Hi guys,
I have an USB application with the V-USB library and want to detect if the host is in suspend mode.
If it's true, then a LED should turn off. When the host wakes up, the LED should turn on.
In my case, D- is connected to INT0. INT1 is already used by another hardware.
Is there an easy method to do that?
Cheers,
AlexDigital
Detect Suspend Mode
Re: Detect Suspend Mode
I've done this in my keyboard converter by putting the CPU to sleep regularly and having it woken by the USB interrupt or a timeout interrupt that fires when the host is suspended and thus doing no USB activity. Something like
You could use the USB_RESET_HOOK to detect when the host reawakens.
Code: Select all
static volatile bool usb_inactive;
ISR(TIMER1_OVF_vect)
{
usb_inactive = true;
}
void check_inactive()
{
TCNT1 = -inactive_timeout;
usb_inactive = false;
sleep_enable();
sleep_cpu();
if ( usb_inactive )
{
...
}
}
You could use the USB_RESET_HOOK to detect when the host reawakens.