Removed specialized Endpoint_ClearControl* and Pipe_ClearControl* macros in favour...
[pub/lufa.git] / Demos / Device / Mouse / Mouse.c
index c066d42..0959a4a 100644 (file)
  \r
 #include "Mouse.h"\r
 \r
-/* Project Tags, for reading out using the ButtLoad project */\r
-BUTTLOADTAG(ProjName,    "LUFA Mouse App");\r
-BUTTLOADTAG(BuildTime,   __TIME__);\r
-BUTTLOADTAG(BuildDate,   __DATE__);\r
-BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);\r
-\r
 /* Scheduler Task List */\r
 TASK_LIST\r
 {\r
        #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
-       { Task: USB_USBTask          , TaskStatus: TASK_STOP },\r
+       { .Task = USB_USBTask          , .TaskStatus = TASK_STOP },\r
        #endif\r
        \r
        #if !defined(INTERRUPT_DATA_ENDPOINT)\r
-       { Task: USB_Mouse_Report     , TaskStatus: TASK_STOP },\r
+       { .Task = USB_Mouse_Report     , .TaskStatus = TASK_STOP },\r
        #endif\r
 };\r
 \r
@@ -66,7 +60,7 @@ bool UsingReportProtocol = true;
 uint8_t IdleCount = 0;\r
 \r
 /** Current Idle period remaining. When the IdleCount value is set, this tracks the remaining number of idle\r
- *  milliseconds. This is seperate to the IdleCount timer and is incremented and compared as the host may request \r
+ *  milliseconds. This is separate to the IdleCount timer and is incremented and compared as the host may request \r
  *  the current idle period via a Get Idle HID class request, thus its value must be preserved.\r
  */\r
 uint16_t IdleMSRemaining = 0;\r
@@ -145,7 +139,7 @@ EVENT_HANDLER(USB_Reset)
  */\r
 EVENT_HANDLER(USB_Disconnect)\r
 {\r
-       /* Stop running keyboard reporting and USB management tasks */\r
+       /* Stop running mouse reporting and USB management tasks */\r
        #if !defined(INTERRUPT_DATA_ENDPOINT)\r
        Scheduler_SetTaskMode(USB_Mouse_Report, TASK_STOP);\r
        #endif\r
@@ -212,7 +206,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                if (wLength > sizeof(MouseReportData))\r
                                  wLength = sizeof(MouseReportData);\r
 \r
-                               Endpoint_ClearSetupReceived();\r
+                               Endpoint_ClearSETUP();\r
        \r
                                /* Write the report data to the control endpoint */\r
                                Endpoint_Write_Control_Stream_LE(&MouseReportData, wLength);\r
@@ -221,24 +215,24 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                memset(&MouseReportData, 0, sizeof(MouseReportData));\r
 \r
                                /* Finalize the stream transfer to send the last packet or clear the host abort */\r
-                               Endpoint_ClearSetupOUT();\r
+                               Endpoint_ClearOUT();\r
                        }\r
                \r
                        break;\r
                case REQ_GetProtocol:\r
                        if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
-                               Endpoint_ClearSetupReceived();\r
+                               Endpoint_ClearSETUP();\r
                                \r
                                /* Write the current protocol flag to the host */\r
                                Endpoint_Write_Byte(UsingReportProtocol);\r
                                \r
                                /* Send the flag to the host */\r
-                               Endpoint_ClearSetupIN();\r
+                               Endpoint_ClearIN();\r
 \r
                                /* Acknowledge status stage */\r
-                               while (!(Endpoint_IsSetupOUTReceived()));\r
-                               Endpoint_ClearSetupOUT();\r
+                               while (!(Endpoint_IsOUTReceived()));\r
+                               Endpoint_ClearOUT();\r
                        }\r
                        \r
                        break;\r
@@ -248,14 +242,14 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Read in the wValue parameter containing the new protocol mode */\r
                                uint16_t wValue = Endpoint_Read_Word_LE();\r
                                \r
-                               Endpoint_ClearSetupReceived();\r
+                               Endpoint_ClearSETUP();\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
                                /* Acknowledge status stage */\r
-                               while (!(Endpoint_IsSetupINReady()));\r
-                               Endpoint_ClearSetupIN();\r
+                               while (!(Endpoint_IsINReady()));\r
+                               Endpoint_ClearIN();\r
                        }\r
                        \r
                        break;\r
@@ -265,31 +259,31 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                /* Read in the wValue parameter containing the idle period */\r
                                uint16_t wValue = Endpoint_Read_Word_LE();\r
                                \r
-                               Endpoint_ClearSetupReceived();\r
+                               Endpoint_ClearSETUP();\r
                                \r
                                /* Get idle period in MSB */\r
                                IdleCount = (wValue >> 8);\r
                                \r
                                /* Acknowledge status stage */\r
-                               while (!(Endpoint_IsSetupINReady()));\r
-                               Endpoint_ClearSetupIN();\r
+                               while (!(Endpoint_IsINReady()));\r
+                               Endpoint_ClearIN();\r
                        }\r
                        \r
                        break;\r
                case REQ_GetIdle:\r
                        if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {               \r
-                               Endpoint_ClearSetupReceived();\r
+                               Endpoint_ClearSETUP();\r
                                \r
                                /* Write the current idle duration to the host */\r
                                Endpoint_Write_Byte(IdleCount);\r
                                \r
                                /* Send the flag to the host */\r
-                               Endpoint_ClearSetupIN();\r
+                               Endpoint_ClearIN();\r
 \r
                                /* Acknowledge status stage */\r
-                               while (!(Endpoint_IsSetupOUTReceived()));\r
-                               Endpoint_ClearSetupOUT();\r
+                               while (!(Endpoint_IsOUTReceived()));\r
+                               Endpoint_ClearOUT();\r
                        }\r
 \r
                        break;\r
@@ -367,13 +361,13 @@ static inline void SendNextReport(void)
        Endpoint_SelectEndpoint(MOUSE_EPNUM);\r
 \r
        /* Check if Mouse Endpoint Ready for Read/Write and if we should send a new report */\r
-       if (Endpoint_ReadWriteAllowed() && SendReport)\r
+       if (Endpoint_IsReadWriteAllowed() && SendReport)\r
        {\r
                /* Write Mouse Report Data */\r
                Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData));\r
                \r
                /* Finalize the stream transfer to send the last packet */\r
-               Endpoint_ClearCurrentBank();\r
+               Endpoint_ClearIN();\r
        }\r
 }\r
 \r