@ -136,8 +136,7 @@ static void USB_Device_SetAddress(void)
return ;
return ;
}
}
if ( DeviceAddress )
USB_DeviceState = ( DeviceAddress ) ? DEVICE_STATE_Addressed : DEVICE_STATE_Default ;
USB_DeviceState = DEVICE_STATE_Addressed ;
UDADDR = ( ( 1 < < ADDEN ) | DeviceAddress ) ;
UDADDR = ( ( 1 < < ADDEN ) | DeviceAddress ) ;
@ -146,11 +145,20 @@ static void USB_Device_SetAddress(void)
static void USB_Device_SetConfiguration ( void )
static void USB_Device_SetConfiguration ( void )
{
{
if ( USB_DeviceState ! = DEVICE_STATE_Addressed )
return ;
# if defined(FIXED_NUM_CONFIGURATIONS)
# if defined(FIXED_NUM_CONFIGURATIONS)
if ( ( uint8_t ) USB_ControlRequest . wValue > FIXED_NUM_CONFIGURATIONS )
if ( ( uint8_t ) USB_ControlRequest . wValue > FIXED_NUM_CONFIGURATIONS )
return ;
return ;
# else
# else
# if !defined(USE_FLASH_DESCRIPTORS) && !defined(USE_EEPROM_DESCRIPTORS) && !defined(USE_RAM_DESCRIPTORS)
# 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 ;
uint8_t MemoryAddressSpace ;
# endif
# endif
@ -165,16 +173,6 @@ static void USB_Device_SetConfiguration(void)
return ;
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 ( MemoryAddressSpace = = MEMSPACE_FLASH )
{
{
if ( ( ( uint8_t ) USB_ControlRequest . wValue > pgm_read_byte ( & DevDescriptorPtr - > NumberOfConfigurations ) ) )
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 )
if ( ( uint8_t ) USB_ControlRequest . wValue > DevDescriptorPtr - > NumberOfConfigurations )
return ;
return ;
}
}
# endif
# endif
# endif
Endpoint_ClearSETUP ( ) ;
Endpoint_ClearSETUP ( ) ;
@ -234,6 +231,8 @@ static void USB_Device_GetInternalSerialDescriptor(void)
uint8_t SigReadAddress = 0x0E ;
uint8_t SigReadAddress = 0x0E ;
ATOMIC_BLOCK ( ATOMIC_RESTORESTATE )
{
for ( uint8_t SerialCharNum = 0 ; SerialCharNum < 20 ; SerialCharNum + + )
for ( uint8_t SerialCharNum = 0 ; SerialCharNum < 20 ; SerialCharNum + + )
{
{
uint8_t SerialByte = boot_signature_byte_get ( SigReadAddress ) ;
uint8_t SerialByte = boot_signature_byte_get ( SigReadAddress ) ;
@ -246,6 +245,7 @@ static void USB_Device_GetInternalSerialDescriptor(void)
SignatureDescriptor . UnicodeString [ SerialCharNum ] = USB_Device_NibbleToASCII ( SerialByte ) ;
SignatureDescriptor . UnicodeString [ SerialCharNum ] = USB_Device_NibbleToASCII ( SerialByte ) ;
}
}
}
Endpoint_ClearSETUP ( ) ;
Endpoint_ClearSETUP ( ) ;