diff --git a/Bootloaders/CDC/BootloaderCDC.c b/Bootloaders/CDC/BootloaderCDC.c index cb6a980cc..61a3b9411 100644 --- a/Bootloaders/CDC/BootloaderCDC.c +++ b/Bootloaders/CDC/BootloaderCDC.c @@ -219,13 +219,13 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { /* Ignore any requests that aren't directed to the CDC interface */ if ((USB_ControlRequest.bmRequestType & (CONTROL_REQTYPE_TYPE | CONTROL_REQTYPE_RECIPIENT)) != (REQTYPE_CLASS | REQREC_INTERFACE)) { - return; + return 0; } /* Activity - toggle indicator LEDs */ @@ -242,6 +242,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Write the line coding data to the control endpoint */ Endpoint_Write_Control_Stream_LE(&LineEncoding, sizeof(CDC_LineEncoding_t)); Endpoint_ClearOUT(); + return 1; } break; @@ -253,6 +254,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Read the line coding data in from the host into the global struct */ Endpoint_Read_Control_Stream_LE(&LineEncoding, sizeof(CDC_LineEncoding_t)); Endpoint_ClearIN(); + return 1; } break; @@ -261,10 +263,12 @@ void EVENT_USB_Device_ControlRequest(void) { Endpoint_ClearSETUP(); Endpoint_ClearStatusStage(); + return 1; } break; } + return 0; } #if !defined(NO_BLOCK_SUPPORT) diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c index 4a0d73043..5cb13aa74 100644 --- a/Bootloaders/DFU/BootloaderDFU.c +++ b/Bootloaders/DFU/BootloaderDFU.c @@ -247,13 +247,13 @@ ISR(TIMER1_OVF_vect, ISR_BLOCK) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { /* Ignore any requests that aren't directed to the DFU interface */ if ((USB_ControlRequest.bmRequestType & (CONTROL_REQTYPE_TYPE | CONTROL_REQTYPE_RECIPIENT)) != (REQTYPE_CLASS | REQREC_INTERFACE)) { - return; + return 0; } /* Activity - toggle indicator LEDs */ @@ -283,7 +283,7 @@ void EVENT_USB_Device_ControlRequest(void) while (!(Endpoint_IsOUTReceived())) { if (USB_DeviceState == DEVICE_STATE_Unattached) - return; + return 0; } /* First byte of the data stage is the DNLOAD request's command */ @@ -415,6 +415,7 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearOUT(); Endpoint_ClearStatusStage(); + return 1; break; case DFU_REQ_UPLOAD: @@ -423,7 +424,7 @@ void EVENT_USB_Device_ControlRequest(void) while (!(Endpoint_IsINReady())) { if (USB_DeviceState == DEVICE_STATE_Unattached) - return; + return 0; } if (DFU_State != dfuUPLOAD_IDLE) @@ -515,6 +516,7 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; break; case DFU_REQ_GETSTATUS: Endpoint_ClearSETUP(); @@ -522,7 +524,7 @@ void EVENT_USB_Device_ControlRequest(void) while (!(Endpoint_IsINReady())) { if (USB_DeviceState == DEVICE_STATE_Unattached) - return; + return 0; } /* Write 8-bit status value */ @@ -541,6 +543,7 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; break; case DFU_REQ_CLRSTATUS: Endpoint_ClearSETUP(); @@ -549,6 +552,7 @@ void EVENT_USB_Device_ControlRequest(void) DFU_Status = OK; Endpoint_ClearStatusStage(); + return 1; break; case DFU_REQ_GETSTATE: Endpoint_ClearSETUP(); @@ -556,7 +560,7 @@ void EVENT_USB_Device_ControlRequest(void) while (!(Endpoint_IsINReady())) { if (USB_DeviceState == DEVICE_STATE_Unattached) - return; + return 0; } /* Write the current device state to the endpoint */ @@ -565,6 +569,7 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; break; case DFU_REQ_ABORT: Endpoint_ClearSETUP(); @@ -573,8 +578,10 @@ void EVENT_USB_Device_ControlRequest(void) DFU_State = dfuIDLE; Endpoint_ClearStatusStage(); + return 1; break; } + return 0; } /** Routine to discard the specified number of bytes from the control endpoint stream. This is used to diff --git a/Bootloaders/DFU/BootloaderDFU.h b/Bootloaders/DFU/BootloaderDFU.h index 73c4b4004..58230f608 100644 --- a/Bootloaders/DFU/BootloaderDFU.h +++ b/Bootloaders/DFU/BootloaderDFU.h @@ -198,7 +198,7 @@ static void SetupHardware(void); static void ResetHardware(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #if defined(INCLUDE_FROM_BOOTLOADER_C) static void DiscardFillerBytes(uint8_t NumberOfBytes); diff --git a/Bootloaders/HID/BootloaderHID.c b/Bootloaders/HID/BootloaderHID.c index bdff1eda3..1de96f555 100644 --- a/Bootloaders/HID/BootloaderHID.c +++ b/Bootloaders/HID/BootloaderHID.c @@ -119,13 +119,13 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { /* Ignore any requests that aren't directed to the HID interface */ if ((USB_ControlRequest.bmRequestType & (CONTROL_REQTYPE_TYPE | CONTROL_REQTYPE_RECIPIENT)) != (REQTYPE_CLASS | REQREC_INTERFACE)) { - return; + return 0; } /* Process HID specific control requests */ @@ -184,7 +184,10 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearOUT(); Endpoint_ClearStatusStage(); + return 1; break; } + + return 0; } diff --git a/Bootloaders/MassStorage/BootloaderMassStorage.c b/Bootloaders/MassStorage/BootloaderMassStorage.c index 776e6b738..438286363 100644 --- a/Bootloaders/MassStorage/BootloaderMassStorage.c +++ b/Bootloaders/MassStorage/BootloaderMassStorage.c @@ -239,9 +239,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - MS_Device_ProcessControlRequest(&Disk_MS_Interface); + return MS_Device_ProcessControlRequest(&Disk_MS_Interface); } /** Mass Storage class driver callback function the reception of SCSI commands from the host, which must be processed. diff --git a/Bootloaders/MassStorage/BootloaderMassStorage.h b/Bootloaders/MassStorage/BootloaderMassStorage.h index fc084dc94..afd37fc3d 100644 --- a/Bootloaders/MassStorage/BootloaderMassStorage.h +++ b/Bootloaders/MassStorage/BootloaderMassStorage.h @@ -87,7 +87,7 @@ void EVENT_USB_Device_Connect(void) AUX_BOOT_SECTION; void EVENT_USB_Device_Disconnect(void) AUX_BOOT_SECTION; void EVENT_USB_Device_ConfigurationChanged(void) AUX_BOOT_SECTION; - void EVENT_USB_Device_ControlRequest(void) AUX_BOOT_SECTION; + int EVENT_USB_Device_ControlRequest(void) AUX_BOOT_SECTION; bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION; diff --git a/Bootloaders/Printer/BootloaderPrinter.c b/Bootloaders/Printer/BootloaderPrinter.c index aaf3ef1cc..06fe8e564 100644 --- a/Bootloaders/Printer/BootloaderPrinter.c +++ b/Bootloaders/Printer/BootloaderPrinter.c @@ -481,7 +481,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - PRNT_Device_ProcessControlRequest(&TextOnly_Printer_Interface); + return PRNT_Device_ProcessControlRequest(&TextOnly_Printer_Interface); } diff --git a/Bootloaders/Printer/BootloaderPrinter.h b/Bootloaders/Printer/BootloaderPrinter.h index b8d421e1e..959740291 100644 --- a/Bootloaders/Printer/BootloaderPrinter.h +++ b/Bootloaders/Printer/BootloaderPrinter.h @@ -102,7 +102,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #endif diff --git a/Demos/Device/ClassDriver/AudioInput/AudioInput.c b/Demos/Device/ClassDriver/AudioInput/AudioInput.c index 7e7b919ce..45f776574 100644 --- a/Demos/Device/ClassDriver/AudioInput/AudioInput.c +++ b/Demos/Device/ClassDriver/AudioInput/AudioInput.c @@ -167,9 +167,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - Audio_Device_ProcessControlRequest(&Microphone_Audio_Interface); + return Audio_Device_ProcessControlRequest(&Microphone_Audio_Interface); } /** Audio class driver callback for the setting and retrieval of streaming endpoint properties. This callback must be implemented diff --git a/Demos/Device/ClassDriver/AudioInput/AudioInput.h b/Demos/Device/ClassDriver/AudioInput/AudioInput.h index dee883e43..626a480b5 100644 --- a/Demos/Device/ClassDriver/AudioInput/AudioInput.h +++ b/Demos/Device/ClassDriver/AudioInput/AudioInput.h @@ -76,7 +76,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, const uint8_t EndpointProperty, diff --git a/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c b/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c index fb5c1bd13..8c1986009 100644 --- a/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c +++ b/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c @@ -204,9 +204,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - Audio_Device_ProcessControlRequest(&Speaker_Audio_Interface); + return Audio_Device_ProcessControlRequest(&Speaker_Audio_Interface); } /** Audio class driver callback for the setting and retrieval of streaming endpoint properties. This callback must be implemented diff --git a/Demos/Device/ClassDriver/DualMIDI/DualMIDI.c b/Demos/Device/ClassDriver/DualMIDI/DualMIDI.c index 1f00ba0da..d3364bb8e 100644 --- a/Demos/Device/ClassDriver/DualMIDI/DualMIDI.c +++ b/Demos/Device/ClassDriver/DualMIDI/DualMIDI.c @@ -204,8 +204,8 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - MIDI_Device_ProcessControlRequest(&Keyboard_MIDI_Interface); + return MIDI_Device_ProcessControlRequest(&Keyboard_MIDI_Interface); } diff --git a/Demos/Device/ClassDriver/DualMIDI/DualMIDI.h b/Demos/Device/ClassDriver/DualMIDI/DualMIDI.h index ca64e01b5..709c471ae 100644 --- a/Demos/Device/ClassDriver/DualMIDI/DualMIDI.h +++ b/Demos/Device/ClassDriver/DualMIDI/DualMIDI.h @@ -72,7 +72,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #endif diff --git a/Demos/Device/ClassDriver/DualVirtualSerial/DualVirtualSerial.c b/Demos/Device/ClassDriver/DualVirtualSerial/DualVirtualSerial.c index 746a00725..8bbb43866 100644 --- a/Demos/Device/ClassDriver/DualVirtualSerial/DualVirtualSerial.c +++ b/Demos/Device/ClassDriver/DualVirtualSerial/DualVirtualSerial.c @@ -210,10 +210,16 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - CDC_Device_ProcessControlRequest(&VirtualSerial1_CDC_Interface); - CDC_Device_ProcessControlRequest(&VirtualSerial2_CDC_Interface); + int request_handled; + + request_handled = CDC_Device_ProcessControlRequest(&VirtualSerial1_CDC_Interface); + if (!request_handled) { + request_handled = CDC_Device_ProcessControlRequest(&VirtualSerial2_CDC_Interface); + } + + return request_handled; } /** CDC class driver callback function the processing of changes to the virtual diff --git a/Demos/Device/ClassDriver/DualVirtualSerial/DualVirtualSerial.h b/Demos/Device/ClassDriver/DualVirtualSerial/DualVirtualSerial.h index acf0b2296..3ffdee979 100644 --- a/Demos/Device/ClassDriver/DualVirtualSerial/DualVirtualSerial.h +++ b/Demos/Device/ClassDriver/DualVirtualSerial/DualVirtualSerial.h @@ -70,7 +70,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #endif diff --git a/Demos/Device/ClassDriver/GenericHID/GenericHID.c b/Demos/Device/ClassDriver/GenericHID/GenericHID.c index 661a745c7..713752a8c 100644 --- a/Demos/Device/ClassDriver/GenericHID/GenericHID.c +++ b/Demos/Device/ClassDriver/GenericHID/GenericHID.c @@ -129,9 +129,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - HID_Device_ProcessControlRequest(&Generic_HID_Interface); + return HID_Device_ProcessControlRequest(&Generic_HID_Interface); } /** Event handler for the USB device Start Of Frame event. */ diff --git a/Demos/Device/ClassDriver/GenericHID/GenericHID.h b/Demos/Device/ClassDriver/GenericHID/GenericHID.h index c710d0a8e..c1720262b 100644 --- a/Demos/Device/ClassDriver/GenericHID/GenericHID.h +++ b/Demos/Device/ClassDriver/GenericHID/GenericHID.h @@ -69,7 +69,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_USB_Device_StartOfFrame(void); bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, diff --git a/Demos/Device/ClassDriver/Joystick/Joystick.c b/Demos/Device/ClassDriver/Joystick/Joystick.c index b05ffcb52..816f7cb80 100644 --- a/Demos/Device/ClassDriver/Joystick/Joystick.c +++ b/Demos/Device/ClassDriver/Joystick/Joystick.c @@ -131,9 +131,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - HID_Device_ProcessControlRequest(&Joystick_HID_Interface); + return HID_Device_ProcessControlRequest(&Joystick_HID_Interface); } /** Event handler for the USB device Start Of Frame event. */ diff --git a/Demos/Device/ClassDriver/Joystick/Joystick.h b/Demos/Device/ClassDriver/Joystick/Joystick.h index 7bd04d5f1..c74c54455 100644 --- a/Demos/Device/ClassDriver/Joystick/Joystick.h +++ b/Demos/Device/ClassDriver/Joystick/Joystick.h @@ -82,7 +82,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_USB_Device_StartOfFrame(void); bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, diff --git a/Demos/Device/ClassDriver/Keyboard/Keyboard.c b/Demos/Device/ClassDriver/Keyboard/Keyboard.c index 7c53a8f68..5f8189a9b 100644 --- a/Demos/Device/ClassDriver/Keyboard/Keyboard.c +++ b/Demos/Device/ClassDriver/Keyboard/Keyboard.c @@ -131,9 +131,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - HID_Device_ProcessControlRequest(&Keyboard_HID_Interface); + return HID_Device_ProcessControlRequest(&Keyboard_HID_Interface); } /** Event handler for the USB device Start Of Frame event. */ diff --git a/Demos/Device/ClassDriver/Keyboard/Keyboard.h b/Demos/Device/ClassDriver/Keyboard/Keyboard.h index 80999f905..421f404a6 100644 --- a/Demos/Device/ClassDriver/Keyboard/Keyboard.h +++ b/Demos/Device/ClassDriver/Keyboard/Keyboard.h @@ -71,7 +71,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_USB_Device_StartOfFrame(void); bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, diff --git a/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c b/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c index e81d0fb9a..9a856be53 100644 --- a/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c +++ b/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c @@ -157,10 +157,16 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - HID_Device_ProcessControlRequest(&Keyboard_HID_Interface); - HID_Device_ProcessControlRequest(&Mouse_HID_Interface); + int request_handled; + + request_handled = HID_Device_ProcessControlRequest(&Keyboard_HID_Interface); + if (!request_handled) { + request_handled = HID_Device_ProcessControlRequest(&Mouse_HID_Interface); + } + + return request_handled; } /** Event handler for the USB device Start Of Frame event. */ diff --git a/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.h b/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.h index 87b31efd3..981ea07f5 100644 --- a/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.h +++ b/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.h @@ -66,7 +66,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_USB_Device_StartOfFrame(void); bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, diff --git a/Demos/Device/ClassDriver/KeyboardMouseMultiReport/KeyboardMouseMultiReport.c b/Demos/Device/ClassDriver/KeyboardMouseMultiReport/KeyboardMouseMultiReport.c index a56fb37c4..6304ead21 100644 --- a/Demos/Device/ClassDriver/KeyboardMouseMultiReport/KeyboardMouseMultiReport.c +++ b/Demos/Device/ClassDriver/KeyboardMouseMultiReport/KeyboardMouseMultiReport.c @@ -130,9 +130,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - HID_Device_ProcessControlRequest(&Device_HID_Interface); + return HID_Device_ProcessControlRequest(&Device_HID_Interface); } /** Event handler for the USB device Start Of Frame event. */ diff --git a/Demos/Device/ClassDriver/KeyboardMouseMultiReport/KeyboardMouseMultiReport.h b/Demos/Device/ClassDriver/KeyboardMouseMultiReport/KeyboardMouseMultiReport.h index 87b31efd3..981ea07f5 100644 --- a/Demos/Device/ClassDriver/KeyboardMouseMultiReport/KeyboardMouseMultiReport.h +++ b/Demos/Device/ClassDriver/KeyboardMouseMultiReport/KeyboardMouseMultiReport.h @@ -66,7 +66,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_USB_Device_StartOfFrame(void); bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, diff --git a/Demos/Device/ClassDriver/MIDI/MIDI.c b/Demos/Device/ClassDriver/MIDI/MIDI.c index e3a14c827..722c83b7d 100644 --- a/Demos/Device/ClassDriver/MIDI/MIDI.c +++ b/Demos/Device/ClassDriver/MIDI/MIDI.c @@ -204,8 +204,8 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - MIDI_Device_ProcessControlRequest(&Keyboard_MIDI_Interface); + return MIDI_Device_ProcessControlRequest(&Keyboard_MIDI_Interface); } diff --git a/Demos/Device/ClassDriver/MassStorage/MassStorage.c b/Demos/Device/ClassDriver/MassStorage/MassStorage.c index 48a2f96fd..fc7f20f6a 100644 --- a/Demos/Device/ClassDriver/MassStorage/MassStorage.c +++ b/Demos/Device/ClassDriver/MassStorage/MassStorage.c @@ -140,9 +140,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - MS_Device_ProcessControlRequest(&Disk_MS_Interface); + return MS_Device_ProcessControlRequest(&Disk_MS_Interface); } /** Mass Storage class driver callback function the reception of SCSI commands from the host, which must be processed. diff --git a/Demos/Device/ClassDriver/MassStorage/MassStorage.h b/Demos/Device/ClassDriver/MassStorage/MassStorage.h index 203df52e0..029d5ac65 100644 --- a/Demos/Device/ClassDriver/MassStorage/MassStorage.h +++ b/Demos/Device/ClassDriver/MassStorage/MassStorage.h @@ -75,7 +75,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo); diff --git a/Demos/Device/ClassDriver/MassStorageKeyboard/MassStorageKeyboard.c b/Demos/Device/ClassDriver/MassStorageKeyboard/MassStorageKeyboard.c index 0a622c194..fd8fa1983 100644 --- a/Demos/Device/ClassDriver/MassStorageKeyboard/MassStorageKeyboard.c +++ b/Demos/Device/ClassDriver/MassStorageKeyboard/MassStorageKeyboard.c @@ -169,10 +169,16 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - MS_Device_ProcessControlRequest(&Disk_MS_Interface); - HID_Device_ProcessControlRequest(&Keyboard_HID_Interface); + int request_handled; + + request_handled = MS_Device_ProcessControlRequest(&Disk_MS_Interface); + if (!request_handled) { + request_handled = HID_Device_ProcessControlRequest(&Keyboard_HID_Interface); + } + + return request_handled; } /** Mass Storage class driver callback function the reception of SCSI commands from the host, which must be processed. diff --git a/Demos/Device/ClassDriver/MassStorageKeyboard/MassStorageKeyboard.h b/Demos/Device/ClassDriver/MassStorageKeyboard/MassStorageKeyboard.h index e3a24be68..887a7da44 100644 --- a/Demos/Device/ClassDriver/MassStorageKeyboard/MassStorageKeyboard.h +++ b/Demos/Device/ClassDriver/MassStorageKeyboard/MassStorageKeyboard.h @@ -80,7 +80,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_USB_Device_StartOfFrame(void); bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo); diff --git a/Demos/Device/ClassDriver/Mouse/Mouse.c b/Demos/Device/ClassDriver/Mouse/Mouse.c index 91ae8e15e..3a00fa731 100644 --- a/Demos/Device/ClassDriver/Mouse/Mouse.c +++ b/Demos/Device/ClassDriver/Mouse/Mouse.c @@ -131,9 +131,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - HID_Device_ProcessControlRequest(&Mouse_HID_Interface); + return HID_Device_ProcessControlRequest(&Mouse_HID_Interface); } /** Event handler for the USB device Start Of Frame event. */ diff --git a/Demos/Device/ClassDriver/Mouse/Mouse.h b/Demos/Device/ClassDriver/Mouse/Mouse.h index e6ec70584..09dcb9c6b 100644 --- a/Demos/Device/ClassDriver/Mouse/Mouse.h +++ b/Demos/Device/ClassDriver/Mouse/Mouse.h @@ -72,7 +72,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_USB_Device_StartOfFrame(void); bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, diff --git a/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c b/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c index 95e270c49..6d59b7148 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c +++ b/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c @@ -172,8 +172,8 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - RNDIS_Device_ProcessControlRequest(&Ethernet_RNDIS_Interface); + return RNDIS_Device_ProcessControlRequest(&Ethernet_RNDIS_Interface); } diff --git a/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.h b/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.h index 0e952da3e..cc27ed426 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.h +++ b/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.h @@ -78,7 +78,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #endif diff --git a/Demos/Device/ClassDriver/VirtualSerial/VirtualSerial.c b/Demos/Device/ClassDriver/VirtualSerial/VirtualSerial.c index 18070bc91..c1a08ad5e 100644 --- a/Demos/Device/ClassDriver/VirtualSerial/VirtualSerial.c +++ b/Demos/Device/ClassDriver/VirtualSerial/VirtualSerial.c @@ -180,9 +180,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); + return CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); } /** CDC class driver callback function the processing of changes to the virtual diff --git a/Demos/Device/ClassDriver/VirtualSerial/VirtualSerial.h b/Demos/Device/ClassDriver/VirtualSerial/VirtualSerial.h index da2d7cf34..961605b2e 100644 --- a/Demos/Device/ClassDriver/VirtualSerial/VirtualSerial.h +++ b/Demos/Device/ClassDriver/VirtualSerial/VirtualSerial.h @@ -71,7 +71,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #endif diff --git a/Demos/Device/ClassDriver/VirtualSerialMassStorage/VirtualSerialMassStorage.c b/Demos/Device/ClassDriver/VirtualSerialMassStorage/VirtualSerialMassStorage.c index 6c3da2970..9c6d304b5 100644 --- a/Demos/Device/ClassDriver/VirtualSerialMassStorage/VirtualSerialMassStorage.c +++ b/Demos/Device/ClassDriver/VirtualSerialMassStorage/VirtualSerialMassStorage.c @@ -218,10 +218,16 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); - MS_Device_ProcessControlRequest(&Disk_MS_Interface); + int request_handled; + + request_handled = CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); + if (!request_handled) { + request_handled = MS_Device_ProcessControlRequest(&Disk_MS_Interface); + } + + return request_handled; } /** CDC class driver callback function the processing of changes to the virtual diff --git a/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.c b/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.c index cae378973..ddda368c4 100644 --- a/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.c +++ b/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.c @@ -195,10 +195,16 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); - HID_Device_ProcessControlRequest(&Mouse_HID_Interface); + int request_handled; + + request_handled = CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); + if (!request_handled) { + request_handled = HID_Device_ProcessControlRequest(&Mouse_HID_Interface); + } + + return request_handled; } /** Event handler for the USB device Start Of Frame event. */ diff --git a/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.h b/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.h index 0aebce1cd..66d8a4316 100644 --- a/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.h +++ b/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.h @@ -71,7 +71,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_USB_Device_StartOfFrame(void); bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, diff --git a/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.c b/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.c index b8bdf0f25..9811bd8c0 100644 --- a/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.c +++ b/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.c @@ -153,7 +153,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { uint8_t TMCRequestStatus = TMC_STATUS_SUCCESS; @@ -188,6 +188,7 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; } break; @@ -211,6 +212,7 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; } break; @@ -243,6 +245,7 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; } break; @@ -266,6 +269,7 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; } break; @@ -294,6 +298,7 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; } break; @@ -316,6 +321,7 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; } break; @@ -327,10 +333,12 @@ void EVENT_USB_Device_ControlRequest(void) /* Write the device capabilities to the control endpoint */ Endpoint_Write_Control_Stream_LE(&Capabilities, sizeof(TMC_Capabilities_t)); Endpoint_ClearOUT(); + return 1; } break; } + return 0; } void ProcessSentMessage(uint8_t* const Data, const uint8_t Length) diff --git a/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.h b/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.h index 95ea13bb7..e2a01ff22 100644 --- a/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.h +++ b/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.h @@ -144,7 +144,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #endif diff --git a/Demos/Device/LowLevel/AudioInput/AudioInput.c b/Demos/Device/LowLevel/AudioInput/AudioInput.c index 5ae7c6fd9..833f7e4bd 100644 --- a/Demos/Device/LowLevel/AudioInput/AudioInput.c +++ b/Demos/Device/LowLevel/AudioInput/AudioInput.c @@ -130,7 +130,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { /* Process General and Audio specific control requests */ switch (USB_ControlRequest.bRequest) @@ -144,6 +144,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */ StreamingAudioInterfaceSelected = ((USB_ControlRequest.wValue) != 0); + return 1; } break; @@ -155,6 +156,7 @@ void EVENT_USB_Device_ControlRequest(void) { Endpoint_ClearSETUP(); Endpoint_ClearStatusStage(); + return 1; } break; @@ -179,6 +181,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Adjust sample reload timer to the new frequency */ OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1); + return 1; } } @@ -203,11 +206,13 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearSETUP(); Endpoint_Write_Control_Stream_LE(SampleRate, sizeof(SampleRate)); Endpoint_ClearOUT(); + return 1; } } break; } + return 0; } /** ISR to handle the reloading of the data endpoint with the next sample. */ diff --git a/Demos/Device/LowLevel/AudioInput/AudioInput.h b/Demos/Device/LowLevel/AudioInput/AudioInput.h index ce0716312..51623345a 100644 --- a/Demos/Device/LowLevel/AudioInput/AudioInput.h +++ b/Demos/Device/LowLevel/AudioInput/AudioInput.h @@ -76,7 +76,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #endif diff --git a/Demos/Device/LowLevel/AudioOutput/AudioOutput.c b/Demos/Device/LowLevel/AudioOutput/AudioOutput.c index 89fef035a..b817aff9a 100644 --- a/Demos/Device/LowLevel/AudioOutput/AudioOutput.c +++ b/Demos/Device/LowLevel/AudioOutput/AudioOutput.c @@ -156,7 +156,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { /* Process General and Audio specific control requests */ switch (USB_ControlRequest.bRequest) @@ -170,6 +170,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */ StreamingAudioInterfaceSelected = ((USB_ControlRequest.wValue) != 0); + return 1; } break; @@ -181,6 +182,7 @@ void EVENT_USB_Device_ControlRequest(void) { Endpoint_ClearSETUP(); Endpoint_ClearStatusStage(); + return 1; } break; @@ -205,6 +207,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Adjust sample reload timer to the new frequency */ OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1); + return 1; } } @@ -229,11 +232,13 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearSETUP(); Endpoint_Write_Control_Stream_LE(SampleRate, sizeof(SampleRate)); Endpoint_ClearOUT(); + return 1; } } break; } + return 0; } /** ISR to handle the reloading of the PWM timer with the next sample. */ diff --git a/Demos/Device/LowLevel/AudioOutput/AudioOutput.h b/Demos/Device/LowLevel/AudioOutput/AudioOutput.h index 188a36acb..0149c6bb7 100644 --- a/Demos/Device/LowLevel/AudioOutput/AudioOutput.h +++ b/Demos/Device/LowLevel/AudioOutput/AudioOutput.h @@ -68,7 +68,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #endif diff --git a/Demos/Device/LowLevel/BulkVendor/BulkVendor.c b/Demos/Device/LowLevel/BulkVendor/BulkVendor.c index 865572187..59008eb14 100644 --- a/Demos/Device/LowLevel/BulkVendor/BulkVendor.c +++ b/Demos/Device/LowLevel/BulkVendor/BulkVendor.c @@ -130,7 +130,8 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { // Process vendor specific control requests here + return 0; } diff --git a/Demos/Device/LowLevel/BulkVendor/BulkVendor.h b/Demos/Device/LowLevel/BulkVendor/BulkVendor.h index be1c2e331..8895407a6 100644 --- a/Demos/Device/LowLevel/BulkVendor/BulkVendor.h +++ b/Demos/Device/LowLevel/BulkVendor/BulkVendor.h @@ -70,7 +70,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #endif diff --git a/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.c b/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.c index dd470779a..3f343babc 100644 --- a/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.c +++ b/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.c @@ -156,7 +156,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { /* Determine which interface's Line Coding data is being set from the wIndex parameter */ void* LineEncodingData = (USB_ControlRequest.wIndex == 0) ? &LineEncoding1 : &LineEncoding2; @@ -172,6 +172,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Write the line coding data to the control endpoint */ Endpoint_Write_Control_Stream_LE(LineEncodingData, sizeof(CDC_LineEncoding_t)); Endpoint_ClearOUT(); + return 1; } break; @@ -183,6 +184,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Read the line coding data in from the host into the global struct */ Endpoint_Read_Control_Stream_LE(LineEncodingData, sizeof(CDC_LineEncoding_t)); Endpoint_ClearIN(); + return 1; } break; @@ -191,10 +193,12 @@ void EVENT_USB_Device_ControlRequest(void) { Endpoint_ClearSETUP(); Endpoint_ClearStatusStage(); + return 1; } break; } + return 0; } /** Function to manage CDC data transmission and reception to and from the host for the first CDC interface, which sends joystick diff --git a/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.h b/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.h index 89259d9b8..c48237349 100644 --- a/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.h +++ b/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.h @@ -71,7 +71,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #endif diff --git a/Demos/Device/LowLevel/GenericHID/GenericHID.c b/Demos/Device/LowLevel/GenericHID/GenericHID.c index 87e88e470..8657d0212 100644 --- a/Demos/Device/LowLevel/GenericHID/GenericHID.c +++ b/Demos/Device/LowLevel/GenericHID/GenericHID.c @@ -118,7 +118,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { /* Handle HID Class specific requests */ switch (USB_ControlRequest.bRequest) @@ -135,7 +135,8 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_Write_Control_Stream_LE(&GenericData, sizeof(GenericData)); Endpoint_ClearOUT(); } - + + return 1; break; case HID_REQ_SetReport: if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) @@ -151,8 +152,10 @@ void EVENT_USB_Device_ControlRequest(void) ProcessGenericHIDReport(GenericData); } + return 1; break; } + return 0; } /** Function to process the last received report from the host. diff --git a/Demos/Device/LowLevel/GenericHID/GenericHID.h b/Demos/Device/LowLevel/GenericHID/GenericHID.h index 6b43d943c..146de162d 100644 --- a/Demos/Device/LowLevel/GenericHID/GenericHID.h +++ b/Demos/Device/LowLevel/GenericHID/GenericHID.h @@ -71,7 +71,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_USB_Device_StartOfFrame(void); void ProcessGenericHIDReport(uint8_t* DataArray); diff --git a/Demos/Device/LowLevel/Joystick/Joystick.c b/Demos/Device/LowLevel/Joystick/Joystick.c index 4a57f07d9..606bd3349 100644 --- a/Demos/Device/LowLevel/Joystick/Joystick.c +++ b/Demos/Device/LowLevel/Joystick/Joystick.c @@ -118,7 +118,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { /* Handle HID Class specific requests */ switch (USB_ControlRequest.bRequest) @@ -136,10 +136,12 @@ void EVENT_USB_Device_ControlRequest(void) /* Write the report data to the control endpoint */ Endpoint_Write_Control_Stream_LE(&JoystickReportData, sizeof(JoystickReportData)); Endpoint_ClearOUT(); + return 1; } break; } + return 0; } /** Fills the given HID report data structure with the next HID report to send to the host. diff --git a/Demos/Device/LowLevel/Joystick/Joystick.h b/Demos/Device/LowLevel/Joystick/Joystick.h index af319bffb..2ff91bda8 100644 --- a/Demos/Device/LowLevel/Joystick/Joystick.h +++ b/Demos/Device/LowLevel/Joystick/Joystick.h @@ -83,7 +83,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); bool GetNextReport(USB_JoystickReport_Data_t* const ReportData); diff --git a/Demos/Device/LowLevel/Keyboard/Keyboard.c b/Demos/Device/LowLevel/Keyboard/Keyboard.c index 9342db359..35bdc8580 100644 --- a/Demos/Device/LowLevel/Keyboard/Keyboard.c +++ b/Demos/Device/LowLevel/Keyboard/Keyboard.c @@ -143,7 +143,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { /* Handle HID Class specific requests */ switch (USB_ControlRequest.bRequest) @@ -161,6 +161,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Write the report data to the control endpoint */ Endpoint_Write_Control_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData)); Endpoint_ClearOUT(); + return 1; } break; @@ -173,7 +174,7 @@ void EVENT_USB_Device_ControlRequest(void) while (!(Endpoint_IsOUTReceived())) { if (USB_DeviceState == DEVICE_STATE_Unattached) - return; + return 0; } /* Read in the LED report from the host */ @@ -184,6 +185,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Process the incoming LED report */ ProcessLEDReport(LEDStatus); + return 1; } break; @@ -197,6 +199,7 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; } break; @@ -208,6 +211,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Set or clear the flag depending on what the host indicates that the current Protocol should be */ UsingReportProtocol = (USB_ControlRequest.wValue != 0); + return 1; } break; @@ -219,6 +223,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Get idle period in MSB, IdleCount must be multiplied by 4 to get number of milliseconds */ IdleCount = ((USB_ControlRequest.wValue & 0xFF00) >> 6); + return 1; } break; @@ -232,10 +237,12 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; } break; } + return 0; } /** Event handler for the USB device Start Of Frame event. */ diff --git a/Demos/Device/LowLevel/Keyboard/Keyboard.h b/Demos/Device/LowLevel/Keyboard/Keyboard.h index 676eca536..252b9466d 100644 --- a/Demos/Device/LowLevel/Keyboard/Keyboard.h +++ b/Demos/Device/LowLevel/Keyboard/Keyboard.h @@ -73,7 +73,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_USB_Device_StartOfFrame(void); void CreateKeyboardReport(USB_KeyboardReport_Data_t* const ReportData); diff --git a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c index ebb28d230..3d6f0106a 100644 --- a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c +++ b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c @@ -130,7 +130,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { uint8_t* ReportData; uint8_t ReportSize; @@ -161,6 +161,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Clear the report data afterwards */ memset(ReportData, 0, ReportSize); + return 1; } break; @@ -173,7 +174,7 @@ void EVENT_USB_Device_ControlRequest(void) while (!(Endpoint_IsOUTReceived())) { if (USB_DeviceState == DEVICE_STATE_Unattached) - return; + return 0; } /* Read in the LED report from the host */ @@ -184,10 +185,12 @@ void EVENT_USB_Device_ControlRequest(void) /* Process the incoming LED report */ Keyboard_ProcessLEDReport(LEDStatus); + return 1; } break; } + return 0; } /** Processes a given Keyboard LED report from the host, and sets the board LEDs to match. Since the Keyboard diff --git a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.h b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.h index ce68529c2..37661ff78 100644 --- a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.h +++ b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.h @@ -70,7 +70,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_USB_Device_StartOfFrame(void); #endif diff --git a/Demos/Device/LowLevel/MassStorage/MassStorage.c b/Demos/Device/LowLevel/MassStorage/MassStorage.c index 46762d45d..2f4f3224a 100644 --- a/Demos/Device/LowLevel/MassStorage/MassStorage.c +++ b/Demos/Device/LowLevel/MassStorage/MassStorage.c @@ -140,7 +140,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { /* Process UFI specific control requests */ switch (USB_ControlRequest.bRequest) @@ -153,6 +153,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Indicate that the current transfer should be aborted */ IsMassStoreReset = true; + return 1; } break; @@ -166,10 +167,12 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; } break; } + return 0; } /** Task to manage the Mass Storage interface, reading in Command Block Wrappers from the host, processing the SCSI commands they diff --git a/Demos/Device/LowLevel/MassStorage/MassStorage.h b/Demos/Device/LowLevel/MassStorage/MassStorage.h index 62db99612..727f50e9c 100644 --- a/Demos/Device/LowLevel/MassStorage/MassStorage.h +++ b/Demos/Device/LowLevel/MassStorage/MassStorage.h @@ -81,7 +81,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #if defined(INCLUDE_FROM_MASSSTORAGE_C) static bool ReadInCommandBlock(void); diff --git a/Demos/Device/LowLevel/Mouse/Mouse.c b/Demos/Device/LowLevel/Mouse/Mouse.c index b3662cfd0..a6cdab7cc 100644 --- a/Demos/Device/LowLevel/Mouse/Mouse.c +++ b/Demos/Device/LowLevel/Mouse/Mouse.c @@ -141,7 +141,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { /* Handle HID Class specific requests */ switch (USB_ControlRequest.bRequest) @@ -162,6 +162,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Clear the report data afterwards */ memset(&MouseReportData, 0, sizeof(MouseReportData)); + return 1; } break; @@ -175,6 +176,7 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; } break; @@ -186,6 +188,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Set or clear the flag depending on what the host indicates that the current Protocol should be */ UsingReportProtocol = (USB_ControlRequest.wValue != 0); + return 1; } break; @@ -197,6 +200,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Get idle period in MSB, must multiply by 4 to get the duration in milliseconds */ IdleCount = ((USB_ControlRequest.wValue & 0xFF00) >> 6); + return 1; } break; @@ -210,10 +214,12 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; } break; } + return 0; } /** Event handler for the USB device Start Of Frame event. */ diff --git a/Demos/Device/LowLevel/Mouse/Mouse.h b/Demos/Device/LowLevel/Mouse/Mouse.h index d39762cb9..48347e51c 100644 --- a/Demos/Device/LowLevel/Mouse/Mouse.h +++ b/Demos/Device/LowLevel/Mouse/Mouse.h @@ -72,7 +72,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_USB_Device_StartOfFrame(void); void CreateMouseReport(USB_MouseReport_Data_t* const ReportData); diff --git a/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c b/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c index 324c55093..2884e3b06 100644 --- a/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c +++ b/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c @@ -128,7 +128,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { /* Process RNDIS class commands */ switch (USB_ControlRequest.bRequest) @@ -144,6 +144,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Process the RNDIS message */ ProcessRNDISControlMessage(); + return 1; } break; @@ -166,10 +167,12 @@ void EVENT_USB_Device_ControlRequest(void) /* Reset the message header once again after transmission */ MessageHeader->MessageLength = 0; + return 1; } break; } + return 0; } /** Task to manage the sending and receiving of encapsulated RNDIS data and notifications. This removes the RNDIS diff --git a/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.h b/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.h index 440b709cb..cd4725b51 100644 --- a/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.h +++ b/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.h @@ -81,7 +81,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #endif diff --git a/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.c b/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.c index 4d7937797..1ce82dcd8 100644 --- a/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.c +++ b/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.c @@ -136,7 +136,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { /* Process CDC specific control requests */ switch (USB_ControlRequest.bRequest) @@ -149,6 +149,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Write the line coding data to the control endpoint */ Endpoint_Write_Control_Stream_LE(&LineEncoding, sizeof(CDC_LineEncoding_t)); Endpoint_ClearOUT(); + return 1; } break; @@ -160,6 +161,7 @@ void EVENT_USB_Device_ControlRequest(void) /* Read the line coding data in from the host into the global struct */ Endpoint_Read_Control_Stream_LE(&LineEncoding, sizeof(CDC_LineEncoding_t)); Endpoint_ClearIN(); + return 1; } break; @@ -173,10 +175,12 @@ void EVENT_USB_Device_ControlRequest(void) lines. The mask is read in from the wValue parameter in USB_ControlRequest, and can be masked against the CONTROL_LINE_OUT_* masks to determine the RTS and DTR line states using the following code: */ + return 1; } break; } + return 0; } /** Function to manage CDC data transmission and reception to and from the host. */ diff --git a/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.h b/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.h index 29f34e99f..ce27d5dd4 100644 --- a/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.h +++ b/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.h @@ -70,7 +70,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #endif diff --git a/Demos/DualRole/ClassDriver/MouseHostDevice/DeviceFunctions.c b/Demos/DualRole/ClassDriver/MouseHostDevice/DeviceFunctions.c index 5c3429351..a14978936 100644 --- a/Demos/DualRole/ClassDriver/MouseHostDevice/DeviceFunctions.c +++ b/Demos/DualRole/ClassDriver/MouseHostDevice/DeviceFunctions.c @@ -84,9 +84,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - HID_Device_ProcessControlRequest(&Mouse_HID_Device_Interface); + return HID_Device_ProcessControlRequest(&Mouse_HID_Device_Interface); } /** Event handler for the USB device Start Of Frame event. */ diff --git a/Demos/DualRole/ClassDriver/MouseHostDevice/DeviceFunctions.h b/Demos/DualRole/ClassDriver/MouseHostDevice/DeviceFunctions.h index 72c2a2012..d0f5f384d 100644 --- a/Demos/DualRole/ClassDriver/MouseHostDevice/DeviceFunctions.h +++ b/Demos/DualRole/ClassDriver/MouseHostDevice/DeviceFunctions.h @@ -57,7 +57,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_USB_Device_StartOfFrame(void); #endif diff --git a/LUFA/CodeTemplates/DeviceTemplate/DeviceApplication.c b/LUFA/CodeTemplates/DeviceTemplate/DeviceApplication.c index ff36c18de..a8eaeee9d 100644 --- a/LUFA/CodeTemplates/DeviceTemplate/DeviceApplication.c +++ b/LUFA/CodeTemplates/DeviceTemplate/DeviceApplication.c @@ -100,7 +100,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - + return 0; /* If event is handled here, return 1 */ } diff --git a/LUFA/Drivers/USB/Class/Device/AudioClassDevice.c b/LUFA/Drivers/USB/Class/Device/AudioClassDevice.c index 1c78750b9..669495732 100644 --- a/LUFA/Drivers/USB/Class/Device/AudioClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/AudioClassDevice.c @@ -37,10 +37,10 @@ #define __INCLUDE_FROM_AUDIO_DEVICE_C #include "AudioClassDevice.h" -void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) +int Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) { if (!(Endpoint_IsSETUPReceived())) - return; + return 0; if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_INTERFACE) { @@ -49,7 +49,7 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi if ((InterfaceIndex != AudioInterfaceInfo->Config.ControlInterfaceNumber) && (InterfaceIndex != AudioInterfaceInfo->Config.StreamingInterfaceNumber)) { - return; + return 0; } } else if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_ENDPOINT) @@ -59,7 +59,7 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi if ((EndpointAddress != AudioInterfaceInfo->Config.DataINEndpoint.Address) && (EndpointAddress != AudioInterfaceInfo->Config.DataOUTEndpoint.Address)) { - return; + return 0; } } @@ -73,6 +73,7 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi AudioInterfaceInfo->State.InterfaceEnabled = ((USB_ControlRequest.wValue & 0xFF) != 0); EVENT_Audio_Device_StreamStartStop(AudioInterfaceInfo); + return 1; } break; @@ -82,6 +83,7 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi { Endpoint_ClearSETUP(); Endpoint_ClearStatusStage(); + return 1; } break; @@ -107,6 +109,7 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi CALLBACK_Audio_Device_GetSetEndpointProperty(AudioInterfaceInfo, EndpointProperty, EndpointAddress, EndpointControl, &ValueLength, Value); + return 1; } } else if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_INTERFACE) @@ -127,6 +130,7 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi CALLBACK_Audio_Device_GetSetInterfaceProperty(AudioInterfaceInfo, Property, Entity, Parameter, &ValueLength, Value); + return 1; } } @@ -149,6 +153,7 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi Endpoint_ClearSETUP(); Endpoint_Write_Control_Stream_LE(Value, ValueLength); Endpoint_ClearOUT(); + return 1; } } else if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_INTERFACE) @@ -165,11 +170,13 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi Endpoint_ClearSETUP(); Endpoint_Write_Control_Stream_LE(Value, ValueLength); Endpoint_ClearOUT(); + return 1; } } break; } + return 0; } bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) diff --git a/LUFA/Drivers/USB/Class/Device/AudioClassDevice.h b/LUFA/Drivers/USB/Class/Device/AudioClassDevice.h index 61d9b4c2b..16df5d9ab 100644 --- a/LUFA/Drivers/USB/Class/Device/AudioClassDevice.h +++ b/LUFA/Drivers/USB/Class/Device/AudioClassDevice.h @@ -117,7 +117,7 @@ * * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. */ - void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + int Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Audio class driver callback for the setting and retrieval of streaming endpoint properties. This callback must be implemented * in the user application to handle property manipulations on streaming audio endpoints. diff --git a/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c b/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c index c366c2f5e..87e465410 100644 --- a/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c @@ -37,13 +37,13 @@ #define __INCLUDE_FROM_CDC_DEVICE_C #include "CDCClassDevice.h" -void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +int CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) { if (!(Endpoint_IsSETUPReceived())) - return; + return 0; if (USB_ControlRequest.wIndex != CDCInterfaceInfo->Config.ControlInterfaceNumber) - return; + return 0; switch (USB_ControlRequest.bRequest) { @@ -61,6 +61,7 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInter Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; } break; @@ -72,7 +73,7 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInter while (!(Endpoint_IsOUTReceived())) { if (USB_DeviceState == DEVICE_STATE_Unattached) - return; + return 0; /* Or should this be considered "handled"? */ } CDCInterfaceInfo->State.LineEncoding.BaudRateBPS = Endpoint_Read_32_LE(); @@ -84,6 +85,7 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInter Endpoint_ClearStatusStage(); EVENT_CDC_Device_LineEncodingChanged(CDCInterfaceInfo); + return 1; } break; @@ -96,6 +98,7 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInter CDCInterfaceInfo->State.ControlLineStates.HostToDevice = USB_ControlRequest.wValue; EVENT_CDC_Device_ControLineStateChanged(CDCInterfaceInfo); + return 1; } break; @@ -106,10 +109,12 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInter Endpoint_ClearStatusStage(); EVENT_CDC_Device_BreakSent(CDCInterfaceInfo, (uint8_t)USB_ControlRequest.wValue); + return 1; } break; } + return 0; } bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) diff --git a/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h b/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h index 1c88fb841..a8d6926de 100644 --- a/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h +++ b/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h @@ -145,7 +145,7 @@ * * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. */ - void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + int CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** General management task for a given CDC class interface, required for the correct operation of the interface. This should * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). diff --git a/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c b/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c index e95575876..78ab86cee 100644 --- a/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c @@ -37,13 +37,13 @@ #define __INCLUDE_FROM_HID_DEVICE_C #include "HIDClassDevice.h" -void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) +int HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) { if (!(Endpoint_IsSETUPReceived())) - return; + return 0; if (USB_ControlRequest.wIndex != HIDInterfaceInfo->Config.InterfaceNumber) - return; + return 0; switch (USB_ControlRequest.bRequest) { @@ -74,6 +74,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter Endpoint_Write_Control_Stream_LE(ReportData, ReportSize); Endpoint_ClearOUT(); + return 1; } break; @@ -91,6 +92,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter CALLBACK_HID_Device_ProcessHIDReport(HIDInterfaceInfo, ReportID, ReportType, &ReportData[ReportID ? 1 : 0], ReportSize - (ReportID ? 1 : 0)); + return 1; } break; @@ -102,6 +104,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter Endpoint_Write_8(HIDInterfaceInfo->State.UsingReportProtocol); Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; } break; @@ -112,6 +115,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter Endpoint_ClearStatusStage(); HIDInterfaceInfo->State.UsingReportProtocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00); + return 1; } break; @@ -122,6 +126,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter Endpoint_ClearStatusStage(); HIDInterfaceInfo->State.IdleCount = ((USB_ControlRequest.wValue & 0xFF00) >> 6); + return 1; } break; @@ -133,10 +138,12 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter Endpoint_Write_8(HIDInterfaceInfo->State.IdleCount >> 2); Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; } break; } + return 0; } bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) diff --git a/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h b/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h index 4a9b4aecd..d9256c5d9 100644 --- a/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h +++ b/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h @@ -136,7 +136,7 @@ * * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. */ - void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + int HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** General management task for a given HID class interface, required for the correct operation of the interface. This should * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). diff --git a/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.h b/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.h index e4b90a747..985307b48 100644 --- a/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.h +++ b/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.h @@ -158,10 +158,11 @@ * * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. */ - static inline void MIDI_Device_ProcessControlRequest(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); - static inline void MIDI_Device_ProcessControlRequest(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) + static inline int MIDI_Device_ProcessControlRequest(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + static inline int MIDI_Device_ProcessControlRequest(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) { (void)MIDIInterfaceInfo; + return 0; } /* Disable C linkage for C++ Compilers: */ diff --git a/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.c b/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.c index 50fe1b9a5..5216a95b7 100644 --- a/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.c @@ -37,13 +37,13 @@ #define __INCLUDE_FROM_MASSSTORAGE_DEVICE_C #include "MassStorageClassDevice.h" -void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) +int MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) { if (!(Endpoint_IsSETUPReceived())) - return; + return 0; if (USB_ControlRequest.wIndex != MSInterfaceInfo->Config.InterfaceNumber) - return; + return 0; switch (USB_ControlRequest.bRequest) { @@ -54,6 +54,7 @@ void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfac Endpoint_ClearStatusStage(); MSInterfaceInfo->State.IsMassStoreReset = true; + return 1; } break; @@ -65,10 +66,12 @@ void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfac Endpoint_Write_8(MSInterfaceInfo->Config.TotalLUNs - 1); Endpoint_ClearIN(); Endpoint_ClearStatusStage(); + return 1; } break; } + return 0; } bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) diff --git a/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.h b/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.h index d3360e62c..ac55c7f9e 100644 --- a/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.h +++ b/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.h @@ -120,7 +120,7 @@ * * \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state. */ - void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + int MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** General management task for a given Mass Storage class interface, required for the correct operation of the interface. This should * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). diff --git a/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.c b/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.c index bd4f8e9ff..03da9239e 100644 --- a/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.c @@ -37,13 +37,13 @@ #define __INCLUDE_FROM_PRINTER_DEVICE_C #include "PrinterClassDevice.h" -void PRNT_Device_ProcessControlRequest(USB_ClassInfo_PRNT_Device_t* const PRNTInterfaceInfo) +int PRNT_Device_ProcessControlRequest(USB_ClassInfo_PRNT_Device_t* const PRNTInterfaceInfo) { if (!(Endpoint_IsSETUPReceived())) - return; + return 0; if (USB_ControlRequest.wIndex != PRNTInterfaceInfo->Config.InterfaceNumber) - return; + return 0; switch (USB_ControlRequest.bRequest) { @@ -55,13 +55,14 @@ void PRNT_Device_ProcessControlRequest(USB_ClassInfo_PRNT_Device_t* const PRNTIn while (!(Endpoint_IsINReady())) { if (USB_DeviceState == DEVICE_STATE_Unattached) - return; + return 0; } uint16_t IEEEStringLen = strlen(PRNTInterfaceInfo->Config.IEEE1284String); Endpoint_Write_16_BE(IEEEStringLen); Endpoint_Write_Control_Stream_LE(PRNTInterfaceInfo->Config.IEEE1284String, IEEEStringLen); Endpoint_ClearStatusStage(); + return 1; } break; @@ -73,11 +74,12 @@ void PRNT_Device_ProcessControlRequest(USB_ClassInfo_PRNT_Device_t* const PRNTIn while (!(Endpoint_IsINReady())) { if (USB_DeviceState == DEVICE_STATE_Unattached) - return; + return 0; } Endpoint_Write_8(PRNTInterfaceInfo->State.PortStatus); Endpoint_ClearStatusStage(); + return 1; } break; @@ -90,10 +92,12 @@ void PRNT_Device_ProcessControlRequest(USB_ClassInfo_PRNT_Device_t* const PRNTIn PRNTInterfaceInfo->State.IsPrinterReset = true; EVENT_PRNT_Device_SoftReset(PRNTInterfaceInfo); + return 1; } break; } + return 0; } bool PRNT_Device_ConfigureEndpoints(USB_ClassInfo_PRNT_Device_t* const PRNTInterfaceInfo) diff --git a/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.h b/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.h index c86aec8e5..61c6883e2 100644 --- a/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.h +++ b/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.h @@ -122,7 +122,7 @@ * * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class configuration and state. */ - void PRNT_Device_ProcessControlRequest(USB_ClassInfo_PRNT_Device_t* const PRNTInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + int PRNT_Device_ProcessControlRequest(USB_ClassInfo_PRNT_Device_t* const PRNTInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** General management task for a given Printer class interface, required for the correct operation of the interface. This should * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). diff --git a/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c b/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c index 0fb0982ca..a0656953b 100644 --- a/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c @@ -68,13 +68,13 @@ static const uint32_t PROGMEM AdapterSupportedOIDList[] = CPU_TO_LE32(OID_802_3_XMIT_MORE_COLLISIONS), }; -void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) +int RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) { if (!(Endpoint_IsSETUPReceived())) - return; + return 0; if (USB_ControlRequest.wIndex != RNDISInterfaceInfo->Config.ControlInterfaceNumber) - return; + return 0; switch (USB_ControlRequest.bRequest) { @@ -86,6 +86,7 @@ void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDI Endpoint_ClearIN(); RNDIS_Device_ProcessRNDISControlMessage(RNDISInterfaceInfo); + return 1; } break; @@ -105,10 +106,12 @@ void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDI Endpoint_ClearOUT(); MessageHeader->MessageLength = CPU_TO_LE32(0); + return 1; } break; } + return 0; } bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) diff --git a/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h b/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h index dbf51f435..b4a4320fe 100644 --- a/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h +++ b/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h @@ -120,7 +120,7 @@ * * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state. */ - void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + int RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** General management task for a given RNDIS class interface, required for the correct operation of the interface. This should * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). diff --git a/LUFA/Drivers/USB/Core/DeviceStandardReq.c b/LUFA/Drivers/USB/Core/DeviceStandardReq.c index a730711e6..426d74055 100644 --- a/LUFA/Drivers/USB/Core/DeviceStandardReq.c +++ b/LUFA/Drivers/USB/Core/DeviceStandardReq.c @@ -48,6 +48,8 @@ bool USB_Device_RemoteWakeupEnabled; void USB_Device_ProcessControlRequest(void) { + int request_handled; + #if defined(ARCH_BIG_ENDIAN) USB_ControlRequest.bmRequestType = Endpoint_Read_8(); USB_ControlRequest.bRequest = Endpoint_Read_8(); @@ -61,9 +63,14 @@ void USB_Device_ProcessControlRequest(void) *(RequestHeader++) = Endpoint_Read_8(); #endif - EVENT_USB_Device_ControlRequest(); - - if (Endpoint_IsSETUPReceived()) + if (!Endpoint_IsSETUPReceived()) + { + return; + } + + request_handled = EVENT_USB_Device_ControlRequest(); + + if (!request_handled) { uint8_t bmRequestType = USB_ControlRequest.bmRequestType; @@ -74,6 +81,7 @@ void USB_Device_ProcessControlRequest(void) (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT))) { USB_Device_GetStatus(); + request_handled = 1; } break; @@ -83,12 +91,14 @@ void USB_Device_ProcessControlRequest(void) (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT))) { USB_Device_ClearSetFeature(); + request_handled = 1; } break; case REQ_SetAddress: if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) USB_Device_SetAddress(); + request_handled = 1; break; case REQ_GetDescriptor: @@ -96,27 +106,30 @@ void USB_Device_ProcessControlRequest(void) (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE))) { USB_Device_GetDescriptor(); + request_handled = 1; } break; case REQ_GetConfiguration: if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) USB_Device_GetConfiguration(); + request_handled = 1; break; case REQ_SetConfiguration: if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) USB_Device_SetConfiguration(); + request_handled = 1; break; default: break; } + } - - if (Endpoint_IsSETUPReceived()) - { + + if (!request_handled) Endpoint_ClearSETUP(); Endpoint_StallTransaction(); } diff --git a/Projects/Benito/Benito.c b/Projects/Benito/Benito.c index 4329ef634..8dd6c70f5 100644 --- a/Projects/Benito/Benito.c +++ b/Projects/Benito/Benito.c @@ -224,9 +224,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) * the device from the USB host before passing along unhandled control requests to the library for processing * internally. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); + return CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); } /** Event handler for the CDC Class driver Line Encoding Changed event. diff --git a/Projects/Benito/Benito.h b/Projects/Benito/Benito.h index 2c14fb550..18960c2b8 100644 --- a/Projects/Benito/Benito.h +++ b/Projects/Benito/Benito.h @@ -70,7 +70,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo); void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo); diff --git a/Projects/LEDNotifier/LEDNotifier.c b/Projects/LEDNotifier/LEDNotifier.c index 8e70e90d4..5fb5204c9 100644 --- a/Projects/LEDNotifier/LEDNotifier.c +++ b/Projects/LEDNotifier/LEDNotifier.c @@ -171,8 +171,8 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); + return CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); } diff --git a/Projects/LEDNotifier/LEDNotifier.h b/Projects/LEDNotifier/LEDNotifier.h index 274a0f06c..71e5927c7 100644 --- a/Projects/LEDNotifier/LEDNotifier.h +++ b/Projects/LEDNotifier/LEDNotifier.h @@ -54,7 +54,7 @@ void SetupHardware(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #endif diff --git a/Projects/MIDIToneGenerator/MIDIToneGenerator.c b/Projects/MIDIToneGenerator/MIDIToneGenerator.c index 98cd596fc..244a1ec15 100644 --- a/Projects/MIDIToneGenerator/MIDIToneGenerator.c +++ b/Projects/MIDIToneGenerator/MIDIToneGenerator.c @@ -245,8 +245,8 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - MIDI_Device_ProcessControlRequest(&Keyboard_MIDI_Interface); + return MIDI_Device_ProcessControlRequest(&Keyboard_MIDI_Interface); } diff --git a/Projects/Magstripe/Magstripe.c b/Projects/Magstripe/Magstripe.c index 8eecf9b01..fbd027767 100644 --- a/Projects/Magstripe/Magstripe.c +++ b/Projects/Magstripe/Magstripe.c @@ -154,9 +154,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - HID_Device_ProcessControlRequest(&Keyboard_HID_Interface); + return HID_Device_ProcessControlRequest(&Keyboard_HID_Interface); } /** Event handler for the USB device Start Of Frame event. */ diff --git a/Projects/Magstripe/Magstripe.h b/Projects/Magstripe/Magstripe.h index dc5edf5ad..a480b59b6 100644 --- a/Projects/Magstripe/Magstripe.h +++ b/Projects/Magstripe/Magstripe.h @@ -72,7 +72,7 @@ void ReadMagstripeData(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_USB_Device_StartOfFrame(void); bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, diff --git a/Projects/MediaController/MediaController.c b/Projects/MediaController/MediaController.c index 55384b472..bad240ce1 100644 --- a/Projects/MediaController/MediaController.c +++ b/Projects/MediaController/MediaController.c @@ -121,9 +121,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - HID_Device_ProcessControlRequest(&MediaControl_HID_Interface); + return HID_Device_ProcessControlRequest(&MediaControl_HID_Interface); } /** Event handler for the USB device Start Of Frame event. */ diff --git a/Projects/MediaController/MediaController.h b/Projects/MediaController/MediaController.h index 9ee349ed9..e61a543cb 100644 --- a/Projects/MediaController/MediaController.h +++ b/Projects/MediaController/MediaController.h @@ -92,7 +92,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_USB_Device_StartOfFrame(void); bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, diff --git a/Projects/RelayBoard/RelayBoard.c b/Projects/RelayBoard/RelayBoard.c index 12732c664..27862c3b1 100644 --- a/Projects/RelayBoard/RelayBoard.c +++ b/Projects/RelayBoard/RelayBoard.c @@ -72,7 +72,7 @@ void SetupHardware(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { const uint8_t SerialNumber[5] = { 0, 0, 0, 0, 1 }; uint8_t ControlData[2] = { 0, 0 }; @@ -104,6 +104,7 @@ void EVENT_USB_Device_ControlRequest(void) if (ControlData[1]) PORTC &= ~RELAY4; else PORTC |= RELAY4; break; } + return 1; } break; @@ -137,9 +138,11 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_Write_Control_Stream_LE(ControlData, sizeof(ControlData)); Endpoint_ClearOUT(); + return 1; } break; } + return 0; } diff --git a/Projects/RelayBoard/RelayBoard.h b/Projects/RelayBoard/RelayBoard.h index d317410df..0c5113aa3 100644 --- a/Projects/RelayBoard/RelayBoard.h +++ b/Projects/RelayBoard/RelayBoard.h @@ -59,7 +59,7 @@ /* Function Prototypes: */ void SetupHardware(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #endif diff --git a/Projects/SerialToLCD/SerialToLCD.c b/Projects/SerialToLCD/SerialToLCD.c index 007f3adb1..4a9862a34 100644 --- a/Projects/SerialToLCD/SerialToLCD.c +++ b/Projects/SerialToLCD/SerialToLCD.c @@ -164,7 +164,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); + return CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); } diff --git a/Projects/SerialToLCD/SerialToLCD.h b/Projects/SerialToLCD/SerialToLCD.h index 4ea8b88ee..aa4f86d49 100644 --- a/Projects/SerialToLCD/SerialToLCD.h +++ b/Projects/SerialToLCD/SerialToLCD.h @@ -58,7 +58,7 @@ void SetupHardware(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); #endif diff --git a/Projects/TempDataLogger/TempDataLogger.c b/Projects/TempDataLogger/TempDataLogger.c index eb1a2fc2d..cf08ea3f7 100644 --- a/Projects/TempDataLogger/TempDataLogger.c +++ b/Projects/TempDataLogger/TempDataLogger.c @@ -256,10 +256,16 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - MS_Device_ProcessControlRequest(&Disk_MS_Interface); - HID_Device_ProcessControlRequest(&Generic_HID_Interface); + int request_handled; + + request_handled = MS_Device_ProcessControlRequest(&Disk_MS_Interface); + if (!request_handled) { + request_handled = HID_Device_ProcessControlRequest(&Generic_HID_Interface); + } + + return request_handled; } /** Mass Storage class driver callback function the reception of SCSI commands from the host, which must be processed. diff --git a/Projects/TempDataLogger/TempDataLogger.h b/Projects/TempDataLogger/TempDataLogger.h index 2bfbc413f..56b6c246c 100644 --- a/Projects/TempDataLogger/TempDataLogger.h +++ b/Projects/TempDataLogger/TempDataLogger.h @@ -94,7 +94,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo); bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, diff --git a/Projects/USBtoSerial/USBtoSerial.c b/Projects/USBtoSerial/USBtoSerial.c index 266592b14..bf52355a7 100644 --- a/Projects/USBtoSerial/USBtoSerial.c +++ b/Projects/USBtoSerial/USBtoSerial.c @@ -182,9 +182,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); + return CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); } /** ISR to manage the reception of data from the serial port, placing received bytes into a circular buffer diff --git a/Projects/USBtoSerial/USBtoSerial.h b/Projects/USBtoSerial/USBtoSerial.h index 068822a56..85b41b5b4 100644 --- a/Projects/USBtoSerial/USBtoSerial.h +++ b/Projects/USBtoSerial/USBtoSerial.h @@ -69,7 +69,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo); diff --git a/Projects/Webserver/USBDeviceMode.c b/Projects/Webserver/USBDeviceMode.c index 7e1841d4d..eb058f5bd 100644 --- a/Projects/Webserver/USBDeviceMode.c +++ b/Projects/Webserver/USBDeviceMode.c @@ -139,10 +139,16 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { - RNDIS_Device_ProcessControlRequest(&Ethernet_RNDIS_Interface_Device); - MS_Device_ProcessControlRequest(&Disk_MS_Interface); + int request_handled; + + request_handled = RNDIS_Device_ProcessControlRequest(&Ethernet_RNDIS_Interface_Device); + if (!request_handled) { + request_handled = MS_Device_ProcessControlRequest(&Disk_MS_Interface); + } + + return request_handled; } /** Mass Storage class driver callback function the reception of SCSI commands from the host, which must be processed. diff --git a/Projects/Webserver/USBDeviceMode.h b/Projects/Webserver/USBDeviceMode.h index 9676dc55a..0ef59c6ce 100644 --- a/Projects/Webserver/USBDeviceMode.h +++ b/Projects/Webserver/USBDeviceMode.h @@ -54,7 +54,7 @@ void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo); diff --git a/Projects/XPLAINBridge/XPLAINBridge.c b/Projects/XPLAINBridge/XPLAINBridge.c index 9475b1fd9..e0cf7b9a8 100644 --- a/Projects/XPLAINBridge/XPLAINBridge.c +++ b/Projects/XPLAINBridge/XPLAINBridge.c @@ -239,10 +239,12 @@ void EVENT_USB_Device_ConfigurationChanged(void) } /** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) +int EVENT_USB_Device_ControlRequest(void) { if (CurrentFirmwareMode == MODE_USART_BRIDGE) - CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); + return CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); + + return 0; } /** Event handler for the library USB Connection event. */ diff --git a/Projects/XPLAINBridge/XPLAINBridge.h b/Projects/XPLAINBridge/XPLAINBridge.h index baed8b90f..5c7a24cf4 100644 --- a/Projects/XPLAINBridge/XPLAINBridge.h +++ b/Projects/XPLAINBridge/XPLAINBridge.h @@ -88,7 +88,7 @@ void UARTBridge_Task(void); void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); + int EVENT_USB_Device_ControlRequest(void); void EVENT_USB_Device_Connect(void); void EVENT_USB_Device_Disconnect(void);