/****************************************************************************** Standard usb request handler Parameters: data - pointer to host's request ******************************************************************************/ void runtimeRequestHandler(uint8_t *data) { UsbRequest_t *pRequest = NULL; pRequest = (UsbRequest_t *)data; if (NULL == pRequest) return; // Check request code switch (pRequest->bRequest) { case USB_GET_DESCRIPTOR: // Send the requested descriptor runtimeGetDescriptorHandler((uint8_t)(pRequest->wValue >> 8), (uint8_t)(pRequest->wValue), pRequest->wLength); break; case USB_SET_ADDRESS: usbAddress = pRequest->wValue & 0x7F; #if defined(AT91SAM7X512) || defined(AT91SAM3S4C) HAL_UsbWrite(0, 0, 0, (TransferCallback_t) HAL_SetAddress, (void *)&usbAddress); #elif defined(AT90USB1287) HAL_SetAddress((uint8_t *)&usbAddress); #endif break; case USB_SET_CONFIGURATION: // Set the requested configuration runtimeSetConfiguration((uint8_t)pRequest->wValue); #if (APP_INTERFACE == APP_INTERFACE_VCP) HAL_ConfigureEndpoint((void *)&(usbConfigDescr.endpointIfc1)); HAL_ConfigureEndpoint((void *)&(usbConfigDescr.endpointIfc2[0])); HAL_ConfigureEndpoint((void *)&(usbConfigDescr.endpointIfc2[1])); HAL_UsbRead(VCP_RECEIVE_PIPE, vcpPointDescrip->rxBuffer, BULK_SIZE, vcpRcvCallback, NULL); #endif // (APP_INTERFACE == APP_INTERFACE_VCP) #if (MSD_SUPPORT == 1) HAL_ConfigureEndpoint((void *)&(usbConfigDescr.endpointIfc3[0])); HAL_ConfigureEndpoint((void *)&(usbConfigDescr.endpointIfc3[1])); HAL_UsbRead(MSD_RECEIVE_PIPE, msdPointDescr->dataTransferDescriptor->buffer, BULK_SIZE, msdRcvCallback, NULL); #endif // (MSD_SUPPORT == 1) break; default: setupProcessRequestHandler(data); 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; } }