Hi has anyone tried enabling and using the USB sleep interrupt? This is on a usb cdc device application,
It looks like I should be calling usb_hal_khci_enable_interrupts(INTR_SLEEP);
But how and where do I write the interrupt handler to deal with this event?
Or can I use processor expert to generate the interrupt to go in events.c like other interrupts.
Thank you for you time.
So far I've found Setting the parameter
/* Advance suspend resume */
#define USBCFG_DEV_ADVANCED_SUSPEND_RESUME (1)
in usb_device_confih.h should enable the usb sleep interrupt.
Then I've put my usb interrupt handler in events.c
GPIO_DRV_TogglePinOutput(CPU_LED); //CPU_LED toggle
But I've not seen any sign if the interrupt being triggered.
Is there another enable I'm missing somewhere?
USB0_IRQHandler must be reserved for USB stack and should not be modified by user.
If you want to enable sleep interrupt, then, as you already saw, you need to enable suspend option on usb_device_config.h:
/* Advance suspend resume */ #define USBCFG_DEV_ADVANCED_SUSPEND_RESUME (1)
After that, all suspend events will be attend on USB_Device_callback (where other events such as bus reset, enumeration complete, among others are handled), for this basic example, I print on console that suspend event is received and increment a counter:
case USB_DEV_EVENT_SUSPEND: suspend_times++; USB_PRINTF("SUSPEND MODE: %d\r\n", suspend_times); break; case USB_DEV_EVENT_ENUM_COMPLETE: /* Device enumerated process complete */ /* Write your code here ... */ break;
This is all you need to do in order to enable sleep interrupt on USB stack from KSDK 1.3
I hope this helps!