From a9e0935a90346beb0c981924becc1f55d969a08b Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Fri, 7 May 2010 06:54:08 +0000 Subject: [PATCH] Device mode class driver callbacks are now fired before the control request status stage is sent to prevent the host from timing out if another request is immediately fired and the device has a lengthy callback routine. Inlined currently unused MIDI ProcessControlRequest routine. --- LUFA/Drivers/USB/Class/Device/CDC.c | 4 +--- LUFA/Drivers/USB/Class/Device/HID.c | 3 +-- LUFA/Drivers/USB/Class/Device/MIDI.c | 5 ----- LUFA/Drivers/USB/Class/Device/MIDI.h | 20 ++++++++++++-------- LUFA/Drivers/USB/Class/Device/RNDIS.c | 3 +-- LUFA/ManPages/ChangeLog.txt | 2 ++ 6 files changed, 17 insertions(+), 20 deletions(-) diff --git a/LUFA/Drivers/USB/Class/Device/CDC.c b/LUFA/Drivers/USB/Class/Device/CDC.c index e1cb554f95..f0c6edb12b 100644 --- a/LUFA/Drivers/USB/Class/Device/CDC.c +++ b/LUFA/Drivers/USB/Class/Device/CDC.c @@ -65,9 +65,8 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* CDCInterfaceIn { Endpoint_ClearSETUP(); Endpoint_Read_Control_Stream_LE(&CDCInterfaceInfo->State.LineEncoding, sizeof(CDCInterfaceInfo->State.LineEncoding)); - Endpoint_ClearIN(); - EVENT_CDC_Device_LineEncodingChanged(CDCInterfaceInfo); + Endpoint_ClearIN(); } break; @@ -77,7 +76,6 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* CDCInterfaceIn Endpoint_ClearSETUP(); CDCInterfaceInfo->State.ControlLineStates.HostToDevice = USB_ControlRequest.wValue; - EVENT_CDC_Device_ControLineStateChanged(CDCInterfaceInfo); Endpoint_ClearStatusStage(); diff --git a/LUFA/Drivers/USB/Class/Device/HID.c b/LUFA/Drivers/USB/Class/Device/HID.c index 7ff32498bc..6766509765 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.c +++ b/LUFA/Drivers/USB/Class/Device/HID.c @@ -79,9 +79,8 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF); Endpoint_Read_Control_Stream_LE(ReportOUTData, ReportOUTSize); - Endpoint_ClearIN(); - CALLBACK_HID_Device_ProcessHIDReport(HIDInterfaceInfo, ReportID, ReportOUTData, ReportOUTSize); + Endpoint_ClearIN(); } break; diff --git a/LUFA/Drivers/USB/Class/Device/MIDI.c b/LUFA/Drivers/USB/Class/Device/MIDI.c index d3f8f55b60..1a66dc867d 100644 --- a/LUFA/Drivers/USB/Class/Device/MIDI.c +++ b/LUFA/Drivers/USB/Class/Device/MIDI.c @@ -35,11 +35,6 @@ #define __INCLUDE_FROM_MIDI_DRIVER #include "MIDI.h" -void MIDI_Device_ProcessControlRequest(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) -{ - -} - bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) { memset(&MIDIInterfaceInfo->State, 0x00, sizeof(MIDIInterfaceInfo->State)); diff --git a/LUFA/Drivers/USB/Class/Device/MIDI.h b/LUFA/Drivers/USB/Class/Device/MIDI.h index 11a05bfbb3..00d34e0009 100644 --- a/LUFA/Drivers/USB/Class/Device/MIDI.h +++ b/LUFA/Drivers/USB/Class/Device/MIDI.h @@ -112,13 +112,6 @@ */ bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); - /** Processes incoming control requests from the host, that are directed to the given MIDI class interface. This should be - * linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event. - * - * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state - */ - void MIDI_Device_ProcessControlRequest(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); - /** Sends a MIDI event packet to the host. If no host is connected, the event packet is discarded. Events are queued into the * endpoint bank until either the endpoint bank is full, or \ref MIDI_Device_Flush() is called. This allows for multiple * MIDI events to be packed into a single endpoint packet, increasing data throughput. @@ -168,7 +161,18 @@ static inline void MIDI_Device_USBTask(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) { (void)MIDIInterfaceInfo; - } + } + + /** Processes incoming control requests from the host, that are directed to the given MIDI class interface. This should be + * linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event. + * + * \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) + { + (void)MIDIInterfaceInfo; + } /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) diff --git a/LUFA/Drivers/USB/Class/Device/RNDIS.c b/LUFA/Drivers/USB/Class/Device/RNDIS.c index 1961e7e84a..69e8e677d3 100644 --- a/LUFA/Drivers/USB/Class/Device/RNDIS.c +++ b/LUFA/Drivers/USB/Class/Device/RNDIS.c @@ -83,9 +83,8 @@ void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDI Endpoint_ClearSETUP(); Endpoint_Read_Control_Stream_LE(RNDISInterfaceInfo->State.RNDISMessageBuffer, USB_ControlRequest.wLength); - Endpoint_ClearIN(); - RNDIS_Device_ProcessRNDISControlMessage(RNDISInterfaceInfo); + Endpoint_ClearIN(); } break; diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index 8e68183043..4de0473a2e 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -39,6 +39,8 @@ * now be implemented via seperate programming headers * - The CDC class bootloader now uses a watchdog reset rather than a soft-reset when exited to ensure that all hardware is * properly reset to their defaults + * - Device mode class driver callbacks are now fired before the control request status stage is sent to prevent the host from + * timing out if another request is immediately fired and the device has a lengthy callback routine * * Fixed: * - Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin