From 5e14c194c9a2f5cb52a43f7efeacb795a38ced74 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Wed, 14 Apr 2010 13:46:49 +0000 Subject: [PATCH] Fixed Set/Clear Feature requests directed to a non-configured endpoint not returning a stall to the host. Make TeensyHID bootloader use an 8 byte control endpoint to match the official Teensy, just in case Paul decides to authenticate on that attribute in the future. --- Bootloaders/TeensyHID/makefile | 2 +- LUFA/Drivers/USB/LowLevel/DevChapter9.c | 28 +++++++++---------- .../Template/Template_Endpoint_Control_W.c | 2 +- LUFA/ManPages/ChangeLog.txt | 1 + Projects/LEDNotifier/makefile | 2 +- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Bootloaders/TeensyHID/makefile b/Bootloaders/TeensyHID/makefile index 0895222a41..10b0ebb068 100644 --- a/Bootloaders/TeensyHID/makefile +++ b/Bootloaders/TeensyHID/makefile @@ -110,7 +110,7 @@ LUFA_PATH = ../.. # LUFA library compile-time options LUFA_OPTS = -D USB_DEVICE_ONLY LUFA_OPTS += -D DEVICE_STATE_AS_GPIOR=0 -LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=64 +LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8 LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1 LUFA_OPTS += -D USE_RAM_DESCRIPTORS LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c index 7d9e81502c..17a5fd4714 100644 --- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c +++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c @@ -323,7 +323,7 @@ static void USB_Device_GetStatus(void) #endif #if !defined(CONTROL_ONLY_DEVICE) case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT): - Endpoint_SelectEndpoint(USB_ControlRequest.wIndex & 0xFF); + Endpoint_SelectEndpoint((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK); CurrentStatus = Endpoint_IsStalled(); @@ -344,7 +344,7 @@ static void USB_Device_GetStatus(void) } static void USB_Device_ClearSetFeature(void) -{ +{ switch (USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) { #if !defined(NO_DEVICE_REMOTE_WAKEUP) @@ -367,18 +367,18 @@ static void USB_Device_ClearSetFeature(void) Endpoint_SelectEndpoint(EndpointIndex); - if (Endpoint_IsEnabled()) - { - if (USB_ControlRequest.bRequest == REQ_SetFeature) - { - Endpoint_StallTransaction(); - } - else - { - Endpoint_ClearStall(); - Endpoint_ResetFIFO(EndpointIndex); - Endpoint_ResetDataToggle(); - } + if (!(Endpoint_IsEnabled())) + return; + + if (USB_ControlRequest.bRequest == REQ_SetFeature) + { + Endpoint_StallTransaction(); + } + else + { + Endpoint_ClearStall(); + Endpoint_ResetFIFO(EndpointIndex); + Endpoint_ResetDataToggle(); } } diff --git a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c index 70560cf46d..7868060fe5 100644 --- a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c +++ b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c @@ -21,7 +21,7 @@ uint8_t TEMPLATE_FUNC_NAME (const void* Buffer, uint16_t Length) if (Endpoint_IsINReady()) { - uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint(); + uint8_t BytesInEndpoint = Endpoint_BytesInEndpoint(); while (Length && (BytesInEndpoint < USB_ControlEndpointSize)) { diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index d88e6a229a..57093aeb6c 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -41,6 +41,7 @@ * - Fixed Still Image Host class driver not resetting the transaction ID when a new session is opened, fixed driver not sending * a valid session ID to the device * - Removed invalid dfu and flip related targets from the bootloaders - bootloaders can only be replaced with an external programmer + * - Fixed Set/Clear Feature requests directed to a non-configured endpoint not returning a stall to the host * * \section Sec_ChangeLog100219 Version 100219 * diff --git a/Projects/LEDNotifier/makefile b/Projects/LEDNotifier/makefile index 20cd598a68..7e49178a5a 100644 --- a/Projects/LEDNotifier/makefile +++ b/Projects/LEDNotifier/makefile @@ -60,7 +60,7 @@ # MCU name -MCU = at90usb646 +MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring