Fixed USB_RemoteWakeupEnabled flag never being set (the REMOTE WAKEUP Set Feature...
authorDean Camera <dean@fourwalledcubicle.com>
Thu, 23 Apr 2009 13:28:12 +0000 (13:28 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Thu, 23 Apr 2009 13:28:12 +0000 (13:28 +0000)
Renamed the FEATURELESS_CONTROL_ONLY_DEVICE compile-time token to CONTROL_ONLY_DEVICE.

19 files changed:
Bootloaders/DFU/makefile
Bootloaders/TeensyHID/makefile
Demos/Device/CDC/CDC.c
Demos/Device/GenericHID/GenericHID.c
Demos/Device/Joystick/Joystick.c
Demos/Device/Keyboard/Keyboard.c
Demos/Device/KeyboardMouse/KeyboardMouse.c
Demos/Device/Mouse/Mouse.c
Demos/Device/RNDISEthernet/RNDISEthernet.c
Demos/Device/USBtoSerial/USBtoSerial.c
Demos/Host/MassStorageHost/MassStoreCommands.c
LUFA/ChangeLog.txt
LUFA/CompileTimeTokens.txt
LUFA/Drivers/USB/LowLevel/DevChapter9.c
LUFA/Drivers/USB/LowLevel/DevChapter9.h
LUFA/Drivers/USB/LowLevel/Endpoint.c
LUFA/Drivers/USB/LowLevel/Endpoint.h
LUFA/Drivers/USB/LowLevel/LowLevel.c
LUFA/MigrationInformation.txt

index d93836f..d55235b 100644 (file)
@@ -54,7 +54,7 @@ MCU = at90usb1287
 # Target board (see library BoardTypes.h documentation, USER or blank for projects not requiring\r
 # LUFA board drivers). If USER is selected, put custom board drivers in a directory called \r
 # "Board" inside the application directory.\r
 # Target board (see library BoardTypes.h documentation, USER or blank for projects not requiring\r
 # LUFA board drivers). If USER is selected, put custom board drivers in a directory called \r
 # "Board" inside the application directory.\r
-BOARD  = USBKEY\r
+BOARD = USBKEY\r
 \r
 \r
 # Processor frequency.\r
 \r
 \r
 # Processor frequency.\r
@@ -175,7 +175,7 @@ BOOT_START = 0x1E000
 \r
 # Place -D or -U options here for C sources\r
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)\r
 \r
 # Place -D or -U options here for C sources\r
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)\r
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DFEATURELESS_CONTROL_ONLY_DEVICE\r
+CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DCONTROL_ONLY_DEVICE\r
 CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=32\r
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"\r
 CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DUSE_SINGLE_DEVICE_CONFIGURATION\r
 CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=32\r
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"\r
 CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DUSE_SINGLE_DEVICE_CONFIGURATION\r
index 6ef9f3a..12b1b45 100644 (file)
@@ -175,7 +175,7 @@ BOOT_START = 0xC000
 \r
 # Place -D or -U options here for C sources\r
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)\r
 \r
 # Place -D or -U options here for C sources\r
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)\r
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DFEATURELESS_CONTROL_ONLY_DEVICE\r
+CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DCONTROL_ONLY_DEVICE\r
 CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8\r
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"\r
 CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DUSE_SINGLE_DEVICE_CONFIGURATION\r
 CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8\r
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"\r
 CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DUSE_SINGLE_DEVICE_CONFIGURATION\r
index 28bce1e..59aa98c 100644 (file)
@@ -193,14 +193,14 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_SetControlLineState:\r
                        if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
                case REQ_SetControlLineState:\r
                        if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
+                               /* Acknowledge the SETUP packet, ready for data transfer */\r
+                               Endpoint_ClearSETUP();\r
+                               \r
                                /* NOTE: Here you can read in the line state mask from the host, to get the current state of the output handshake\r
                                         lines. The mask is read in from the wValue parameter in USB_ControlRequest, and can be masked against the\r
                                                 CONTROL_LINE_OUT_* masks to determine the RTS and DTR line states using the following code:\r
                                */\r
                                \r
                                /* NOTE: Here you can read in the line state mask from the host, to get the current state of the output handshake\r
                                         lines. The mask is read in from the wValue parameter in USB_ControlRequest, and can be masked against the\r
                                                 CONTROL_LINE_OUT_* masks to determine the RTS and DTR line states using the following code:\r
                                */\r
                                \r
-                               /* Acknowledge the SETUP packet, ready for data transfer */\r
-                               Endpoint_ClearSETUP();\r
-                               \r
                                /* Acknowledge status stage */\r
                                while (!(Endpoint_IsINReady()));\r
                                Endpoint_ClearIN();\r
                                /* Acknowledge status stage */\r
                                while (!(Endpoint_IsINReady()));\r
                                Endpoint_ClearIN();\r
index 245ddaa..695342d 100644 (file)
@@ -165,10 +165,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_GetReport:\r
                        if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
                case REQ_GetReport:\r
                        if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
+                               uint8_t GenericData[GENERIC_REPORT_SIZE];\r
+\r
                                Endpoint_ClearSETUP();\r
        \r
                                Endpoint_ClearSETUP();\r
        \r
-                               uint8_t GenericData[GENERIC_REPORT_SIZE];\r
-                               \r
                                CreateGenericHIDReport(GenericData);\r
 \r
                                /* Write the report data to the control endpoint */\r
                                CreateGenericHIDReport(GenericData);\r
 \r
                                /* Write the report data to the control endpoint */\r
@@ -182,13 +182,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_SetReport:\r
                        if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
                case REQ_SetReport:\r
                        if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
+                               uint8_t GenericData[GENERIC_REPORT_SIZE];\r
+\r
                                Endpoint_ClearSETUP();\r
                                \r
                                /* Wait until the generic report has been sent by the host */\r
                                while (!(Endpoint_IsOUTReceived()));\r
 \r
                                Endpoint_ClearSETUP();\r
                                \r
                                /* Wait until the generic report has been sent by the host */\r
                                while (!(Endpoint_IsOUTReceived()));\r
 \r
-                               uint8_t GenericData[GENERIC_REPORT_SIZE];\r
-\r
                                Endpoint_Read_Control_Stream_LE(&GenericData, sizeof(GenericData));\r
 \r
                                ProcessGenericHIDReport(GenericData);\r
                                Endpoint_Read_Control_Stream_LE(&GenericData, sizeof(GenericData));\r
 \r
                                ProcessGenericHIDReport(GenericData);\r
index ee4bc6a..a5c3242 100644 (file)
@@ -129,11 +129,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                        {\r
                                USB_JoystickReport_Data_t JoystickReportData;\r
                                \r
                        {\r
                                USB_JoystickReport_Data_t JoystickReportData;\r
                                \r
+                               Endpoint_ClearSETUP();\r
+\r
                                /* Create the next HID report to send to the host */                            \r
                                GetNextReport(&JoystickReportData);\r
                                /* Create the next HID report to send to the host */                            \r
                                GetNextReport(&JoystickReportData);\r
-                               \r
-                               Endpoint_ClearSETUP();\r
-       \r
+                                       \r
                                /* Write the report data to the control endpoint */\r
                                Endpoint_Write_Control_Stream_LE(&JoystickReportData, sizeof(JoystickReportData));\r
                                \r
                                /* Write the report data to the control endpoint */\r
                                Endpoint_Write_Control_Stream_LE(&JoystickReportData, sizeof(JoystickReportData));\r
                                \r
index 088943b..33545bf 100644 (file)
@@ -200,11 +200,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                        {\r
                                USB_KeyboardReport_Data_t KeyboardReportData;\r
 \r
                        {\r
                                USB_KeyboardReport_Data_t KeyboardReportData;\r
 \r
+                               Endpoint_ClearSETUP();\r
+       \r
                                /* Create the next keyboard report for transmission to the host */\r
                                CreateKeyboardReport(&KeyboardReportData);\r
 \r
                                /* Create the next keyboard report for transmission to the host */\r
                                CreateKeyboardReport(&KeyboardReportData);\r
 \r
-                               Endpoint_ClearSETUP();\r
-       \r
                                /* Write the report data to the control endpoint */\r
                                Endpoint_Write_Control_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData));\r
                                \r
                                /* Write the report data to the control endpoint */\r
                                Endpoint_Write_Control_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData));\r
                                \r
index a85a378..dc039ee 100644 (file)
@@ -144,6 +144,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_GetReport:\r
                        if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
                case REQ_GetReport:\r
                        if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
+                               Endpoint_ClearSETUP();\r
+       \r
                                /* Determine if it is the mouse or the keyboard data that is being requested */\r
                                if (!(USB_ControlRequest.wIndex))\r
                                {\r
                                /* Determine if it is the mouse or the keyboard data that is being requested */\r
                                if (!(USB_ControlRequest.wIndex))\r
                                {\r
@@ -156,8 +158,6 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                        ReportSize = sizeof(MouseReportData);\r
                                }\r
 \r
                                        ReportSize = sizeof(MouseReportData);\r
                                }\r
 \r
-                               Endpoint_ClearSETUP();\r
-       \r
                                /* Write the report data to the control endpoint */\r
                                Endpoint_Write_Control_Stream_LE(ReportData, ReportSize);\r
 \r
                                /* Write the report data to the control endpoint */\r
                                Endpoint_Write_Control_Stream_LE(ReportData, ReportSize);\r
 \r
index 2e5f05b..669b576 100644 (file)
@@ -190,10 +190,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                        {\r
                                USB_MouseReport_Data_t MouseReportData;\r
 \r
                        {\r
                                USB_MouseReport_Data_t MouseReportData;\r
 \r
+                               Endpoint_ClearSETUP();\r
+\r
                                /* Create the next mouse report for transmission to the host */\r
                                CreateMouseReport(&MouseReportData);\r
                                /* Create the next mouse report for transmission to the host */\r
                                CreateMouseReport(&MouseReportData);\r
-\r
-                               Endpoint_ClearSETUP();\r
        \r
                                /* Write the report data to the control endpoint */\r
                                Endpoint_Write_Control_Stream_LE(&MouseReportData, sizeof(MouseReportData));\r
        \r
                                /* Write the report data to the control endpoint */\r
                                Endpoint_Write_Control_Stream_LE(&MouseReportData, sizeof(MouseReportData));\r
index 7b81ad8..8338cdd 100644 (file)
@@ -172,6 +172,9 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_GetEncapsulatedResponse:\r
                        if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
                case REQ_GetEncapsulatedResponse:\r
                        if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
+                               /* Clear the SETUP packet, ready for data transfer */\r
+                               Endpoint_ClearSETUP();\r
+                               \r
                                /* Check if a response to the last message is ready */\r
                                if (!(MessageHeader->MessageLength))\r
                                {\r
                                /* Check if a response to the last message is ready */\r
                                if (!(MessageHeader->MessageLength))\r
                                {\r
@@ -180,9 +183,6 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                        MessageHeader->MessageLength = 1;\r
                                }\r
 \r
                                        MessageHeader->MessageLength = 1;\r
                                }\r
 \r
-                               /* Clear the SETUP packet, ready for data transfer */\r
-                               Endpoint_ClearSETUP();\r
-                               \r
                                /* Write the message response data to the endpoint */\r
                                Endpoint_Write_Control_Stream_LE(RNDISMessageBuffer, MessageHeader->MessageLength);\r
                                \r
                                /* Write the message response data to the endpoint */\r
                                Endpoint_Write_Control_Stream_LE(RNDISMessageBuffer, MessageHeader->MessageLength);\r
                                \r
index dbf4b1b..ea8dcd5 100644 (file)
@@ -188,15 +188,15 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                        break;\r
                case REQ_SetControlLineState:\r
                        if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        break;\r
                case REQ_SetControlLineState:\r
                        if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
-                       {\r
+                       {                               \r
+                               /* Acknowledge the SETUP packet, ready for data transfer */\r
+                               Endpoint_ClearSETUP();\r
+                               \r
                                /* NOTE: Here you can read in the line state mask from the host, to get the current state of the output handshake\r
                                         lines. The mask is read in from the wValue parameter in USB_ControlRequest, and can be masked against the\r
                                                 CONTROL_LINE_OUT_* masks to determine the RTS and DTR line states using the following code:\r
                                */\r
                                /* NOTE: Here you can read in the line state mask from the host, to get the current state of the output handshake\r
                                         lines. The mask is read in from the wValue parameter in USB_ControlRequest, and can be masked against the\r
                                                 CONTROL_LINE_OUT_* masks to determine the RTS and DTR line states using the following code:\r
                                */\r
-                               \r
-                               /* Acknowledge the SETUP packet, ready for data transfer */\r
-                               Endpoint_ClearSETUP();\r
-                               \r
+\r
                                /* Acknowledge status stage */\r
                                while (!(Endpoint_IsINReady()));\r
                                Endpoint_ClearIN();\r
                                /* Acknowledge status stage */\r
                                while (!(Endpoint_IsINReady()));\r
                                Endpoint_ClearIN();\r
index d4df205..4ebc67a 100644 (file)
@@ -75,7 +75,7 @@ static uint8_t MassStore_SendCommand(void)
 {\r
        uint8_t ErrorCode = PIPE_RWSTREAM_ERROR_NoError;\r
 \r
 {\r
        uint8_t ErrorCode = PIPE_RWSTREAM_ERROR_NoError;\r
 \r
-       /* Each transmission should have a unique tag value, excluding valued 0 and 0xFFFFFFFF */\r
+       /* Each transmission should have a unique tag value, excluding values 0 and 0xFFFFFFFF */\r
        if (++MassStore_Tag == 0xFFFFFFFF)\r
          MassStore_Tag = 1;\r
 \r
        if (++MassStore_Tag == 0xFFFFFFFF)\r
          MassStore_Tag = 1;\r
 \r
index 3825cd3..1557db5 100644 (file)
@@ -59,6 +59,8 @@
   *    rather than having the library pass only partially read header data to the application\r
   *  - The USB_UnhandledControlPacket event has had its parameters removed, in favour of accessing the new USB_ControlRequest structure\r
   *  - The Endpoint control stream functions now correctly send a ZLP to the host when less data than requested is sent\r
   *    rather than having the library pass only partially read header data to the application\r
   *  - The USB_UnhandledControlPacket event has had its parameters removed, in favour of accessing the new USB_ControlRequest structure\r
   *  - The Endpoint control stream functions now correctly send a ZLP to the host when less data than requested is sent\r
+  *  - Fixed USB_RemoteWakeupEnabled flag never being set (the REMOTE WAKEUP Set Feature request was not being handled)\r
+  *  - Renamed the FEATURELESS_CONTROL_ONLY_DEVICE compile-time token to CONTROL_ONLY_DEVICE \r
   *    \r
   *\r
   *  \section Sec_ChangeLog090401 Version 090401\r
   *    \r
   *\r
   *  \section Sec_ChangeLog090401 Version 090401\r
index 0dc4be0..090ace8 100644 (file)
  *  EEPROM or RAM rather than flash memory) and reduces code maintenance. However, many USB device projects use only a single configuration.\r
  *  Defining this token enables single-configuration mode, reducing the compiled size of the binary at the expense of flexibility.\r
  *\r
  *  EEPROM or RAM rather than flash memory) and reduces code maintenance. However, many USB device projects use only a single configuration.\r
  *  Defining this token enables single-configuration mode, reducing the compiled size of the binary at the expense of flexibility.\r
  *\r
- *  <b>FEATURELESS_CONTROL_ONLY_DEVICE</b> \n\r
- *  In some limited USB device applications, device features (other than self-power) and endpoints other than the control endpoint aren't\r
- *  used. In such limited situations, this token may be defined to remove the handling of the Set Feature Chapter 9 request entirely and\r
- *  parts of the Get Feature chapter 9 request to save space. Generally, this is usually only useful in (some) bootloaders and is best avoided.\r
+ *  <b>CONTROL_ONLY_DEVICE</b> \n\r
+ *  In some limited USB device applications, there are no device endpoints other than the control endpoint; i.e. all device communication\r
+ *  is through control endpoint requests. Defining this token will remove several features related to the selection and control of device\r
+ *  endpoints internally, saving space. Generally, this is usually only useful in (some) bootloaders and is best avoided.\r
  *\r
  *  <b>NO_STREAM_CALLBACKS</b> - ( \ref Group_EndpointPacketManagement , \ref Group_PipePacketManagement )\n\r
  *  Both the endpoint and the pipe driver code contains stream functions, allowing for arrays of data to be sent to or from the\r
  *\r
  *  <b>NO_STREAM_CALLBACKS</b> - ( \ref Group_EndpointPacketManagement , \ref Group_PipePacketManagement )\n\r
  *  Both the endpoint and the pipe driver code contains stream functions, allowing for arrays of data to be sent to or from the\r
index bf2b127..bf1cb6c 100644 (file)
@@ -46,31 +46,31 @@ void USB_Device_ProcessControlPacket(void)
        \r
        for (uint8_t RequestHeaderByte = 0; RequestHeaderByte < sizeof(USB_Request_Header_t); RequestHeaderByte++)\r
          *(RequestHeader++) = Endpoint_Read_Byte();\r
        \r
        for (uint8_t RequestHeaderByte = 0; RequestHeaderByte < sizeof(USB_Request_Header_t); RequestHeaderByte++)\r
          *(RequestHeader++) = Endpoint_Read_Byte();\r
+         \r
+       uint8_t bmRequestType = USB_ControlRequest.bmRequestType;\r
        \r
        switch (USB_ControlRequest.bRequest)\r
        {\r
                case REQ_GetStatus:\r
        \r
        switch (USB_ControlRequest.bRequest)\r
        {\r
                case REQ_GetStatus:\r
-                       if ((USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) ||\r
-                           (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT)))\r
+                       if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) ||\r
+                           (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT)))\r
                        {\r
                                USB_Device_GetStatus();\r
                                RequestHandled = true;\r
                        }\r
 \r
                        break;\r
                        {\r
                                USB_Device_GetStatus();\r
                                RequestHandled = true;\r
                        }\r
 \r
                        break;\r
-#if !defined(FEATURELESS_CONTROL_ONLY_DEVICE)\r
                case REQ_ClearFeature:\r
                case REQ_SetFeature:\r
                case REQ_ClearFeature:\r
                case REQ_SetFeature:\r
-                       if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT))\r
+                       if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT))\r
                        {\r
                                USB_Device_ClearSetFeature();\r
                                RequestHandled = true;\r
                        }\r
 \r
                        break;\r
                        {\r
                                USB_Device_ClearSetFeature();\r
                                RequestHandled = true;\r
                        }\r
 \r
                        break;\r
-#endif\r
                case REQ_SetAddress:\r
                case REQ_SetAddress:\r
-                       if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE))\r
+                       if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE))\r
                        {\r
                                USB_Device_SetAddress();\r
                                RequestHandled = true;\r
                        {\r
                                USB_Device_SetAddress();\r
                                RequestHandled = true;\r
@@ -78,8 +78,8 @@ void USB_Device_ProcessControlPacket(void)
 \r
                        break;\r
                case REQ_GetDescriptor:\r
 \r
                        break;\r
                case REQ_GetDescriptor:\r
-                       if ((USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) ||\r
-                           (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE)))\r
+                       if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) ||\r
+                           (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE)))\r
                        {\r
                                USB_Device_GetDescriptor();\r
                                RequestHandled = true;\r
                        {\r
                                USB_Device_GetDescriptor();\r
                                RequestHandled = true;\r
@@ -87,7 +87,7 @@ void USB_Device_ProcessControlPacket(void)
                        \r
                        break;\r
                case REQ_GetConfiguration:\r
                        \r
                        break;\r
                case REQ_GetConfiguration:\r
-                       if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE))\r
+                       if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE))\r
                        {\r
                                USB_Device_GetConfiguration();\r
                                RequestHandled = true;\r
                        {\r
                                USB_Device_GetConfiguration();\r
                                RequestHandled = true;\r
@@ -95,7 +95,7 @@ void USB_Device_ProcessControlPacket(void)
 \r
                        break;\r
                case REQ_SetConfiguration:\r
 \r
                        break;\r
                case REQ_SetConfiguration:\r
-                       if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE))\r
+                       if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE))\r
                        {\r
                                USB_Device_SetConfiguration();\r
                                RequestHandled = true;\r
                        {\r
                                USB_Device_SetConfiguration();\r
                                RequestHandled = true;\r
@@ -124,7 +124,7 @@ static void USB_Device_SetAddress(void)
        \r
        while (!(Endpoint_IsINReady()));\r
 \r
        \r
        while (!(Endpoint_IsINReady()));\r
 \r
-       UDADDR = ((1 << ADDEN) | (USB_ControlRequest.wValue & 0x7F));\r
+       UDADDR = ((1 << ADDEN) | ((uint8_t)USB_ControlRequest.wValue & 0x7F));\r
 \r
        return;\r
 }\r
 \r
        return;\r
 }\r
@@ -134,17 +134,17 @@ static void USB_Device_SetConfiguration(void)
        bool    AlreadyConfigured = (USB_ConfigurationNumber != 0);\r
 \r
 #if defined(USE_SINGLE_DEVICE_CONFIGURATION)\r
        bool    AlreadyConfigured = (USB_ConfigurationNumber != 0);\r
 \r
 #if defined(USE_SINGLE_DEVICE_CONFIGURATION)\r
-       if (USB_ControlRequest.wValue > 1)\r
+       if ((uint8_t)USB_ControlRequest.wValue > 1)\r
 #else\r
        USB_Descriptor_Device_t* DevDescriptorPtr;\r
 \r
        if ((USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr) == NO_DESCRIPTOR) ||\r
        #if defined(USE_RAM_DESCRIPTORS)\r
 #else\r
        USB_Descriptor_Device_t* DevDescriptorPtr;\r
 \r
        if ((USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr) == NO_DESCRIPTOR) ||\r
        #if defined(USE_RAM_DESCRIPTORS)\r
-           (USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations))\r
+           ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations))\r
        #elif defined (USE_EEPROM_DESCRIPTORS)\r
        #elif defined (USE_EEPROM_DESCRIPTORS)\r
-           (USB_ControlRequest.wValue > eeprom_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))\r
+           ((uint8_t)USB_ControlRequest.wValue > eeprom_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))\r
        #else\r
        #else\r
-           (USB_ControlRequest.wValue > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))\r
+           ((uint8_t)USB_ControlRequest.wValue > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))\r
        #endif\r
 #endif\r
        {\r
        #endif\r
 #endif\r
        {\r
@@ -153,7 +153,7 @@ static void USB_Device_SetConfiguration(void)
        \r
        Endpoint_ClearSETUP();\r
 \r
        \r
        Endpoint_ClearSETUP();\r
 \r
-       USB_ConfigurationNumber = USB_ControlRequest.wValue;\r
+       USB_ConfigurationNumber = (uint8_t)USB_ControlRequest.wValue;\r
 \r
        Endpoint_ClearIN();\r
 \r
 \r
        Endpoint_ClearIN();\r
 \r
@@ -245,9 +245,9 @@ static void USB_Device_GetStatus(void)
                          CurrentStatus |= FEATURE_REMOTE_WAKEUP_ENABLED;\r
                        \r
                        break;\r
                          CurrentStatus |= FEATURE_REMOTE_WAKEUP_ENABLED;\r
                        \r
                        break;\r
-#if !defined(FEATURELESS_CONTROL_ONLY_DEVICE)\r
+#if !defined(CONTROL_ONLY_DEVICE)\r
                case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT):\r
                case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT):\r
-                       Endpoint_SelectEndpoint(USB_ControlRequest.wIndex);\r
+                       Endpoint_SelectEndpoint((uint8_t)USB_ControlRequest.wIndex);\r
 \r
                        CurrentStatus = Endpoint_IsStalled();\r
 \r
 \r
                        CurrentStatus = Endpoint_IsStalled();\r
 \r
@@ -267,15 +267,20 @@ static void USB_Device_GetStatus(void)
        Endpoint_ClearOUT();\r
 }\r
 \r
        Endpoint_ClearOUT();\r
 }\r
 \r
-#if !defined(FEATURELESS_CONTROL_ONLY_DEVICE)\r
 static void USB_Device_ClearSetFeature(void)\r
 {      \r
        switch (USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT)\r
        {\r
 static void USB_Device_ClearSetFeature(void)\r
 {      \r
        switch (USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT)\r
        {\r
+               case REQREC_DEVICE:\r
+                       if ((uint8_t)USB_ControlRequest.wValue == FEATURE_REMOTE_WAKEUP)\r
+                         USB_RemoteWakeupEnabled = (USB_ControlRequest.bRequest == REQ_SetFeature);\r
+                       \r
+                       break;                  \r
+#if !defined(CONTROL_ONLY_DEVICE)\r
                case REQREC_ENDPOINT:\r
                case REQREC_ENDPOINT:\r
-                       if (USB_ControlRequest.wValue == FEATURE_ENDPOINT_HALT)\r
+                       if ((uint8_t)USB_ControlRequest.wValue == FEATURE_ENDPOINT_HALT)\r
                        {\r
                        {\r
-                               uint8_t EndpointIndex = (USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK);\r
+                               uint8_t EndpointIndex = ((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK);\r
                                \r
                                if (EndpointIndex != ENDPOINT_CONTROLEP)\r
                                {\r
                                \r
                                if (EndpointIndex != ENDPOINT_CONTROLEP)\r
                                {\r
@@ -302,8 +307,8 @@ static void USB_Device_ClearSetFeature(void)
                        }\r
                        \r
                        break;\r
                        }\r
                        \r
                        break;\r
+#endif\r
        }\r
 }\r
        }\r
 }\r
-#endif\r
 \r
 #endif\r
 \r
 #endif\r
index b3cac2d..3369b51 100644 (file)
                                static void USB_Device_GetConfiguration(void);\r
                                static void USB_Device_GetDescriptor(void);\r
                                static void USB_Device_GetStatus(void);\r
                                static void USB_Device_GetConfiguration(void);\r
                                static void USB_Device_GetDescriptor(void);\r
                                static void USB_Device_GetStatus(void);\r
-                               #if !defined(FEATURELESS_CONTROL_ONLY_DEVICE)\r
                                static void USB_Device_ClearSetFeature(void);\r
                                static void USB_Device_ClearSetFeature(void);\r
-                               #endif\r
                        #endif\r
        #endif\r
 \r
                        #endif\r
        #endif\r
 \r
index efa1a2d..da2925e 100644 (file)
@@ -82,6 +82,7 @@ void Endpoint_ClearEndpoints(void)
        }\r
 }\r
 \r
        }\r
 }\r
 \r
+#if !defined(CONTROL_ONLY_DEVICE)\r
 uint8_t Endpoint_WaitUntilReady(void)\r
 {\r
        uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
 uint8_t Endpoint_WaitUntilReady(void)\r
 {\r
        uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
@@ -289,6 +290,7 @@ uint8_t Endpoint_Read_Stream_BE(void* Buffer, uint16_t Length
        \r
        return ENDPOINT_RWSTREAM_ERROR_NoError;\r
 }\r
        \r
        return ENDPOINT_RWSTREAM_ERROR_NoError;\r
 }\r
+#endif\r
 \r
 uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length)\r
 {\r
 \r
 uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length)\r
 {\r
index 172ab33..1e88e06 100644 (file)
                         */                             \r
                        #define ENDPOINT_DOUBLEBANK_SUPPORTED(n)      _ENDPOINT_GET_DOUBLEBANK(n)\r
 \r
                         */                             \r
                        #define ENDPOINT_DOUBLEBANK_SUPPORTED(n)      _ENDPOINT_GET_DOUBLEBANK(n)\r
 \r
-                       #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)\r
-                               /** Total number of endpoints (including the default control endpoint at address 0) which may\r
-                                *  be used in the device. Different USB AVR models support different amounts of endpoints,\r
-                                *  this value reflects the maximum number of endpoints for the currently selected AVR model.\r
-                                */\r
-                               #define ENDPOINT_TOTAL_ENDPOINTS          7\r
+                       #if !defined(CONTROL_ONLY_DEVICE)\r
+                               #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)\r
+                                       /** Total number of endpoints (including the default control endpoint at address 0) which may\r
+                                        *  be used in the device. Different USB AVR models support different amounts of endpoints,\r
+                                        *  this value reflects the maximum number of endpoints for the currently selected AVR model.\r
+                                        */\r
+                                       #define ENDPOINT_TOTAL_ENDPOINTS          7\r
+                               #else\r
+                                       #define ENDPOINT_TOTAL_ENDPOINTS          5                     \r
+                               #endif\r
                        #else\r
                        #else\r
-                               #define ENDPOINT_TOTAL_ENDPOINTS          5                     \r
+                               #define ENDPOINT_TOTAL_ENDPOINTS              1\r
                        #endif\r
 \r
                        /** Interrupt definition for the endpoint SETUP interrupt (for CONTROL type endpoints). Should be\r
                        #endif\r
 \r
                        /** Interrupt definition for the endpoint SETUP interrupt (for CONTROL type endpoints). Should be\r
                                        #define Endpoint_BytesInEndpoint()        UEBCLX\r
                                #endif\r
                                \r
                                        #define Endpoint_BytesInEndpoint()        UEBCLX\r
                                #endif\r
                                \r
-                               #define Endpoint_GetCurrentEndpoint()         (UENUM & ENDPOINT_EPNUM_MASK)\r
+                               #if !defined(CONTROL_ONLY_DEVICE)\r
+                                       #define Endpoint_GetCurrentEndpoint()     (UENUM & ENDPOINT_EPNUM_MASK)\r
+                               #else\r
+                                       #define Endpoint_GetCurrentEndpoint()     ENDPOINT_CONTROLEP\r
+                               #endif\r
                                \r
                                \r
-                               #define Endpoint_SelectEndpoint(epnum)        MACROS{ UENUM = epnum; }MACROE\r
+                               #if !defined(CONTROL_ONLY_DEVICE)\r
+                                       #define Endpoint_SelectEndpoint(epnum)    MACROS{ UENUM = epnum; }MACROE\r
+                               #else\r
+                                       #define Endpoint_SelectEndpoint(epnum)    (void)epnum\r
+                               #endif\r
 \r
                                #define Endpoint_ResetFIFO(epnum)             MACROS{ UERST = (1 << epnum); UERST = 0; }MACROE\r
 \r
 \r
                                #define Endpoint_ResetFIFO(epnum)             MACROS{ UERST = (1 << epnum); UERST = 0; }MACROE\r
 \r
 \r
                                #define Endpoint_IsEnabled()                  ((UECONX & (1 << EPEN)) ? true : false)\r
 \r
 \r
                                #define Endpoint_IsEnabled()                  ((UECONX & (1 << EPEN)) ? true : false)\r
 \r
-                               #define Endpoint_IsReadWriteAllowed()         ((UEINTX & (1 << RWAL)) ? true : false)\r
-\r
+                               #if !defined(CONTROL_ONLY_DEVICE)\r
+                                       #define Endpoint_IsReadWriteAllowed()     ((UEINTX & (1 << RWAL)) ? true : false)\r
+                               #endif\r
+                               \r
                                #define Endpoint_IsConfigured()               ((UESTA0X & (1 << CFGOK)) ? true : false)\r
 \r
                                #define Endpoint_GetEndpointInterrupts()      UEINT\r
                                #define Endpoint_IsConfigured()               ((UESTA0X & (1 << CFGOK)) ? true : false)\r
 \r
                                #define Endpoint_GetEndpointInterrupts()      UEINT\r
 \r
                                #define Endpoint_ClearSETUP()                 MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE\r
 \r
 \r
                                #define Endpoint_ClearSETUP()                 MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE\r
 \r
-                               #define Endpoint_ClearIN()                    MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << TXINI)); \\r
-                                                                                     UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE\r
+                               #if !defined(CONTROL_ONLY_DEVICE)\r
+                                       #define Endpoint_ClearIN()                MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << TXINI)); \\r
+                                                                                         UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE\r
+                               #else\r
+                                       #define Endpoint_ClearIN()                MACROS{ UEINTX &= ~(1 << TXINI); }MACROE\r
+                               #endif\r
 \r
 \r
-                               #define Endpoint_ClearOUT()                   MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << RXOUTI)); \\r
-                                                                                     UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE\r
+                               #if !defined(CONTROL_ONLY_DEVICE)\r
+                                       #define Endpoint_ClearOUT()               MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << RXOUTI)); \\r
+                                                                                         UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE\r
+                               #else\r
+                                       #define Endpoint_ClearOUT()               MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE                     \r
+                               #endif\r
 \r
                                #define Endpoint_StallTransaction()           MACROS{ UECONX |= (1 << STALLRQ); }MACROE\r
 \r
 \r
                                #define Endpoint_StallTransaction()           MACROS{ UECONX |= (1 << STALLRQ); }MACROE\r
 \r
                        bool Endpoint_ConfigureEndpoint(const uint8_t  Number, const uint8_t Type, const uint8_t Direction,\r
                                                        const uint16_t Size, const uint8_t Banks);\r
 \r
                        bool Endpoint_ConfigureEndpoint(const uint8_t  Number, const uint8_t Type, const uint8_t Direction,\r
                                                        const uint16_t Size, const uint8_t Banks);\r
 \r
+                       #if !defined(CONTROL_ONLY_DEVICE)\r
+\r
                        /** Spinloops until the currently selected non-control endpoint is ready for the next packet of data\r
                         *  to be read or written to it.\r
                         *\r
                        /** Spinloops until the currently selected non-control endpoint is ready for the next packet of data\r
                         *  to be read or written to it.\r
                         *\r
                        #endif\r
                                                        ) ATTR_NON_NULL_PTR_ARG(1);\r
 \r
                        #endif\r
                                                        ) ATTR_NON_NULL_PTR_ARG(1);\r
 \r
+                       #endif\r
+\r
                        /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,\r
                         *  sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared\r
                         *  in both failure and success states; the user is responsible for manually clearing the setup OUT to\r
                        /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,\r
                         *  sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared\r
                         *  in both failure and success states; the user is responsible for manually clearing the setup OUT to\r
index 4df8eee..3994e2f 100644 (file)
@@ -162,7 +162,7 @@ void USB_ResetInterface(void)
        USB_RemoteWakeupEnabled  = false;\r
        USB_CurrentlySelfPowered = false;\r
        #endif\r
        USB_RemoteWakeupEnabled  = false;\r
        USB_CurrentlySelfPowered = false;\r
        #endif\r
-               \r
+       \r
        if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
        {\r
                #if defined(USB_MODIFIED_FULL_CONTROLLER)\r
        if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
        {\r
                #if defined(USB_MODIFIED_FULL_CONTROLLER)\r
@@ -223,7 +223,12 @@ void USB_ResetInterface(void)
        \r
        #if defined(USB_DEVICE_ONLY)    \r
        USB_INT_Enable(USB_INT_SUSPEND);\r
        \r
        #if defined(USB_DEVICE_ONLY)    \r
        USB_INT_Enable(USB_INT_SUSPEND);\r
-       USB_INT_Enable(USB_INT_EORSTI); \r
+       USB_INT_Enable(USB_INT_EORSTI);\r
+\r
+       #if defined(CONTROL_ONLY_DEVICE)\r
+       UENUM = ENDPOINT_CONTROLEP;\r
+       #endif\r
+               \r
        #elif defined(USB_HOST_ONLY)\r
        USB_Host_HostMode_On();\r
        \r
        #elif defined(USB_HOST_ONLY)\r
        USB_Host_HostMode_On();\r
        \r
@@ -240,6 +245,10 @@ void USB_ResetInterface(void)
        {\r
                USB_INT_Enable(USB_INT_SUSPEND);\r
                USB_INT_Enable(USB_INT_EORSTI);\r
        {\r
                USB_INT_Enable(USB_INT_SUSPEND);\r
                USB_INT_Enable(USB_INT_EORSTI);\r
+\r
+               #if defined(CONTROL_ONLY_DEVICE)\r
+               UENUM = ENDPOINT_CONTROLEP;\r
+               #endif\r
        }\r
        else if (USB_CurrentMode == USB_MODE_HOST)\r
        {\r
        }\r
        else if (USB_CurrentMode == USB_MODE_HOST)\r
        {\r
index efec274..9dbabb7 100644 (file)
@@ -36,6 +36,7 @@
  *    - The USB_UnhandledControlPacket event no longer has any parameters. User code should no longer attempt to read in the remainder of\r
  *      the Control Request header as all Control Request header data is now preloaded by the library and made available in the\r
  *      USB_ControlRequest structure.\r
  *    - The USB_UnhandledControlPacket event no longer has any parameters. User code should no longer attempt to read in the remainder of\r
  *      the Control Request header as all Control Request header data is now preloaded by the library and made available in the\r
  *      USB_ControlRequest structure.\r
+ *    - The FEATURELESS_CONTROL_ONLY_DEVICE token has been renamed to CONTROL_ONLY_DEVICE.\r
  *\r
  *  <b>Host Mode</b>\r
  *    - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0) to allow it to be used on\r
  *\r
  *  <b>Host Mode</b>\r
  *    - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0) to allow it to be used on\r