X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/ecaf872177e771b6b7e331b47a5b68832b5dd126..59becad82f18c158063ef450d65fefa332857e86:/Demos/Device/AudioInput/AudioInput.c diff --git a/Demos/Device/AudioInput/AudioInput.c b/Demos/Device/AudioInput/AudioInput.c index fca24c360..ecd8cdda8 100644 --- a/Demos/Device/AudioInput/AudioInput.c +++ b/Demos/Device/AudioInput/AudioInput.c @@ -36,17 +36,11 @@ #include "AudioInput.h" -/* Project Tags, for reading out using the ButtLoad project */ -BUTTLOADTAG(ProjName, "LUFA AudioIn App"); -BUTTLOADTAG(BuildTime, __TIME__); -BUTTLOADTAG(BuildDate, __DATE__); -BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING); - /* Scheduler Task List */ TASK_LIST { - { Task: USB_USBTask , TaskStatus: TASK_STOP }, - { Task: USB_Audio_Task , TaskStatus: TASK_STOP }, + { .Task = USB_USBTask , .TaskStatus = TASK_STOP }, + { .Task = USB_Audio_Task , .TaskStatus = TASK_STOP }, }; @@ -86,7 +80,7 @@ int main(void) /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs, and * configures the sample update and PWM timers. */ -EVENT_HANDLER(USB_Connect) +void EVENT_USB_Connect(void) { /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); @@ -103,7 +97,7 @@ EVENT_HANDLER(USB_Connect) /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs, disables the sample update and PWM output timers and stops the USB and Audio management tasks. */ -EVENT_HANDLER(USB_Disconnect) +void EVENT_USB_Disconnect(void) { /* Stop the sample reload timer */ TCCR0B = 0; @@ -119,7 +113,7 @@ EVENT_HANDLER(USB_Disconnect) /** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration * of the USB device after enumeration - the device endpoints are configured. */ -EVENT_HANDLER(USB_ConfigurationChanged) +void EVENT_USB_ConfigurationChanged(void) { /* Setup audio stream endpoint */ Endpoint_ConfigureEndpoint(AUDIO_STREAM_EPNUM, EP_TYPE_ISOCHRONOUS, @@ -134,21 +128,19 @@ EVENT_HANDLER(USB_ConfigurationChanged) * control requests that are not handled internally by the USB library (including the Audio class-specific * requests) so that they can be handled appropriately for the application. */ -EVENT_HANDLER(USB_UnhandledControlPacket) +void EVENT_USB_UnhandledControlPacket(void) { /* Process General and Audio specific control requests */ - switch (bRequest) + switch (USB_ControlRequest.bRequest) { case REQ_SetInterface: /* Set Interface is not handled by the library, as its function is application-specific */ - if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE)) + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE)) { - uint16_t wValue = Endpoint_Read_Word_LE(); - - Endpoint_ClearSetupReceived(); + Endpoint_ClearSETUP(); /* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */ - if (wValue) + if (USB_ControlRequest.wValue) { /* Start audio task */ Scheduler_SetTaskMode(USB_Audio_Task, TASK_RUN); @@ -160,8 +152,8 @@ EVENT_HANDLER(USB_UnhandledControlPacket) } /* Acknowledge status stage */ - while (!(Endpoint_IsSetupINReady())); - Endpoint_ClearSetupIN(); + while (!(Endpoint_IsINReady())); + Endpoint_ClearIN(); } break; @@ -201,8 +193,8 @@ TASK(USB_Audio_Task) /* Select the audio stream endpoint */ Endpoint_SelectEndpoint(AUDIO_STREAM_EPNUM); - /* Check if the current endpoint can be read from (contains a packet) and that the next sample should be stored */ - if (Endpoint_ReadWriteAllowed() && (TIFR0 & (1 << OCF0A))) + /* Check if the current endpoint can be written to and that the next sample should be stored */ + if (Endpoint_IsINReady() && (TIFR0 & (1 << OCF0A))) { /* Clear the sample reload timer */ TIFR0 |= (1 << OCF0A); @@ -219,10 +211,10 @@ TASK(USB_Audio_Task) Endpoint_Write_Word_LE(AudioSample); /* Check to see if the bank is now full */ - if (!(Endpoint_ReadWriteAllowed())) + if (!(Endpoint_IsReadWriteAllowed())) { /* Send the full packet to the host */ - Endpoint_ClearCurrentBank(); + Endpoint_ClearIN(); } } }