/*FUNCTION*---------------------------------------------------------------- * * Function Name : usb_device_call_service * Returned Value : USB_OK or error code * Comments : * Calls the appropriate service for the specified type, if one is * registered. Used internally only. * *END*--------------------------------------------------------------------*/ usb_status _usb_device_call_service_internal ( /* [IN] pointer to usb device status structure */ usb_dev_state_struct_t* usb_dev_ptr, /* [IN] pointer to event structure */ usb_event_struct_t* event ) { service_struct_t* service_ptr = NULL; uint32_t i; /* Needs mutual exclusion */ //OS_Mutex_lock(usb_dev_ptr->mutex); switch (event->type) { case USB_SERVICE_EP0: USB_Control_Service(&usb_dev_ptr->usb_framework, event, NULL); break; case USB_SERVICE_BUS_RESET: USB_Reset_Service(&usb_dev_ptr->usb_framework, event, NULL); break; #if USBCFG_DEV_ADVANCED_SUSPEND_RESUME case USB_SERVICE_SUSPEND: USB_Suspend_Service(&usb_dev_ptr->usb_framework, event, NULL); break; case USB_SERVICE_RESUME: USB_Resume_Service(&usb_dev_ptr->usb_framework, event, NULL); break; #endif #if USBCFG_DEV_KHCI_ADVANCED_ERROR_HANDLING case USB_SERVICE_ERROR: USB_Error_Service(&usb_dev_ptr->usb_framework, event, NULL); break; #endif #if USBCFG_DEV_DETACH_ENABLE case USB_SERVICE_DETACH: USB_Detach_Service(&usb_dev_ptr->usb_framework, event, NULL); break; #endif default: break; } /* Endswitch */ /* Search for an existing entry for type */ for (i = 0; i < MAX_DEVICE_SERVICE_NUMBER; i++) { service_ptr = &usb_dev_ptr->services[i]; if (service_ptr->type == event->type) { service_ptr->service(event,service_ptr->arg); //OS_Mutex_unlock(usb_dev_ptr->mutex); return USB_OK; } } //OS_Mutex_unlock(usb_dev_ptr->mutex); return USBERR_CLOSED_SERVICE; } /* EndBody */
/**************************************************************************//*! * * @name USB_Framework_Periodic_Task * * @brief The funtion is called to respond to any control request * * @param None * * @return None * *****************************************************************************/ void USB_Framework_Periodic_Task(void) { /* if control request pending to be completed */ if(g_control_pending==TRUE) { /* handle pending control request */ USB_Control_Service(&g_f_event); g_control_pending=FALSE; } }