Commit c20a94a4 authored by Dean Camera's avatar Dean Camera
Browse files

Fixed USB_RemoteWakeupEnabled flag never being set (the REMOTE WAKEUP Set...

Fixed USB_RemoteWakeupEnabled flag never being set (the REMOTE WAKEUP Set Feature request was not being handled).

Renamed the FEATURELESS_CONTROL_ONLY_DEVICE compile-time token to CONTROL_ONLY_DEVICE.
parent 9cec85bf
...@@ -54,7 +54,7 @@ MCU = at90usb1287 ...@@ -54,7 +54,7 @@ MCU = at90usb1287
# Target board (see library BoardTypes.h documentation, USER or blank for projects not requiring # Target board (see library BoardTypes.h documentation, USER or blank for projects not requiring
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # LUFA board drivers). If USER is selected, put custom board drivers in a directory called
# "Board" inside the application directory. # "Board" inside the application directory.
BOARD = USBKEY BOARD = USBKEY
# Processor frequency. # Processor frequency.
...@@ -175,7 +175,7 @@ BOOT_START = 0x1E000 ...@@ -175,7 +175,7 @@ BOOT_START = 0x1E000
# Place -D or -U options here for C sources # Place -D or -U options here for C sources
CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD) CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DFEATURELESS_CONTROL_ONLY_DEVICE CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DCONTROL_ONLY_DEVICE
CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=32 CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=32
CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DUSE_SINGLE_DEVICE_CONFIGURATION CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DUSE_SINGLE_DEVICE_CONFIGURATION
......
...@@ -175,7 +175,7 @@ BOOT_START = 0xC000 ...@@ -175,7 +175,7 @@ BOOT_START = 0xC000
# Place -D or -U options here for C sources # Place -D or -U options here for C sources
CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD) CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DFEATURELESS_CONTROL_ONLY_DEVICE CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DCONTROL_ONLY_DEVICE
CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8 CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DUSE_SINGLE_DEVICE_CONFIGURATION CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DUSE_SINGLE_DEVICE_CONFIGURATION
......
...@@ -193,14 +193,14 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -193,14 +193,14 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_SetControlLineState: case REQ_SetControlLineState:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSETUP();
/* NOTE: Here you can read in the line state mask from the host, to get the current state of the output handshake /* NOTE: Here you can read in the line state mask from the host, to get the current state of the output handshake
lines. The mask is read in from the wValue parameter in USB_ControlRequest, and can be masked against the 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: CONTROL_LINE_OUT_* masks to determine the RTS and DTR line states using the following code:
*/ */
/* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSETUP();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearIN(); Endpoint_ClearIN();
......
...@@ -165,10 +165,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -165,10 +165,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_GetReport: case REQ_GetReport:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
uint8_t GenericData[GENERIC_REPORT_SIZE];
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
uint8_t GenericData[GENERIC_REPORT_SIZE];
CreateGenericHIDReport(GenericData); CreateGenericHIDReport(GenericData);
/* Write the report data to the control endpoint */ /* Write the report data to the control endpoint */
...@@ -182,13 +182,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -182,13 +182,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_SetReport: case REQ_SetReport:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
uint8_t GenericData[GENERIC_REPORT_SIZE];
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
/* Wait until the generic report has been sent by the host */ /* Wait until the generic report has been sent by the host */
while (!(Endpoint_IsOUTReceived())); while (!(Endpoint_IsOUTReceived()));
uint8_t GenericData[GENERIC_REPORT_SIZE];
Endpoint_Read_Control_Stream_LE(&GenericData, sizeof(GenericData)); Endpoint_Read_Control_Stream_LE(&GenericData, sizeof(GenericData));
ProcessGenericHIDReport(GenericData); ProcessGenericHIDReport(GenericData);
......
...@@ -129,11 +129,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -129,11 +129,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
{ {
USB_JoystickReport_Data_t JoystickReportData; USB_JoystickReport_Data_t JoystickReportData;
Endpoint_ClearSETUP();
/* Create the next HID report to send to the host */ /* Create the next HID report to send to the host */
GetNextReport(&JoystickReportData); GetNextReport(&JoystickReportData);
Endpoint_ClearSETUP();
/* Write the report data to the control endpoint */ /* Write the report data to the control endpoint */
Endpoint_Write_Control_Stream_LE(&JoystickReportData, sizeof(JoystickReportData)); Endpoint_Write_Control_Stream_LE(&JoystickReportData, sizeof(JoystickReportData));
......
...@@ -200,11 +200,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -200,11 +200,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
{ {
USB_KeyboardReport_Data_t KeyboardReportData; USB_KeyboardReport_Data_t KeyboardReportData;
Endpoint_ClearSETUP();
/* Create the next keyboard report for transmission to the host */ /* Create the next keyboard report for transmission to the host */
CreateKeyboardReport(&KeyboardReportData); CreateKeyboardReport(&KeyboardReportData);
Endpoint_ClearSETUP();
/* Write the report data to the control endpoint */ /* Write the report data to the control endpoint */
Endpoint_Write_Control_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData)); Endpoint_Write_Control_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData));
......
...@@ -144,6 +144,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -144,6 +144,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_GetReport: case REQ_GetReport:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP();
/* Determine if it is the mouse or the keyboard data that is being requested */ /* Determine if it is the mouse or the keyboard data that is being requested */
if (!(USB_ControlRequest.wIndex)) if (!(USB_ControlRequest.wIndex))
{ {
...@@ -156,8 +158,6 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -156,8 +158,6 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
ReportSize = sizeof(MouseReportData); ReportSize = sizeof(MouseReportData);
} }
Endpoint_ClearSETUP();
/* Write the report data to the control endpoint */ /* Write the report data to the control endpoint */
Endpoint_Write_Control_Stream_LE(ReportData, ReportSize); Endpoint_Write_Control_Stream_LE(ReportData, ReportSize);
......
...@@ -190,10 +190,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -190,10 +190,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
{ {
USB_MouseReport_Data_t MouseReportData; USB_MouseReport_Data_t MouseReportData;
Endpoint_ClearSETUP();
/* Create the next mouse report for transmission to the host */ /* Create the next mouse report for transmission to the host */
CreateMouseReport(&MouseReportData); CreateMouseReport(&MouseReportData);
Endpoint_ClearSETUP();
/* Write the report data to the control endpoint */ /* Write the report data to the control endpoint */
Endpoint_Write_Control_Stream_LE(&MouseReportData, sizeof(MouseReportData)); Endpoint_Write_Control_Stream_LE(&MouseReportData, sizeof(MouseReportData));
......
...@@ -172,6 +172,9 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -172,6 +172,9 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_GetEncapsulatedResponse: case REQ_GetEncapsulatedResponse:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Clear the SETUP packet, ready for data transfer */
Endpoint_ClearSETUP();
/* Check if a response to the last message is ready */ /* Check if a response to the last message is ready */
if (!(MessageHeader->MessageLength)) if (!(MessageHeader->MessageLength))
{ {
...@@ -180,9 +183,6 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -180,9 +183,6 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
MessageHeader->MessageLength = 1; MessageHeader->MessageLength = 1;
} }
/* Clear the SETUP packet, ready for data transfer */
Endpoint_ClearSETUP();
/* Write the message response data to the endpoint */ /* Write the message response data to the endpoint */
Endpoint_Write_Control_Stream_LE(RNDISMessageBuffer, MessageHeader->MessageLength); Endpoint_Write_Control_Stream_LE(RNDISMessageBuffer, MessageHeader->MessageLength);
......
...@@ -188,15 +188,15 @@ EVENT_HANDLER(USB_UnhandledControlPacket) ...@@ -188,15 +188,15 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
break; break;
case REQ_SetControlLineState: case REQ_SetControlLineState:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSETUP();
/* NOTE: Here you can read in the line state mask from the host, to get the current state of the output handshake /* NOTE: Here you can read in the line state mask from the host, to get the current state of the output handshake
lines. The mask is read in from the wValue parameter in USB_ControlRequest, and can be masked against the 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: CONTROL_LINE_OUT_* masks to determine the RTS and DTR line states using the following code:
*/ */
/* Acknowledge the SETUP packet, ready for data transfer */
Endpoint_ClearSETUP();
/* Acknowledge status stage */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
Endpoint_ClearIN(); Endpoint_ClearIN();
......
...@@ -75,7 +75,7 @@ static uint8_t MassStore_SendCommand(void) ...@@ -75,7 +75,7 @@ static uint8_t MassStore_SendCommand(void)
{ {
uint8_t ErrorCode = PIPE_RWSTREAM_ERROR_NoError; uint8_t ErrorCode = PIPE_RWSTREAM_ERROR_NoError;
/* Each transmission should have a unique tag value, excluding valued 0 and 0xFFFFFFFF */ /* Each transmission should have a unique tag value, excluding values 0 and 0xFFFFFFFF */
if (++MassStore_Tag == 0xFFFFFFFF) if (++MassStore_Tag == 0xFFFFFFFF)
MassStore_Tag = 1; MassStore_Tag = 1;
......
...@@ -59,6 +59,8 @@ ...@@ -59,6 +59,8 @@
* rather than having the library pass only partially read header data to the application * rather than having the library pass only partially read header data to the application
* - The USB_UnhandledControlPacket event has had its parameters removed, in favour of accessing the new USB_ControlRequest structure * - The USB_UnhandledControlPacket event has had its parameters removed, in favour of accessing the new USB_ControlRequest structure
* - The Endpoint control stream functions now correctly send a ZLP to the host when less data than requested is sent * - The Endpoint control stream functions now correctly send a ZLP to the host when less data than requested is sent
* - Fixed USB_RemoteWakeupEnabled flag never being set (the REMOTE WAKEUP Set Feature request was not being handled)
* - Renamed the FEATURELESS_CONTROL_ONLY_DEVICE compile-time token to CONTROL_ONLY_DEVICE
* *
* *
* \section Sec_ChangeLog090401 Version 090401 * \section Sec_ChangeLog090401 Version 090401
......
...@@ -114,10 +114,10 @@ ...@@ -114,10 +114,10 @@
* EEPROM or RAM rather than flash memory) and reduces code maintenance. However, many USB device projects use only a single configuration. * EEPROM or RAM rather than flash memory) and reduces code maintenance. However, many USB device projects use only a single configuration.
* Defining this token enables single-configuration mode, reducing the compiled size of the binary at the expense of flexibility. * Defining this token enables single-configuration mode, reducing the compiled size of the binary at the expense of flexibility.
* *
* <b>FEATURELESS_CONTROL_ONLY_DEVICE</b> \n * <b>CONTROL_ONLY_DEVICE</b> \n
* In some limited USB device applications, device features (other than self-power) and endpoints other than the control endpoint aren't * In some limited USB device applications, there are no device endpoints other than the control endpoint; i.e. all device communication
* used. In such limited situations, this token may be defined to remove the handling of the Set Feature Chapter 9 request entirely and * is through control endpoint requests. Defining this token will remove several features related to the selection and control of device
* parts of the Get Feature chapter 9 request to save space. Generally, this is usually only useful in (some) bootloaders and is best avoided. * endpoints internally, saving space. Generally, this is usually only useful in (some) bootloaders and is best avoided.
* *
* <b>NO_STREAM_CALLBACKS</b> - ( \ref Group_EndpointPacketManagement , \ref Group_PipePacketManagement )\n * <b>NO_STREAM_CALLBACKS</b> - ( \ref Group_EndpointPacketManagement , \ref Group_PipePacketManagement )\n
* Both the endpoint and the pipe driver code contains stream functions, allowing for arrays of data to be sent to or from the * Both the endpoint and the pipe driver code contains stream functions, allowing for arrays of data to be sent to or from the
......
...@@ -46,31 +46,31 @@ void USB_Device_ProcessControlPacket(void) ...@@ -46,31 +46,31 @@ void USB_Device_ProcessControlPacket(void)
for (uint8_t RequestHeaderByte = 0; RequestHeaderByte < sizeof(USB_Request_Header_t); RequestHeaderByte++) for (uint8_t RequestHeaderByte = 0; RequestHeaderByte < sizeof(USB_Request_Header_t); RequestHeaderByte++)
*(RequestHeader++) = Endpoint_Read_Byte(); *(RequestHeader++) = Endpoint_Read_Byte();
uint8_t bmRequestType = USB_ControlRequest.bmRequestType;
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)
{ {
case REQ_GetStatus: case REQ_GetStatus:
if ((USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) || if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) ||
(USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT))) (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT)))
{ {
USB_Device_GetStatus(); USB_Device_GetStatus();
RequestHandled = true; RequestHandled = true;
} }
break; break;
#if !defined(FEATURELESS_CONTROL_ONLY_DEVICE)
case REQ_ClearFeature: case REQ_ClearFeature:
case REQ_SetFeature: case REQ_SetFeature:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT))
{ {
USB_Device_ClearSetFeature(); USB_Device_ClearSetFeature();
RequestHandled = true; RequestHandled = true;
} }
break; break;
#endif
case REQ_SetAddress: case REQ_SetAddress:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE))
{ {
USB_Device_SetAddress(); USB_Device_SetAddress();
RequestHandled = true; RequestHandled = true;
...@@ -78,8 +78,8 @@ void USB_Device_ProcessControlPacket(void) ...@@ -78,8 +78,8 @@ void USB_Device_ProcessControlPacket(void)
break; break;
case REQ_GetDescriptor: case REQ_GetDescriptor:
if ((USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) || if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) ||
(USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE))) (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE)))
{ {
USB_Device_GetDescriptor(); USB_Device_GetDescriptor();
RequestHandled = true; RequestHandled = true;
...@@ -87,7 +87,7 @@ void USB_Device_ProcessControlPacket(void) ...@@ -87,7 +87,7 @@ void USB_Device_ProcessControlPacket(void)
break; break;
case REQ_GetConfiguration: case REQ_GetConfiguration:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE))
{ {
USB_Device_GetConfiguration(); USB_Device_GetConfiguration();
RequestHandled = true; RequestHandled = true;
...@@ -95,7 +95,7 @@ void USB_Device_ProcessControlPacket(void) ...@@ -95,7 +95,7 @@ void USB_Device_ProcessControlPacket(void)
break; break;
case REQ_SetConfiguration: case REQ_SetConfiguration:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE))
{ {
USB_Device_SetConfiguration(); USB_Device_SetConfiguration();
RequestHandled = true; RequestHandled = true;
...@@ -124,7 +124,7 @@ static void USB_Device_SetAddress(void) ...@@ -124,7 +124,7 @@ static void USB_Device_SetAddress(void)
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));
UDADDR = ((1 << ADDEN) | (USB_ControlRequest.wValue & 0x7F)); UDADDR = ((1 << ADDEN) | ((uint8_t)USB_ControlRequest.wValue & 0x7F));
return; return;
} }
...@@ -134,17 +134,17 @@ static void USB_Device_SetConfiguration(void) ...@@ -134,17 +134,17 @@ static void USB_Device_SetConfiguration(void)
bool AlreadyConfigured = (USB_ConfigurationNumber != 0); bool AlreadyConfigured = (USB_ConfigurationNumber != 0);
#if defined(USE_SINGLE_DEVICE_CONFIGURATION) #if defined(USE_SINGLE_DEVICE_CONFIGURATION)
if (USB_ControlRequest.wValue > 1) if ((uint8_t)USB_ControlRequest.wValue > 1)
#else #else
USB_Descriptor_Device_t* DevDescriptorPtr; USB_Descriptor_Device_t* DevDescriptorPtr;
if ((USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr) == NO_DESCRIPTOR) || if ((USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr) == NO_DESCRIPTOR) ||
#if defined(USE_RAM_DESCRIPTORS) #if defined(USE_RAM_DESCRIPTORS)
(USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations)) ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations))
#elif defined (USE_EEPROM_DESCRIPTORS) #elif defined (USE_EEPROM_DESCRIPTORS)
(USB_ControlRequest.wValue > eeprom_read_byte(&DevDescriptorPtr->NumberOfConfigurations))) ((uint8_t)USB_ControlRequest.wValue > eeprom_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))
#else #else
(USB_ControlRequest.wValue > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations))) ((uint8_t)USB_ControlRequest.wValue > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))
#endif #endif
#endif #endif
{ {
...@@ -153,7 +153,7 @@ static void USB_Device_SetConfiguration(void) ...@@ -153,7 +153,7 @@ static void USB_Device_SetConfiguration(void)
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
USB_ConfigurationNumber = USB_ControlRequest.wValue; USB_ConfigurationNumber = (uint8_t)USB_ControlRequest.wValue;
Endpoint_ClearIN(); Endpoint_ClearIN();
...@@ -245,9 +245,9 @@ static void USB_Device_GetStatus(void) ...@@ -245,9 +245,9 @@ static void USB_Device_GetStatus(void)
CurrentStatus |= FEATURE_REMOTE_WAKEUP_ENABLED; CurrentStatus |= FEATURE_REMOTE_WAKEUP_ENABLED;
break; break;
#if !defined(FEATURELESS_CONTROL_ONLY_DEVICE) #if !defined(CONTROL_ONLY_DEVICE)
case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT): case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT):
Endpoint_SelectEndpoint(USB_ControlRequest.wIndex); Endpoint_SelectEndpoint((uint8_t)USB_ControlRequest.wIndex);
CurrentStatus = Endpoint_IsStalled(); CurrentStatus = Endpoint_IsStalled();
...@@ -267,15 +267,20 @@ static void USB_Device_GetStatus(void) ...@@ -267,15 +267,20 @@ static void USB_Device_GetStatus(void)
Endpoint_ClearOUT(); Endpoint_ClearOUT();
} }
#if !defined(FEATURELESS_CONTROL_ONLY_DEVICE)
static void USB_Device_ClearSetFeature(void) static void USB_Device_ClearSetFeature(void)
{ {
switch (USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) switch (USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT)
{ {
case REQREC_DEVICE:
if ((uint8_t)USB_ControlRequest.wValue == FEATURE_REMOTE_WAKEUP)
USB_RemoteWakeupEnabled = (USB_ControlRequest.bRequest == REQ_SetFeature);
break;
#if !defined(CONTROL_ONLY_DEVICE)
case REQREC_ENDPOINT: case REQREC_ENDPOINT:
if (USB_ControlRequest.wValue == FEATURE_ENDPOINT_HALT) if ((uint8_t)USB_ControlRequest.wValue == FEATURE_ENDPOINT_HALT)
{ {
uint8_t EndpointIndex = (USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK); uint8_t EndpointIndex = ((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK);
if (EndpointIndex != ENDPOINT_CONTROLEP) if (EndpointIndex != ENDPOINT_CONTROLEP)
{ {
...@@ -302,8 +307,8 @@ static void USB_Device_ClearSetFeature(void) ...@@ -302,8 +307,8 @@ static void USB_Device_ClearSetFeature(void)
} }
break; break;
#endif
} }
} }
#endif
#endif #endif
...@@ -120,9 +120,7 @@ ...@@ -120,9 +120,7 @@
static void USB_Device_GetConfiguration(void); static void USB_Device_GetConfiguration(void);
static void USB_Device_GetDescriptor(void); static void USB_Device_GetDescriptor(void);
static void USB_Device_GetStatus(void); static void USB_Device_GetStatus(void);
#if !defined(FEATURELESS_CONTROL_ONLY_DEVICE)
static void USB_Device_ClearSetFeature(void); static void USB_Device_ClearSetFeature(void);
#endif
#endif #endif
#endif #endif
......
...@@ -82,6 +82,7 @@ void Endpoint_ClearEndpoints(void) ...@@ -82,6 +82,7 @@ void Endpoint_ClearEndpoints(void)
} }
} }
#if !defined(CONTROL_ONLY_DEVICE)
uint8_t Endpoint_WaitUntilReady(void) uint8_t Endpoint_WaitUntilReady(void)
{ {
uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
...@@ -289,6 +290,7 @@ uint8_t Endpoint_Read_Stream_BE(void* Buffer, uint16_t Length ...@@ -289,6 +290,7 @@ uint8_t Endpoint_Read_Stream_BE(void* Buffer, uint16_t Length
return ENDPOINT_RWSTREAM_ERROR_NoError; return ENDPOINT_RWSTREAM_ERROR_NoError;
} }
#endif
uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length) uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length)
{ {
......
...@@ -127,14 +127,18 @@ ...@@ -127,14 +127,18 @@
*/ */
#define ENDPOINT_DOUBLEBANK_SUPPORTED(n) _ENDPOINT_GET_DOUBLEBANK(n) #define ENDPOINT_DOUBLEBANK_SUPPORTED(n) _ENDPOINT_GET_DOUBLEBANK(n)
#if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__) #if !defined(CONTROL_ONLY_DEVICE)
/** Total number of endpoints (including the default control endpoint at address 0) which may #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)
* be used in the device. Different USB AVR models support different amounts of endpoints, /** Total number of endpoints (including the default control endpoint at address 0) which may
* this value reflects the maximum number of endpoints for the currently selected AVR model. * be used in the device. Different USB AVR models support different amounts of endpoints,
*/ * this value reflects the maximum number of endpoints for the currently selected AVR model.
#define ENDPOINT_TOTAL_ENDPOINTS 7 */
#define ENDPOINT_TOTAL_ENDPOINTS 7
#else
#define ENDPOINT_TOTAL_ENDPOINTS 5
#endif
#else #else
#define ENDPOINT_TOTAL_ENDPOINTS 5 #define ENDPOINT_TOTAL_ENDPOINTS 1
#endif #endif
/** Interrupt definition for the endpoint SETUP interrupt (for CONTROL type endpoints). Should be /** Interrupt definition for the endpoint SETUP interrupt (for CONTROL type endpoints). Should be
...@@ -366,9 +370,17 @@ ...@@ -366,9 +370,17 @@
#define Endpoint_BytesInEndpoint() UEBCLX #define Endpoint_BytesInEndpoint() UEBCLX
#endif