/*********************************************************************************** * @fn usbEventProcess * * @brief Handle the USB events which are not directly related to the UART. * * @param none * * @return none */ static void usbEventProcess(void) { // Handle reset signaling on the bus if (USBIRQ_GET_EVENT_MASK() & USBIRQ_EVENT_RESET) { USBIRQ_CLEAR_EVENTS(USBIRQ_EVENT_RESET); usbfwResetHandler(); } // Handle packets on EP0 if (USBIRQ_GET_EVENT_MASK() & USBIRQ_EVENT_SETUP) { USBIRQ_CLEAR_EVENTS(USBIRQ_EVENT_SETUP); usbfwSetupHandler(); } // Handle USB suspend if (USBIRQ_GET_EVENT_MASK() & USBIRQ_EVENT_SUSPEND) { // Clear USB suspend interrupt USBIRQ_CLEAR_EVENTS(USBIRQ_EVENT_SUSPEND); // Take the chip into PM1 until a USB resume is deteceted. usbsuspEnter(); // Running again; first clear RESUME interrupt USBIRQ_CLEAR_EVENTS(USBIRQ_EVENT_RESUME); } }
/*********************************************************************************** * @fn halUartPollEvt * * @brief Poll for USB events which are not directly related to the UART. * * @param none * * @return none */ void halUartPollEvt(void) { /* Handle reset signaling on the bus */ if (USBIRQ_GET_EVENT_MASK() & USBIRQ_EVENT_RESET) { USBIRQ_CLEAR_EVENTS(USBIRQ_EVENT_RESET); usbfwResetHandler(); } /* Handle packets on EP0 */ if (USBIRQ_GET_EVENT_MASK() & USBIRQ_EVENT_SETUP) { USBIRQ_CLEAR_EVENTS(USBIRQ_EVENT_SETUP); usbfwSetupHandler(); } /* Handle USB suspend */ if (USBIRQ_GET_EVENT_MASK() & USBIRQ_EVENT_SUSPEND) { /* Clear USB suspend interrupt */ USBIRQ_CLEAR_EVENTS(USBIRQ_EVENT_SUSPEND); #if HAL_UART_USB_SUSPEND /* Take the chip into PM1 until a USB resume is deteceted. */ usbsuspEnter(); #endif /* Running again; first clear RESUME interrupt */ USBIRQ_CLEAR_EVENTS(USBIRQ_EVENT_RESUME); } }
/** \brief Processes USB HID events. * * This function processes USB events. Calls application callback function * usbHidAppPoll(). */ void usbHidProcessEvents(void) { // // Handle USB resume // if(USBIRQ_GET_EVENT_MASK() & USBIRQ_EVENT_RESUME) { USBIRQ_CLEAR_EVENTS(USBIRQ_EVENT_RESUME); } // // Handle USB reset // if(USBIRQ_GET_EVENT_MASK() & USBIRQ_EVENT_RESET) { USBIRQ_CLEAR_EVENTS(USBIRQ_EVENT_RESET); usbfwResetHandler(); } // // Handle USB suspend // if(USBIRQ_GET_EVENT_MASK() & USBIRQ_EVENT_SUSPEND) { USBIRQ_CLEAR_EVENTS(USBIRQ_EVENT_SUSPEND); usbsuspEnter(); } // // Handle USB packets on EP0 // if(USBIRQ_GET_EVENT_MASK() & USBIRQ_EVENT_SETUP) { USBIRQ_CLEAR_EVENTS(USBIRQ_EVENT_SETUP); usbfwSetupHandler(); } // // Call application polling callback // usbHidAppPoll(); }