When the PC turn on or off?

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
dehghanimeh
Posts: 6
Joined: Mon Jan 12, 2009 11:04 am

When the PC turn on or off?

Post by dehghanimeh » Fri Oct 30, 2009 11:18 pm

hi
I want to know that When the PC turn on or off (hid-data sampel)
i am using this macro

Code: Select all

#define USB_RX_USER_HOOK(data, len)     if(usbRxToken == (uchar)USBPID_SETUP) blinkLED(data, len);
--------------------------------------------
void blinkLED(uchar *data, uchar len)
{
usbRequest_t    *rq = (void *)data;

ledRedOff();
}


i changed the input blinkLED function for accept any setup control transfer data
but i don't know which field of usbRequest_t and value means that the PC turn on or off.

thank you

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Re: When the PC turn on or off?

Post by christian » Sun Nov 01, 2009 10:58 am

The PC won't tell you directly when it turns on or of. You can check for SOF pulses on D-. They occur every 1 ms if the PC is on. It helps to have D- on an interrupt or even use D- for the USB interrupt in order to detect these pulses.

Post Reply