Fixed USB_RemoteWakeupEnabled flag never being set (the REMOTE WAKEUP Set Feature...
[pub/USBasp.git] / Demos / Device / AudioInput / AudioInput.c
index b0c0295..05094c2 100644 (file)
 \r
 #include "AudioInput.h"\r
 \r
-/* Project Tags, for reading out using the ButtLoad project */\r
-BUTTLOADTAG(ProjName,    "LUFA AudioIn 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
-       { Task: USB_USBTask          , TaskStatus: TASK_STOP },\r
-       { Task: USB_Audio_Task       , TaskStatus: TASK_STOP },\r
+       { .Task = USB_USBTask          , .TaskStatus = TASK_STOP },\r
+       { .Task = USB_Audio_Task       , .TaskStatus = TASK_STOP },\r
 };\r
 \r
 \r
@@ -95,7 +89,7 @@ EVENT_HANDLER(USB_Connect)
        UpdateStatus(Status_USBEnumerating);\r
 \r
        /* Sample reload timer initialization */\r
-       OCR0A   = (F_CPU / AUDIO_SAMPLE_FREQUENCY) - ((F_CPU % AUDIO_SAMPLE_FREQUENCY) == 0 ? 1 : 0);\r
+       OCR0A   = (F_CPU / AUDIO_SAMPLE_FREQUENCY) - 1;\r
        TCCR0A  = (1 << WGM01);  // CTC mode\r
        TCCR0B  = (1 << CS00);   // Fcpu speed\r
 }\r
@@ -137,18 +131,16 @@ EVENT_HANDLER(USB_ConfigurationChanged)
 EVENT_HANDLER(USB_UnhandledControlPacket)\r
 {\r
        /* Process General and Audio specific control requests */\r
-       switch (bRequest)\r
+       switch (USB_ControlRequest.bRequest)\r
        {\r
                case REQ_SetInterface:\r
                        /* Set Interface is not handled by the library, as its function is application-specific */\r
-                       if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE))\r
+                       if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE))\r
                        {\r
-                               uint16_t wValue = Endpoint_Read_Word_LE();\r
-                               \r
-                               Endpoint_ClearSetupReceived();\r
+                               Endpoint_ClearSETUP();\r
                                \r
                                /* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */\r
-                               if (wValue)\r
+                               if (USB_ControlRequest.wValue)\r
                                {\r
                                        /* Start audio task */\r
                                        Scheduler_SetTaskMode(USB_Audio_Task, TASK_RUN);\r
@@ -160,8 +152,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                                }\r
                                \r
                                /* Acknowledge status stage */\r
-                               while (!(Endpoint_IsSetupINReady()));\r
-                               Endpoint_ClearSetupIN();\r
+                               while (!(Endpoint_IsINReady()));\r
+                               Endpoint_ClearIN();\r
                        }\r
 \r
                        break;\r
@@ -201,8 +193,8 @@ TASK(USB_Audio_Task)
        /* Select the audio stream endpoint */\r
        Endpoint_SelectEndpoint(AUDIO_STREAM_EPNUM);\r
        \r
-       /* Check if the current endpoint can be read from (contains a packet) and that the next sample should be stored */\r
-       if (Endpoint_ReadWriteAllowed() && (TIFR0 & (1 << OCF0A)))\r
+       /* Check if the current endpoint can be written to and that the next sample should be stored */\r
+       if (Endpoint_IsINReady() && (TIFR0 & (1 << OCF0A)))\r
        {\r
                /* Clear the sample reload timer */\r
                TIFR0 |= (1 << OCF0A);\r
@@ -219,10 +211,10 @@ TASK(USB_Audio_Task)
                Endpoint_Write_Word_LE(AudioSample);\r
 \r
                /* Check to see if the bank is now full */\r
-               if (!(Endpoint_ReadWriteAllowed()))\r
+               if (!(Endpoint_IsReadWriteAllowed()))\r
                {\r
                        /* Send the full packet to the host */\r
-                       Endpoint_ClearCurrentBank();\r
+                       Endpoint_ClearIN();\r
                }\r
        }\r
 }\r