-/** Event handler for the USB_UnhandledControlRequest event. This is used to catch standard and class specific
- * control requests that are not handled internally by the USB library, so that they can be handled appropriately
- * for the application.
- */
-void EVENT_USB_Device_UnhandledControlRequest(void)
-{
- uint8_t* LineCodingData = (uint8_t*)&LineCoding;
-
- /* Process CDC specific control requests */
- switch (USB_ControlRequest.bRequest)
- {
- case REQ_GetLineEncoding:
- if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
- {
- Endpoint_ClearSETUP();
-
- for (uint8_t i = 0; i < sizeof(LineCoding); i++)
- Endpoint_Write_Byte(*(LineCodingData++));
-
- Endpoint_ClearIN();
-
- Endpoint_ClearStatusStage();
- }
-
- break;
- case REQ_SetLineEncoding:
- if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
- {
- Endpoint_ClearSETUP();
-
- while (!(Endpoint_IsOUTReceived()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
-
- for (uint8_t i = 0; i < sizeof(LineCoding); i++)
- *(LineCodingData++) = Endpoint_Read_Byte();
-
- Endpoint_ClearOUT();
-
- Endpoint_ClearStatusStage();
- }
-
- break;
- case REQ_SetControlLineState:
- if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
- {
- Endpoint_ClearSETUP();
-
- Endpoint_ClearStatusStage();
- }
-
- break;
- }
-}
-