/****************************************************************************** Usb setup process request handler Parameters: data - pointer to host's request ******************************************************************************/ void setupProcessRequestHandler(uint8_t *data) { UsbRequest_t *pRequest = NULL; pRequest = (UsbRequest_t *)data; if (NULL == pRequest) return; switch (pRequest->wIndex) { #if (APP_INTERFACE == APP_INTERFACE_VCP) case NUMBER_OF_FIRST_INTERFACE: vcpRequestHandler(data); break; #endif // (APP_INTERFACE == APP_INTERFACE_VCP) /* MSC commands */ #if (MSD_SUPPORT == 1) #if (APP_INTERFACE == APP_INTERFACE_VCP) case NUMBER_OF_THIRD_INTERFACE: #else case NUMBER_OF_FIRST_INTERFACE: #endif msdRequestHandler(data); break; #endif // (MSD_SUPPORT == 1) #if (DFU_SUPPORT == 1) #if (APP_INTERFACE == APP_INTERFACE_VCP) #if (MSD_SUPPORT == 1) case NUMBER_OF_FOURTH_INTERFACE: #else case NUMBER_OF_THIRD_INTERFACE: #endif #else case NUMBER_OF_SECOND_INTERFACE: #endif // (APP_INTERFACE == APP_INTERFACE_VCP) dfuRequestHandler(data); break; #endif // (DFU_SUPPORT == 1) default: HAL_Stall(0); break; } }
/****************************************************************************** Standard usb request handler ******************************************************************************/ void runtimeRequestHandler(void) { // Check request code switch (request.bRequest) { case USB_GET_DESCRIPTOR: // Send the requested descriptor runtimeGetDescriptorHandler((uint8_t)(request.wValue >> 8), (uint8_t)(request.wValue), request.wLength); break; case USB_SET_ADDRESS: usbAddress = request.wValue & 0x7F; txUsbData(0, 0, (TransferCallback_t)setUsbAddress, (void *)&usbAddress); break; case USB_SET_CONFIGURATION: // Set the requested configuration runtimeSetConfiguration((uint8_t)request.wValue); break; default: dfuRequestHandler(); break; } }