Page 1 of 1

When the PC turn on or off?

Posted: Fri Oct 30, 2009 11:18 pm
by dehghanimeh
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

Re: When the PC turn on or off?

Posted: Sun Nov 01, 2009 10:58 am
by christian
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.