Files
bia_microddr_fw/bootloader/src/usb_events.c

86 lines
2.7 KiB
C

#include "usb.h"
#include "usb_device_hid.h"
#include "bootloader.h"
/*******************************************************************
* Function: bool USER_USB_CALLBACK_EVENT_HANDLER(
* USB_EVENT event, void *pdata, uint16_t size)
*
* PreCondition: None
*
* Input: USB_EVENT event - the type of event
* void *pdata - pointer to the event data
* uint16_t size - size of the event data
*
* Output: None
*
* Side Effects: None
*
* Overview: This function is called from the USB stack to
* notify a user application that a USB event
* occured. This callback is in interrupt context
* when the USB_INTERRUPT option is selected.
*
* Note: None
*******************************************************************/
bool USER_USB_CALLBACK_EVENT_HANDLER(USB_EVENT event, void *pdata, uint16_t size)
{
switch( (int) event )
{
case EVENT_TRANSFER:
break;
case EVENT_SOF:
break;
case EVENT_SUSPEND:
//Call the hardware platform specific handler for suspend events for
//possible further action (like optionally going reconfiguring the application
//for lower power states and going to sleep during the suspend event). This
//would normally be done in USB compliant bus powered applications, although
//no further processing is needed for purely self powered applications that
//don't consume power from the host.
//asm("SLEEP"); // sleep right now, execution starts on next line when woken up
// we have been woken up. if the watchdog was the cause go back to sleep
//while ((PIR2bits.USBIF == 0) && (RCONbits.TO == 0))
//{
// asm("SLEEP");
//}
break;
case EVENT_RESUME:
// restore any hardware states (i.e. IO pin config) that were changed on suspend
break;
case EVENT_CONFIGURED:
// When the device is configured, we should (re)initialize our state variables
UserInit();
break;
case EVENT_SET_DESCRIPTOR:
break;
case EVENT_EP0_REQUEST:
/* We have received a non-standard USB request. The HID driver
* needs to check to see if the request was for it. */
USBCheckHIDRequest();
break;
case EVENT_BUS_ERROR:
break;
case EVENT_TRANSFER_TERMINATED:
break;
default:
break;
}
return true;
}
/*******************************************************************************
End of File
*/