Fixed incorrect/missing control status stage transfers on demos, bootloaders and...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 10 Mar 2009 05:56:17 +0000 (05:56 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 10 Mar 2009 05:56:17 +0000 (05:56 +0000)
23 files changed:
Bootloaders/CDC/BootloaderCDC.c
Bootloaders/DFU/BootloaderDFU.c
Bootloaders/TeensyHID/TeensyHID.c
Demos/AudioInput/AudioInput.c
Demos/AudioOutput/AudioOutput.c
Demos/CDC/CDC.c
Demos/DualCDC/DualCDC.c
Demos/Keyboard/Keyboard.c
Demos/KeyboardFullInt/KeyboardFullInt.c
Demos/KeyboardMouse/KeyboardMouse.c
Demos/KeyboardViaInt/KeyboardViaInt.c
Demos/MassStorage/MassStorage.c
Demos/Mouse/Mouse.c
Demos/MouseFullInt/MouseFullInt.c
Demos/MouseViaInt/MouseViaInt.c
Demos/USBtoSerial/USBtoSerial.c
LUFA/ChangeLog.txt
LUFA/Drivers/USB/LowLevel/Endpoint.h
LUFA/Drivers/USB/LowLevel/LowLevel.h
LUFA/Drivers/USB/LowLevel/Pipe.h
LUFA/MigrationInformation.txt
Projects/AVRISP_Programmer/AVRISP_Programmer.c
Projects/Magstripe/Magstripe.c

index 60fe4a4..0add977 100644 (file)
@@ -167,6 +167,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                \r
                                Endpoint_ClearSetupIN();\r
                                \r
                                \r
                                Endpoint_ClearSetupIN();\r
                                \r
+                               /* Acknowledge status stage */\r
                                while (!(Endpoint_IsSetupOUTReceived()));\r
                                Endpoint_ClearSetupOUT();\r
                        }\r
                                while (!(Endpoint_IsSetupOUTReceived()));\r
                                Endpoint_ClearSetupOUT();\r
                        }\r
@@ -184,6 +185,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
 \r
                                Endpoint_ClearSetupOUT();\r
 \r
 \r
                                Endpoint_ClearSetupOUT();\r
 \r
+                               /* Acknowledge status stage */\r
                                while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                                while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
@@ -194,6 +196,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                        {\r
                                Endpoint_ClearSetupReceived();\r
                                \r
                        {\r
                                Endpoint_ClearSetupReceived();\r
                                \r
+                               /* Acknowledge status stage */\r
                                while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                                while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
index 8cc5fd4..9fff20c 100644 (file)
@@ -57,7 +57,7 @@ bool RunBootloader = true;
 \r
 /** Flag to indicate if the bootloader is waiting to exit. When the host requests the bootloader to exit and\r
  *  jump to the application address it specifies, it sends two sequential commands which must be properly\r
 \r
 /** Flag to indicate if the bootloader is waiting to exit. When the host requests the bootloader to exit and\r
  *  jump to the application address it specifies, it sends two sequential commands which must be properly\r
- *  acknowedged. Upon reception of the first the RunBootloader flag is cleared and the WaitForExit flag is set,\r
+ *  acknowledged. Upon reception of the first the RunBootloader flag is cleared and the WaitForExit flag is set,\r
  *  causing the bootloader to wait for the final exit command before shutting down.\r
  */\r
 bool WaitForExit = false;\r
  *  causing the bootloader to wait for the final exit command before shutting down.\r
  */\r
 bool WaitForExit = false;\r
@@ -305,7 +305,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
 \r
                        Endpoint_ClearSetupOUT();\r
 \r
 \r
                        Endpoint_ClearSetupOUT();\r
 \r
-                       /* Send ZLP to the host to acknowedge the request */\r
+                       /* Acknowledge status stage */\r
+                       while (!(Endpoint_IsSetupINReady()));\r
                        Endpoint_ClearSetupIN();\r
                                \r
                        break;\r
                        Endpoint_ClearSetupIN();\r
                                \r
                        break;\r
@@ -392,7 +393,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
 \r
                        Endpoint_ClearSetupIN();\r
 \r
 \r
                        Endpoint_ClearSetupIN();\r
 \r
-                       /* Send ZLP to the host to acknowedge the request */\r
+                       /* Acknowledge status stage */\r
                        while (!(Endpoint_IsSetupOUTReceived()));\r
                        Endpoint_ClearSetupOUT();\r
 \r
                        while (!(Endpoint_IsSetupOUTReceived()));\r
                        Endpoint_ClearSetupOUT();\r
 \r
@@ -415,6 +416,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
 \r
                        Endpoint_ClearSetupIN();\r
                        \r
 \r
                        Endpoint_ClearSetupIN();\r
                        \r
+                       /* Acknowledge status stage */\r
                        while (!(Endpoint_IsSetupOUTReceived()));\r
                        Endpoint_ClearSetupOUT();\r
        \r
                        while (!(Endpoint_IsSetupOUTReceived()));\r
                        Endpoint_ClearSetupOUT();\r
        \r
@@ -424,9 +426,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                        \r
                        /* Reset the status value variable to the default OK status */\r
                        DFU_Status = OK;\r
                        \r
                        /* Reset the status value variable to the default OK status */\r
                        DFU_Status = OK;\r
-                       \r
-                       Endpoint_ClearSetupIN();\r
 \r
 \r
+                       /* Acknowledge status stage */\r
+                       while (!(Endpoint_IsSetupINReady()));\r
+                       Endpoint_ClearSetupIN();\r
+                       \r
                        break;\r
                case DFU_GETSTATE:\r
                        Endpoint_ClearSetupReceived();\r
                        break;\r
                case DFU_GETSTATE:\r
                        Endpoint_ClearSetupReceived();\r
@@ -436,6 +440,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                \r
                        Endpoint_ClearSetupIN();\r
                        \r
                \r
                        Endpoint_ClearSetupIN();\r
                        \r
+                       /* Acknowledge status stage */\r
                        while (!(Endpoint_IsSetupOUTReceived()));\r
                        Endpoint_ClearSetupOUT();\r
 \r
                        while (!(Endpoint_IsSetupOUTReceived()));\r
                        Endpoint_ClearSetupOUT();\r
 \r
@@ -446,6 +451,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                        /* Reset the current state variable to the default idle state */\r
                        DFU_State = dfuIDLE;\r
                        \r
                        /* Reset the current state variable to the default idle state */\r
                        DFU_State = dfuIDLE;\r
                        \r
+                       /* Acknowledge status stage */\r
+                       while (!(Endpoint_IsSetupINReady()));\r
                        Endpoint_ClearSetupIN();\r
 \r
                        break;\r
                        Endpoint_ClearSetupIN();\r
 \r
                        break;\r
index fe20702..93f0621 100644 (file)
@@ -144,10 +144,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
 \r
                                Endpoint_ClearSetupOUT();\r
 \r
 \r
                                Endpoint_ClearSetupOUT();\r
 \r
-                               /* Wait until the host is ready to receive the request confirmation */\r
+                               /* Acknowledge status stage */\r
                                while (!(Endpoint_IsSetupINReady()));\r
                                while (!(Endpoint_IsSetupINReady()));\r
-                               \r
-                               /* Handshake the request by sending an empty IN packet */\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
index 0db41c3..6ead7a0 100644 (file)
@@ -163,7 +163,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                        Scheduler_SetTaskMode(USB_Audio_Task, TASK_STOP);                               \r
                                }\r
                                \r
                                        Scheduler_SetTaskMode(USB_Audio_Task, TASK_STOP);                               \r
                                }\r
                                \r
-                               /* Handshake the request */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
 \r
                                Endpoint_ClearSetupIN();\r
                        }\r
 \r
index 3d2e324..87afd36 100644 (file)
@@ -193,7 +193,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                        Scheduler_SetTaskMode(USB_Audio_Task, TASK_STOP);                               \r
                                }\r
                                \r
                                        Scheduler_SetTaskMode(USB_Audio_Task, TASK_STOP);                               \r
                                }\r
                                \r
-                               /* Handshake the request */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
 \r
                                Endpoint_ClearSetupIN();\r
                        }\r
 \r
@@ -249,7 +250,7 @@ TASK(USB_Audio_Task)
                /* Check to see if the bank is now empty */\r
                if (!(Endpoint_ReadWriteAllowed()))\r
                {\r
                /* Check to see if the bank is now empty */\r
                if (!(Endpoint_ReadWriteAllowed()))\r
                {\r
-                       /* Acknowedge the packet, clear the bank ready for the next packet */\r
+                       /* Acknowledge the packet, clear the bank ready for the next packet */\r
                        Endpoint_ClearCurrentBank();\r
                }\r
 \r
                        Endpoint_ClearCurrentBank();\r
                }\r
 \r
index eeae625..6e933d5 100644 (file)
@@ -171,7 +171,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_GetLineEncoding:\r
                        if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {       \r
                case REQ_GetLineEncoding:\r
                        if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {       \r
-                               /* Acknowedge the SETUP packet, ready for data transfer */\r
+                               /* Acknowledge the SETUP packet, ready for data transfer */\r
                                Endpoint_ClearSetupReceived();\r
 \r
                                /* Write the line coding data to the control endpoint */\r
                                Endpoint_ClearSetupReceived();\r
 \r
                                /* Write the line coding data to the control endpoint */\r
@@ -185,7 +185,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_SetLineEncoding:\r
                        if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
                case REQ_SetLineEncoding:\r
                        if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
-                               /* Acknowedge the SETUP packet, ready for data transfer */\r
+                               /* Acknowledge the SETUP packet, ready for data transfer */\r
                                Endpoint_ClearSetupReceived();\r
 \r
                                /* Read the line coding data in from the host into the global struct */\r
                                Endpoint_ClearSetupReceived();\r
 \r
                                /* Read the line coding data in from the host into the global struct */\r
@@ -210,10 +210,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                // Do something with the given line states in wIndex\r
 #endif\r
                                \r
                                // Do something with the given line states in wIndex\r
 #endif\r
                                \r
-                               /* Acknowedge the SETUP packet, ready for data transfer */\r
+                               /* Acknowledge the SETUP packet, ready for data transfer */\r
                                Endpoint_ClearSetupReceived();\r
                                \r
                                Endpoint_ClearSetupReceived();\r
                                \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
        \r
index 8e6e389..3c598da 100644 (file)
@@ -209,7 +209,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_GetLineEncoding:\r
                        if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {       \r
                case REQ_GetLineEncoding:\r
                        if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {       \r
-                               /* Acknowedge the SETUP packet, ready for data transfer */\r
+                               /* Acknowledge the SETUP packet, ready for data transfer */\r
                                Endpoint_ClearSetupReceived();\r
 \r
                                /* Write the line coding data to the control endpoint */\r
                                Endpoint_ClearSetupReceived();\r
 \r
                                /* Write the line coding data to the control endpoint */\r
@@ -223,7 +223,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_SetLineEncoding:\r
                        if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
                case REQ_SetLineEncoding:\r
                        if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
-                               /* Acknowedge the SETUP packet, ready for data transfer */\r
+                               /* Acknowledge the SETUP packet, ready for data transfer */\r
                                Endpoint_ClearSetupReceived();\r
 \r
                                /* Read the line coding data in from the host into the global struct */\r
                                Endpoint_ClearSetupReceived();\r
 \r
                                /* Read the line coding data in from the host into the global struct */\r
@@ -237,10 +237,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_SetControlLineState:\r
                        if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
                case REQ_SetControlLineState:\r
                        if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
-                               /* Acknowedge the SETUP packet, ready for data transfer */\r
+                               /* Acknowledge the SETUP packet, ready for data transfer */\r
                                Endpoint_ClearSetupReceived();\r
                                \r
                                Endpoint_ClearSetupReceived();\r
                                \r
-                               /* Send an empty packet to acknowedge the command (currently unused) */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
        \r
index 22d406d..931f080 100644 (file)
@@ -210,10 +210,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Clear the endpoint data */\r
                                Endpoint_ClearSetupOUT();\r
 \r
                                /* Clear the endpoint data */\r
                                Endpoint_ClearSetupOUT();\r
 \r
-                               /* Wait until the host is ready to receive the request confirmation */\r
+                               /* Acknowledge status stage */\r
                                while (!(Endpoint_IsSetupINReady()));\r
                                while (!(Endpoint_IsSetupINReady()));\r
-                               \r
-                               /* Handshake the request by sending an empty IN packet */\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -228,6 +226,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
+                               \r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupOUTReceived()));\r
+                               Endpoint_ClearSetupOUT();\r
                        }\r
                        \r
                        break;\r
                        }\r
                        \r
                        break;\r
@@ -242,7 +244,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
                                UsingReportProtocol = (wValue != 0x0000);\r
                                \r
                                /* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
                                UsingReportProtocol = (wValue != 0x0000);\r
                                \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -258,7 +261,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Get idle period in MSB */\r
                                IdleCount = (wValue >> 8);\r
                                \r
                                /* Get idle period in MSB */\r
                                IdleCount = (wValue >> 8);\r
                                \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -273,6 +277,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
+\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupOUTReceived()));\r
+                               Endpoint_ClearSetupOUT();\r
                        }\r
 \r
                        break;\r
                        }\r
 \r
                        break;\r
index ed08137..6a15a92 100644 (file)
@@ -212,10 +212,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Clear the endpoint data */\r
                                Endpoint_ClearSetupOUT();\r
 \r
                                /* Clear the endpoint data */\r
                                Endpoint_ClearSetupOUT();\r
 \r
-                               /* Wait until the host is ready to receive the request confirmation */\r
+                               /* Acknowledge status stage */\r
                                while (!(Endpoint_IsSetupINReady()));\r
                                while (!(Endpoint_IsSetupINReady()));\r
-                               \r
-                               /* Handshake the request by sending an empty IN packet */\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -230,6 +228,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
+\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupOUTReceived()));\r
+                               Endpoint_ClearSetupOUT();\r
                        }\r
                        \r
                        break;\r
                        }\r
                        \r
                        break;\r
@@ -244,7 +246,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
                                UsingReportProtocol = (wValue != 0x0000);\r
 \r
                                /* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
                                UsingReportProtocol = (wValue != 0x0000);\r
 \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -260,7 +263,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Get idle period in MSB */\r
                                IdleCount = (wValue >> 8);\r
                                \r
                                /* Get idle period in MSB */\r
                                IdleCount = (wValue >> 8);\r
                                \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -275,6 +279,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
+\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupOUTReceived()));\r
+                               Endpoint_ClearSetupOUT();\r
                        }\r
 \r
                        break;\r
                        }\r
 \r
                        break;\r
index 8108a30..3ee101b 100644 (file)
@@ -213,10 +213,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Clear the endpoint data */\r
                                Endpoint_ClearSetupOUT();\r
 \r
                                /* Clear the endpoint data */\r
                                Endpoint_ClearSetupOUT();\r
 \r
-                               /* Wait until the host is ready to receive the request confirmation */\r
+                               /* Acknowledge status stage */\r
                                while (!(Endpoint_IsSetupINReady()));\r
                                while (!(Endpoint_IsSetupINReady()));\r
-                               \r
-                               /* Handshake the request by sending an empty IN packet */\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
index b66506d..1e724e6 100644 (file)
@@ -211,10 +211,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Clear the endpoint data */\r
                                Endpoint_ClearSetupOUT();\r
 \r
                                /* Clear the endpoint data */\r
                                Endpoint_ClearSetupOUT();\r
 \r
-                               /* Wait until the host is ready to receive the request confirmation */\r
+                               /* Acknowledge status stage */\r
                                while (!(Endpoint_IsSetupINReady()));\r
                                while (!(Endpoint_IsSetupINReady()));\r
-                               \r
-                               /* Handshake the request by sending an empty IN packet */\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -229,6 +227,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
+\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupOUTReceived()));\r
+                               Endpoint_ClearSetupOUT();\r
                        }\r
                        \r
                        break;\r
                        }\r
                        \r
                        break;\r
@@ -243,7 +245,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
                                UsingReportProtocol = (wValue != 0x0000);\r
                                \r
                                /* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
                                UsingReportProtocol = (wValue != 0x0000);\r
                                \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -259,7 +262,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Get idle period in MSB */\r
                                IdleCount = (wValue >> 8);\r
                                \r
                                /* Get idle period in MSB */\r
                                IdleCount = (wValue >> 8);\r
                                \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -274,6 +278,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
+\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupOUTReceived()));\r
+                               Endpoint_ClearSetupOUT();\r
                        }\r
 \r
                        break;\r
                        }\r
 \r
                        break;\r
index 34fcee4..92e3307 100644 (file)
@@ -159,10 +159,13 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_MassStorageReset:\r
                        if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
                case REQ_MassStorageReset:\r
                        if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
-                               /* Indicate that the current transfer should be aborted */\r
-                               IsMassStoreReset = true;\r
-                       \r
                                Endpoint_ClearSetupReceived();\r
                                Endpoint_ClearSetupReceived();\r
+\r
+                               /* Indicate that the current transfer should be aborted */\r
+                               IsMassStoreReset = true;                        \r
+\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
 \r
                                Endpoint_ClearSetupIN();\r
                        }\r
 \r
@@ -171,9 +174,15 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                        if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
                                /* Indicate to the host the number of supported LUNs (virtual disks) on the device */\r
                        if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
                                /* Indicate to the host the number of supported LUNs (virtual disks) on the device */\r
-                               Endpoint_ClearSetupReceived();                  \r
+                               Endpoint_ClearSetupReceived();\r
+\r
                                Endpoint_Write_Byte(TOTAL_LUNS - 1);\r
                                Endpoint_Write_Byte(TOTAL_LUNS - 1);\r
+                               \r
                                Endpoint_ClearSetupIN();\r
                                Endpoint_ClearSetupIN();\r
+                               \r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupOUTReceived()));\r
+                               Endpoint_ClearSetupOUT();\r
                        }\r
                        \r
                        break;\r
                        }\r
                        \r
                        break;\r
index 3e59706..da8a4a8 100644 (file)
@@ -201,6 +201,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
+\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupOUTReceived()));\r
+                               Endpoint_ClearSetupOUT();\r
                        }\r
                        \r
                        break;\r
                        }\r
                        \r
                        break;\r
@@ -215,7 +219,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
                                UsingReportProtocol = (wValue != 0x0000);\r
                                \r
                                /* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
                                UsingReportProtocol = (wValue != 0x0000);\r
                                \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -231,7 +236,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Get idle period in MSB */\r
                                IdleCount = (wValue >> 8);\r
                                \r
                                /* Get idle period in MSB */\r
                                IdleCount = (wValue >> 8);\r
                                \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -246,6 +252,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
+\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupOUTReceived()));\r
+                               Endpoint_ClearSetupOUT();\r
                        }\r
 \r
                        break;\r
                        }\r
 \r
                        break;\r
index 98782b6..7e69d81 100644 (file)
@@ -200,6 +200,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
+\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupOUTReceived()));\r
+                               Endpoint_ClearSetupOUT();\r
                        }\r
                        \r
                        break;\r
                        }\r
                        \r
                        break;\r
@@ -214,7 +218,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
                                UsingReportProtocol = (wValue != 0x0000);\r
                                \r
                                /* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
                                UsingReportProtocol = (wValue != 0x0000);\r
                                \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -230,7 +235,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Get idle period in MSB */\r
                                IdleCount = (wValue >> 8);\r
                                \r
                                /* Get idle period in MSB */\r
                                IdleCount = (wValue >> 8);\r
                                \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -245,6 +251,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
+\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupOUTReceived()));\r
+                               Endpoint_ClearSetupOUT();\r
                        }\r
 \r
                        break;\r
                        }\r
 \r
                        break;\r
index 445fb49..465459a 100644 (file)
@@ -198,6 +198,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
+\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupOUTReceived()));\r
+                               Endpoint_ClearSetupOUT();\r
                        }\r
                        \r
                        break;\r
                        }\r
                        \r
                        break;\r
@@ -212,7 +216,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
                                UsingReportProtocol = (wValue != 0x0000);\r
                                \r
                                /* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
                                UsingReportProtocol = (wValue != 0x0000);\r
                                \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -228,7 +233,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Get idle period in MSB */\r
                                IdleCount = (wValue >> 8);\r
                                \r
                                /* Get idle period in MSB */\r
                                IdleCount = (wValue >> 8);\r
                                \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -243,6 +249,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
+\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupOUTReceived()));\r
+                               Endpoint_ClearSetupOUT();\r
                        }\r
 \r
                        break;\r
                        }\r
 \r
                        break;\r
index 0495826..c7c9e4b 100644 (file)
@@ -164,7 +164,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_GetLineEncoding:\r
                        if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {       \r
                case REQ_GetLineEncoding:\r
                        if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {       \r
-                               /* Acknowedge the SETUP packet, ready for data transfer */\r
+                               /* Acknowledge the SETUP packet, ready for data transfer */\r
                                Endpoint_ClearSetupReceived();\r
 \r
                                /* Write the line coding data to the control endpoint */\r
                                Endpoint_ClearSetupReceived();\r
 \r
                                /* Write the line coding data to the control endpoint */\r
@@ -178,7 +178,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_SetLineEncoding:\r
                        if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
                case REQ_SetLineEncoding:\r
                        if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
-                               /* Acknowedge the SETUP packet, ready for data transfer */\r
+                               /* Acknowledge the SETUP packet, ready for data transfer */\r
                                Endpoint_ClearSetupReceived();\r
 \r
                                /* Read the line coding data in from the host into the global struct */\r
                                Endpoint_ClearSetupReceived();\r
 \r
                                /* Read the line coding data in from the host into the global struct */\r
@@ -206,10 +206,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                // Do something with the given line states in wIndex\r
 #endif\r
                                \r
                                // Do something with the given line states in wIndex\r
 #endif\r
                                \r
-                               /* Acknowedge the SETUP packet, ready for data transfer */\r
+                               /* Acknowledge the SETUP packet, ready for data transfer */\r
                                Endpoint_ClearSetupReceived();\r
                                \r
                                Endpoint_ClearSetupReceived();\r
                                \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
        \r
index 1a2b9f8..d283d7f 100644 (file)
   *  - Function attribute ATTR_ALWAYSINLINE renamed to ATTR_ALWAYS_INLINE to match other function attribute macro naming conventions\r
   *  - Added ATTR_ALWAYS_INLINE attribute to several key inlined library components, to ensure they are inlined in all circumstances\r
   *  - Removed SetSystemClockPrescaler() macro, the clock_prescale_set() avr-libc macro has been corrected in recent avr-libc versions\r
   *  - Function attribute ATTR_ALWAYSINLINE renamed to ATTR_ALWAYS_INLINE to match other function attribute macro naming conventions\r
   *  - Added ATTR_ALWAYS_INLINE attribute to several key inlined library components, to ensure they are inlined in all circumstances\r
   *  - Removed SetSystemClockPrescaler() macro, the clock_prescale_set() avr-libc macro has been corrected in recent avr-libc versions\r
+  *  - Fixed incorrect/missing control status stage transfers on demos, bootloaders and applications (thanks to Nate Lawson)\r
   *\r
   *  \section Sec_ChangeLog090209 Version 090209\r
   *\r
   *  - PWM timer mode in AudioOut demo changed to Fast PWM for speed\r
   *  - Updated Magstripe project to work with the latest hardware revision\r
   *  - Fixed library not responding to the BCERRI flag correctly in host mode, leading to device lockups\r
   *\r
   *  \section Sec_ChangeLog090209 Version 090209\r
   *\r
   *  - PWM timer mode in AudioOut demo changed to Fast PWM for speed\r
   *  - Updated Magstripe project to work with the latest hardware revision\r
   *  - Fixed library not responding to the BCERRI flag correctly in host mode, leading to device lockups\r
-  *  - Fixed library handling Get Descriptor requests when not addressed as standard requests to the device or interface\r
+  *  - Fixed library handling Get Descriptor requests when not addressed as standard requests to the device or interface (thanks to\r
+  *    Nate Lawson)\r
   *  - Fixed serious data corruption issue in MassStorage demo dataflash write routine\r
   *  - Added new NO_CLEARSET_FEATURE_REQUEST compile time token\r
   *  - USB task now restores previous global interrupt state after execution, rather than forcing global interrupts to be enabled\r
   *  - Fixed serious data corruption issue in MassStorage demo dataflash write routine\r
   *  - Added new NO_CLEARSET_FEATURE_REQUEST compile time token\r
   *  - USB task now restores previous global interrupt state after execution, rather than forcing global interrupts to be enabled\r
   *  - Added Endpoint_Read_Stream, Endpoint_Write_Stream, Pipe_Read_Stream and Pipe_Write_Stream functions\r
   *    (including Big and Little Endian variants)\r
   *  - Made Dataflash functions inline for speed, removed now empty Dataflash.c driver file\r
   *  - Added Endpoint_Read_Stream, Endpoint_Write_Stream, Pipe_Read_Stream and Pipe_Write_Stream functions\r
   *    (including Big and Little Endian variants)\r
   *  - Made Dataflash functions inline for speed, removed now empty Dataflash.c driver file\r
-  *  - Added new SetSystemClockPrescaler() macro - thanks to Joerg Wunsch\r
+  *  - Added new SetSystemClockPrescaler() macro (thanks to Joerg Wunsch)\r
   *  - Fixed Endpoint_ClearStall() to function correctly on full USB controller AVRs (AT90USBXXX6/7)\r
   *  - Endpoint_Setup_In_Clear() and Endpoint_Setup_Out_Clear() no longer set FIFOCON, in line with the\r
   *    directives in the datasheet\r
   *  - Fixed Endpoint_ClearStall() to function correctly on full USB controller AVRs (AT90USBXXX6/7)\r
   *  - Endpoint_Setup_In_Clear() and Endpoint_Setup_Out_Clear() no longer set FIFOCON, in line with the\r
   *    directives in the datasheet\r
index d1ad131..1626686 100644 (file)
                        /** Sends an IN packet to the host on the currently selected CONTROL type endpoint. */\r
                        #define Endpoint_ClearSetupIN()               MACROS{ UEINTX &= ~(1 << TXINI); }MACROE\r
 \r
                        /** Sends an IN packet to the host on the currently selected CONTROL type endpoint. */\r
                        #define Endpoint_ClearSetupIN()               MACROS{ UEINTX &= ~(1 << TXINI); }MACROE\r
 \r
-                       /** Acknowedges an OUT packet to the host on the currently selected CONTROL type endpoint, freeing\r
+                       /** Acknowledges an OUT packet to the host on the currently selected CONTROL type endpoint, freeing\r
                         *  up the endpoint for the next packet.\r
                         */\r
                        #define Endpoint_ClearSetupOUT()              MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE\r
                         *  up the endpoint for the next packet.\r
                         */\r
                        #define Endpoint_ClearSetupOUT()              MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE\r
                                                        ) ATTR_NON_NULL_PTR_ARG(1);\r
 \r
                        /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,\r
                                                        ) ATTR_NON_NULL_PTR_ARG(1);\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 acknowedgement is not automatically cleared\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
                         *  finalize the transfer via the Endpoint_ClearSetupOUT() macro.\r
                         *\r
                         *  in both failure and success states; the user is responsible for manually clearing the setup OUT to\r
                         *  finalize the transfer via the Endpoint_ClearSetupOUT() macro.\r
                         *\r
                        uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
 \r
                        /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian,\r
                        uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
 \r
                        /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian,\r
-                        *  sending full packets to the host as needed. The host OUT acknowedgement is not automatically cleared\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
                         *  finalize the transfer via the Endpoint_ClearSetupOUT() macro.\r
                         *\r
                         *  in both failure and success states; the user is responsible for manually clearing the setup OUT to\r
                         *  finalize the transfer via the Endpoint_ClearSetupOUT() macro.\r
                         *\r
                        uint8_t Endpoint_Write_Control_Stream_BE(const void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
 \r
                        /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian,\r
                        uint8_t Endpoint_Write_Control_Stream_BE(const void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
 \r
                        /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian,\r
-                        *  discarding fully read packets from the host as needed. The device IN acknowedgement is not\r
+                        *  discarding fully read packets from the host as needed. The device IN acknowledgement is not\r
                         *  automatically sent after success or failure states; the user is responsible for manually sending the\r
                         *  setup IN to finalize the transfer via the Endpoint_ClearSetupIN() macro.\r
                         *\r
                         *  automatically sent after success or failure states; the user is responsible for manually sending the\r
                         *  setup IN to finalize the transfer via the Endpoint_ClearSetupIN() macro.\r
                         *\r
                        uint8_t Endpoint_Read_Control_Stream_LE(void* Buffer, uint16_t Length)  ATTR_NON_NULL_PTR_ARG(1);\r
 \r
                        /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian,\r
                        uint8_t Endpoint_Read_Control_Stream_LE(void* Buffer, uint16_t Length)  ATTR_NON_NULL_PTR_ARG(1);\r
 \r
                        /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian,\r
-                        *  discarding fully read packets from the host as needed. The device IN acknowedgement is not\r
+                        *  discarding fully read packets from the host as needed. The device IN acknowledgement is not\r
                         *  automatically sent after success or failure states; the user is responsible for manually sending the\r
                         *  setup IN to finalize the transfer via the Endpoint_ClearSetupIN() macro.\r
                         *\r
                         *  automatically sent after success or failure states; the user is responsible for manually sending the\r
                         *  setup IN to finalize the transfer via the Endpoint_ClearSetupIN() macro.\r
                         *\r
index 9721bac..98deaac 100644 (file)
                        #if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__)\r
                                /** Constant for the maximum software timeout period of the USB data stream transfer functions\r
                                 *  (both control and standard) when in either device or host mode. If the next packet of a stream\r
                        #if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__)\r
                                /** Constant for the maximum software timeout period of the USB data stream transfer functions\r
                                 *  (both control and standard) when in either device or host mode. If the next packet of a stream\r
-                                *  is not received or acknowedged within this time period, the stream function will fail.\r
+                                *  is not received or acknowledged within this time period, the stream function will fail.\r
                                 *\r
                                 *  This value may be overridden in the user project makefile as the value of the \r
                                 *  USB_STREAM_TIMEOUT_MS token, and passed to the compiler using the -D switch.\r
                                 *\r
                                 *  This value may be overridden in the user project makefile as the value of the \r
                                 *  USB_STREAM_TIMEOUT_MS token, and passed to the compiler using the -D switch.\r
index f7d10bc..5d4793e 100644 (file)
                         */\r
                        #define Pipe_IsSetupOUTReady()         ((UPINTX & (1 << TXOUTI)) ? true : false)\r
 \r
                         */\r
                        #define Pipe_IsSetupOUTReady()         ((UPINTX & (1 << TXOUTI)) ? true : false)\r
 \r
-                       /** Acknowedges the reception of a setup IN request from the attached device on the currently selected\r
+                       /** Acknowledges the reception of a setup IN request from the attached device on the currently selected\r
                         *  CONTROL type endpoint, allowing for the transmission of a setup OUT packet, or the reception of\r
                         *  another setup IN packet.\r
                         */\r
                         *  CONTROL type endpoint, allowing for the transmission of a setup OUT packet, or the reception of\r
                         *  another setup IN packet.\r
                         */\r
                        /** Sends the currently selected CONTROL type pipe's contents to the device as a setup OUT packet. */\r
                        #define Pipe_ClearSetupOUT()           MACROS{ UPINTX &= ~(1 << TXOUTI); UPINTX &= ~(1 << FIFOCON); }MACROE\r
                        \r
                        /** Sends the currently selected CONTROL type pipe's contents to the device as a setup OUT packet. */\r
                        #define Pipe_ClearSetupOUT()           MACROS{ UPINTX &= ~(1 << TXOUTI); UPINTX &= ~(1 << FIFOCON); }MACROE\r
                        \r
-                       /** Returns true if the device sent a NAK (Negative Acknowedge) in response to the last sent packet on\r
+                       /** Returns true if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on\r
                         *  the currently selected pipe. This ocurrs when the host sends a packet to the device, but the device\r
                         *  is not currently ready to handle the packet (i.e. its endpoint banks are full). Once a NAK has been\r
                         *  received, it must be cleard using Pipe_ClearNAKReceived() before the previous (or any other) packet\r
                         *  the currently selected pipe. This ocurrs when the host sends a packet to the device, but the device\r
                         *  is not currently ready to handle the packet (i.e. its endpoint banks are full). Once a NAK has been\r
                         *  received, it must be cleard using Pipe_ClearNAKReceived() before the previous (or any other) packet\r
index 364f09c..75b5d19 100644 (file)
@@ -22,6 +22,9 @@
  *\r
  *  <b>Library Demos</b>\r
  *    - The USBtoSerial demo now discards all data when not connected to a host, rather than buffering it for later transmission.\r
  *\r
  *  <b>Library Demos</b>\r
  *    - The USBtoSerial demo now discards all data when not connected to a host, rather than buffering it for later transmission.\r
+ *    - Most demos, bootloaders and applications have had their control request handling code corrected, to properly send the status\r
+ *      stage in all handled requests. If you are using code based off one of the library demos, bootloaders or applications, you should\r
+ *      update to the latest revisions.\r
  *\r
  *  <b>Non-USB Library Components</b>\r
  *    - The ATTR_ALWAYSINLINE function attribute macro has been renamed to ATTR_ALWAYS_INLINE.\r
  *\r
  *  <b>Non-USB Library Components</b>\r
  *    - The ATTR_ALWAYSINLINE function attribute macro has been renamed to ATTR_ALWAYS_INLINE.\r
index 4bc4f9c..5859367 100644 (file)
@@ -267,7 +267,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_GetLineEncoding:\r
                        if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {       \r
                case REQ_GetLineEncoding:\r
                        if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {       \r
-                               /* Acknowedge the SETUP packet, ready for data transfer */\r
+                               /* Acknowledge the SETUP packet, ready for data transfer */\r
                                Endpoint_ClearSetupReceived();\r
 \r
                                /* Write the line coding data to the control endpoint */\r
                                Endpoint_ClearSetupReceived();\r
 \r
                                /* Write the line coding data to the control endpoint */\r
@@ -281,7 +281,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_SetLineEncoding:\r
                        if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
                case REQ_SetLineEncoding:\r
                        if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
-                               /* Acknowedge the SETUP packet, ready for data transfer */\r
+                               /* Acknowledge the SETUP packet, ready for data transfer */\r
                                Endpoint_ClearSetupReceived();\r
 \r
                                /* Read the line coding data in from the host into the global struct */\r
                                Endpoint_ClearSetupReceived();\r
 \r
                                /* Read the line coding data in from the host into the global struct */\r
@@ -298,10 +298,11 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                case REQ_SetControlLineState:\r
                        if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
                case REQ_SetControlLineState:\r
                        if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
-                               /* Acknowedge the SETUP packet, ready for data transfer */\r
+                               /* Acknowledge the SETUP packet, ready for data transfer */\r
                                Endpoint_ClearSetupReceived();\r
                                \r
                                Endpoint_ClearSetupReceived();\r
                                \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
        \r
index 2826c14..0e10053 100644 (file)
@@ -204,6 +204,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
+\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupOUTReceived()));\r
+                               Endpoint_ClearSetupOUT();\r
                        }\r
                        \r
                        break;\r
                        }\r
                        \r
                        break;\r
@@ -218,7 +222,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
                                UsingReportProtocol = (wValue != 0x0000);\r
                                \r
                                /* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
                                UsingReportProtocol = (wValue != 0x0000);\r
                                \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -234,7 +239,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Get idle period in MSB */\r
                                IdleCount = (wValue >> 8);\r
                                \r
                                /* Get idle period in MSB */\r
                                IdleCount = (wValue >> 8);\r
                                \r
-                               /* Send an empty packet to acknowedge the command */\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupINReady()));\r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
                                Endpoint_ClearSetupIN();\r
                        }\r
                        \r
@@ -249,6 +255,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
                                \r
                                /* Send the flag to the host */\r
                                Endpoint_ClearSetupIN();\r
+\r
+                               /* Acknowledge status stage */\r
+                               while (!(Endpoint_IsSetupOUTReceived()));\r
+                               Endpoint_ClearSetupOUT();\r
                        }\r
 \r
                        break;\r
                        }\r
 \r
                        break;\r