aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-05-04 10:07:22 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-05-04 10:07:22 +0000
commit27f0ba6fc30db478fbab0b952bf2c3137f5a7719 (patch)
treee179a64b7558db825b28b173091f07d9c99f63c5 /LUFA
parenteed7d4df6ae3da8616ec294d303ceea26078c707 (diff)
downloadlufa-27f0ba6fc30db478fbab0b952bf2c3137f5a7719.tar.gz
lufa-27f0ba6fc30db478fbab0b952bf2c3137f5a7719.tar.bz2
lufa-27f0ba6fc30db478fbab0b952bf2c3137f5a7719.zip
Fixed device state not being reset back to the default state if the host sets the address to 0x00.
Fixed Set Configuration requests not being stalled until the host has set the device's address. Fixed possibility of internal signature retrieval being corrupted if an interrupt occurs during a signature byte read (thanks to Andrei Krainev).
Diffstat (limited to 'LUFA')
-rw-r--r--LUFA/Drivers/USB/LowLevel/DevChapter9.c46
-rw-r--r--LUFA/Drivers/USB/LowLevel/DevChapter9.h1
-rw-r--r--LUFA/ManPages/ChangeLog.txt6
3 files changed, 30 insertions, 23 deletions
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c
index 17a5fd471..b7f811b5e 100644
--- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c
+++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c
@@ -136,8 +136,7 @@ static void USB_Device_SetAddress(void)
return;
}
- if (DeviceAddress)
- USB_DeviceState = DEVICE_STATE_Addressed;
+ USB_DeviceState = (DeviceAddress) ? DEVICE_STATE_Addressed : DEVICE_STATE_Default;
UDADDR = ((1 << ADDEN) | DeviceAddress);
@@ -146,12 +145,21 @@ static void USB_Device_SetAddress(void)
static void USB_Device_SetConfiguration(void)
{
+ if (USB_DeviceState != DEVICE_STATE_Addressed)
+ return;
+
#if defined(FIXED_NUM_CONFIGURATIONS)
if ((uint8_t)USB_ControlRequest.wValue > FIXED_NUM_CONFIGURATIONS)
return;
#else
- #if !defined(USE_FLASH_DESCRIPTORS) && !defined(USE_EEPROM_DESCRIPTORS) && !defined(USE_RAM_DESCRIPTORS)
- uint8_t MemoryAddressSpace;
+ #if defined(USE_FLASH_DESCRIPTORS)
+ #define MemoryAddressSpace MEMSPACE_FLASH
+ #elif defined(USE_EEPROM_DESCRIPTORS)
+ #define MemoryAddressSpace MEMSPACE_EEPROM
+ #elif defined(USE_SRAM_DESCRIPTORS)
+ #define MemoryAddressSpace MEMSPACE_SRAM
+ #else
+ uint8_t MemoryAddressSpace;
#endif
USB_Descriptor_Device_t* DevDescriptorPtr;
@@ -165,16 +173,6 @@ static void USB_Device_SetConfiguration(void)
return;
}
- #if defined(USE_RAM_DESCRIPTORS)
- if ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations)
- return;
- #elif defined (USE_EEPROM_DESCRIPTORS)
- if ((uint8_t)USB_ControlRequest.wValue > eeprom_read_byte(&DevDescriptorPtr->NumberOfConfigurations))
- return;
- #elif defined (USE_FLASH_DESCRIPTORS)
- if ((uint8_t)USB_ControlRequest.wValue > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations))
- return;
- #else
if (MemoryAddressSpace == MEMSPACE_FLASH)
{
if (((uint8_t)USB_ControlRequest.wValue > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))
@@ -190,7 +188,6 @@ static void USB_Device_SetConfiguration(void)
if ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations)
return;
}
- #endif
#endif
Endpoint_ClearSETUP();
@@ -234,17 +231,20 @@ static void USB_Device_GetInternalSerialDescriptor(void)
uint8_t SigReadAddress = 0x0E;
- for (uint8_t SerialCharNum = 0; SerialCharNum < 20; SerialCharNum++)
+ ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
- uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
-
- if (SerialCharNum & 0x01)
+ for (uint8_t SerialCharNum = 0; SerialCharNum < 20; SerialCharNum++)
{
- SerialByte >>= 4;
- SigReadAddress++;
+ uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
+
+ if (SerialCharNum & 0x01)
+ {
+ SerialByte >>= 4;
+ SigReadAddress++;
+ }
+
+ SignatureDescriptor.UnicodeString[SerialCharNum] = USB_Device_NibbleToASCII(SerialByte);
}
-
- SignatureDescriptor.UnicodeString[SerialCharNum] = USB_Device_NibbleToASCII(SerialByte);
}
Endpoint_ClearSETUP();
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.h b/LUFA/Drivers/USB/LowLevel/DevChapter9.h
index d59132739..868c3fab2 100644
--- a/LUFA/Drivers/USB/LowLevel/DevChapter9.h
+++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.h
@@ -46,6 +46,7 @@
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include <avr/boot.h>
+ #include <util/atomic.h>
#include "../HighLevel/StdDescriptors.h"
#include "../HighLevel/Events.h"
diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt
index 8d5a7ab6a..c38f9e73e 100644
--- a/LUFA/ManPages/ChangeLog.txt
+++ b/LUFA/ManPages/ChangeLog.txt
@@ -52,6 +52,12 @@
* - Fixed Set/Clear Feature requests directed to a non-configured endpoint not returning a stall to the host
* - Fixed HID Device Class Driver not allocating a temporary buffer when the host requests a report via the control endpoint and the
* user has set the PrevReportINBuffer driver configuration element to NULL (thanks to Lars Noschinski)
+ * - Fixed device state not being reset to DEVICE_STATE_Default if the host sets a 0x00 device address
+ * - Fixed device not stalling configuration requests before the device's address has been set
+ * - Fixed possibility of internal signature retrieval being corrupted if an interrupt occurs during a signature byte
+ * read (thanks to Andrei Krainev)
+ * - Fixed device state not being reset back to the default state if the host sets the address to 0
+ * - Fixed Set Configuration requests not being stalled until the host has set the device's address
*
* \section Sec_ChangeLog100219 Version 100219
*