Detection Suspend Mode - example.

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
Maxx

Detection Suspend Mode - example.

Post by Maxx » Thu Dec 25, 2014 4:40 pm

I have no opportunity to use the usbSofCount variable therefore I realized another method of detection of a suspend mode:


Code: Select all

    for(;;){                /* main event loop */
       
        usbPoll();
         
      if(IsBusy){         
             StartProcess();
            IsBusy = 0;
   
       }else Sleep();      
   
    }



Code: Select all

void Sleep()
{
   
   
unsigned int a = 1024, taqt = 0;;
unsigned char val = 0, val_2 = 0;


   val = PINB&0x01;
   

   while(--a){             
      
      val_2 = PINB&0x01;
      
      if(val!=val_2)
         taqt++;      
      
      val = val_2;
            
   }
   
   if(taqt){
      OnLed();
   }else OffLed();
   
   
}



I don't use the mode of the low-energy consumption but only I disconnect a LED.

It is an example, possibly, it is written not absolutely correctly :) You don't judge strictly :)

Post Reply