diff --git a/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c b/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c index d7de7d5b01..a73f1c96e6 100644 --- a/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c +++ b/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c @@ -123,17 +123,15 @@ void ProcessNextSample(void) uint8_t LEDMask = LEDS_NO_LEDS; - if (MixedSample_8Bit_Abs > 2) - LEDMask |= LEDS_LED1; - - if (MixedSample_8Bit_Abs > 4) - LEDMask |= LEDS_LED2; - - if (MixedSample_8Bit_Abs > 8) - LEDMask |= LEDS_LED3; - + /* Turn on LEDs as the sample amplitude increases */ if (MixedSample_8Bit_Abs > 16) - LEDMask |= LEDS_LED4; + LEDMask = (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4); + else if (MixedSample_8Bit_Abs > 8) + LEDMask = (LEDS_LED1 | LEDS_LED2 | LEDS_LED3); + else if (MixedSample_8Bit_Abs > 4) + LEDMask = (LEDS_LED1 | LEDS_LED2); + else if (MixedSample_8Bit_Abs > 2) + LEDMask = (LEDS_LED1); LEDs_SetAllLEDs(LEDMask); } diff --git a/Demos/Device/ClassDriver/AudioOutput/makefile b/Demos/Device/ClassDriver/AudioOutput/makefile index ec60801be8..7ece3734bf 100644 --- a/Demos/Device/ClassDriver/AudioOutput/makefile +++ b/Demos/Device/ClassDriver/AudioOutput/makefile @@ -184,6 +184,7 @@ CSTANDARD = -std=gnu99 # Place -D or -U options here for C sources CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD) $(LUFA_OPTS) +CDEFS += -DAUDIO_OUT_STEREO # Place -D or -U options here for ASM sources diff --git a/Demos/Device/LowLevel/AudioOutput/AudioOutput.c b/Demos/Device/LowLevel/AudioOutput/AudioOutput.c index 1128e8f4e5..dd880b437d 100644 --- a/Demos/Device/LowLevel/AudioOutput/AudioOutput.c +++ b/Demos/Device/LowLevel/AudioOutput/AudioOutput.c @@ -230,17 +230,15 @@ void USB_Audio_Task(void) uint8_t LEDMask = LEDS_NO_LEDS; - if (MixedSample_8Bit_Abs > 2) - LEDMask |= LEDS_LED1; - - if (MixedSample_8Bit_Abs > 4) - LEDMask |= LEDS_LED2; - - if (MixedSample_8Bit_Abs > 8) - LEDMask |= LEDS_LED3; - + /* Turn on LEDs as the sample amplitude increases */ if (MixedSample_8Bit_Abs > 16) - LEDMask |= LEDS_LED4; + LEDMask = (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4); + else if (MixedSample_8Bit_Abs > 8) + LEDMask = (LEDS_LED1 | LEDS_LED2 | LEDS_LED3); + else if (MixedSample_8Bit_Abs > 4) + LEDMask = (LEDS_LED1 | LEDS_LED2); + else if (MixedSample_8Bit_Abs > 2) + LEDMask = (LEDS_LED1); LEDs_SetAllLEDs(LEDMask); } diff --git a/LUFA.pnproj b/LUFA.pnproj index d7c449ea1e..b7d248c0ae 100644 --- a/LUFA.pnproj +++ b/LUFA.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/LUFA/Drivers/Board/LEDs.h b/LUFA/Drivers/Board/LEDs.h index dcfa8f49ae..f710734d03 100644 --- a/LUFA/Drivers/Board/LEDs.h +++ b/LUFA/Drivers/Board/LEDs.h @@ -89,7 +89,7 @@ #elif (BOARD == BOARD_ATAVRUSBRF01) #include "ATAVRUSBRF01/LEDs.h" #elif (BOARD == BOARD_XPLAIN) - #include "XPLAIN/LEDs.h + #include "XPLAIN/LEDs.h" #elif (BOARD == BOARD_BUMBLEB) #include "BUMBLEB/LEDs.h" #elif (BOARD == BOARD_USER) diff --git a/LUFA/Drivers/USB/Class/Device/Audio.c b/LUFA/Drivers/USB/Class/Device/Audio.c index c4fbc3d9c9..337437c946 100644 --- a/LUFA/Drivers/USB/Class/Device/Audio.c +++ b/LUFA/Drivers/USB/Class/Device/Audio.c @@ -89,67 +89,6 @@ void Audio_Device_USBTask(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo } -int8_t Audio_Device_ReadSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) -{ - int8_t Sample; - - Sample = Endpoint_Read_Byte(); - - if (!(Endpoint_BytesInEndpoint())) - Endpoint_ClearOUT(); - - return Sample; -} - -int16_t Audio_Device_ReadSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) -{ - int16_t Sample; - - Sample = (int16_t)Endpoint_Read_Word_LE(); - - if (!(Endpoint_BytesInEndpoint())) - Endpoint_ClearOUT(); - - return Sample; -} - -int32_t Audio_Device_ReadSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) -{ - int32_t Sample; - - Sample = (((uint32_t)Endpoint_Read_Byte() << 16) | Endpoint_Read_Word_LE()); - - if (!(Endpoint_BytesInEndpoint())) - Endpoint_ClearOUT(); - - return Sample; -} - -void Audio_Device_WriteSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, const int8_t Sample) -{ - Endpoint_Write_Byte(Sample); - - if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpointSize) - Endpoint_ClearIN(); -} - -void Audio_Device_WriteSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, const int16_t Sample) -{ - Endpoint_Write_Word_LE(Sample); - - if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpointSize) - Endpoint_ClearIN(); -} - -void Audio_Device_WriteSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, const int32_t Sample) -{ - Endpoint_Write_Byte(Sample >> 16); - Endpoint_Write_Word_LE(Sample); - - if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpointSize) - Endpoint_ClearIN(); -} - bool Audio_Device_IsSampleReceived(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) { if ((USB_DeviceState != DEVICE_STATE_Configured) || !(AudioInterfaceInfo->State.InterfaceEnabled)) diff --git a/LUFA/Drivers/USB/Class/Device/Audio.h b/LUFA/Drivers/USB/Class/Device/Audio.h index 12a8acdd62..67699fdd12 100644 --- a/LUFA/Drivers/USB/Class/Device/Audio.h +++ b/LUFA/Drivers/USB/Class/Device/Audio.h @@ -120,6 +120,25 @@ */ void Audio_Device_USBTask(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + /** Determines if the given audio interface is ready for a sample to be read from it, and selects the streaming + * OUT endpoint ready for reading. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * + * \return Boolean true if the given Audio interface has a sample to be read, false otherwise + */ + bool Audio_Device_IsSampleReceived(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo); + + /** Determines if the given audio interface is ready to accept the next sample to be written to it, and selects + * the streaming IN endpoint ready for writing. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * + * \return Boolean true if the given Audio interface is ready to accept the next sample, false otherwise + */ + bool Audio_Device_IsReadyForNextSample(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo); + + /* Inline Functions: */ /** Reads the next 8-bit audio sample from the current audio interface. * * \note This should be preceeded immediately by a call to the USB_Audio_IsSampleReceived() function to ensure that @@ -129,7 +148,18 @@ * * \return Signed 8-bit audio sample from the audio interface */ - int8_t Audio_Device_ReadSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + static inline int8_t Audio_Device_ReadSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_ALWAYS_INLINE; + static inline int8_t Audio_Device_ReadSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) + { + int8_t Sample; + + Sample = Endpoint_Read_Byte(); + + if (!(Endpoint_BytesInEndpoint())) + Endpoint_ClearOUT(); + + return Sample; + } /** Reads the next 16-bit audio sample from the current audio interface. * @@ -140,7 +170,18 @@ * * \return Signed 16-bit audio sample from the audio interface */ - int16_t Audio_Device_ReadSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + static inline int16_t Audio_Device_ReadSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_ALWAYS_INLINE; + static inline int16_t Audio_Device_ReadSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) + { + int16_t Sample; + + Sample = (int16_t)Endpoint_Read_Word_LE(); + + if (!(Endpoint_BytesInEndpoint())) + Endpoint_ClearOUT(); + + return Sample; + } /** Reads the next 24-bit audio sample from the current audio interface. * @@ -150,7 +191,18 @@ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. * \return Signed 24-bit audio sample from the audio interface */ - int32_t Audio_Device_ReadSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + static inline int32_t Audio_Device_ReadSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_ALWAYS_INLINE; + static inline int32_t Audio_Device_ReadSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) + { + int32_t Sample; + + Sample = (((uint32_t)Endpoint_Read_Byte() << 16) | Endpoint_Read_Word_LE()); + + if (!(Endpoint_BytesInEndpoint())) + Endpoint_ClearOUT(); + + return Sample; + } /** Writes the next 8-bit audio sample to the current audio interface. * @@ -160,7 +212,16 @@ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. * \param[in] Sample Signed 8-bit audio sample */ - void Audio_Device_WriteSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, const int8_t Sample) ATTR_NON_NULL_PTR_ARG(1); + static inline void Audio_Device_WriteSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, + const int8_t Sample) ATTR_ALWAYS_INLINE; + static inline void Audio_Device_WriteSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, + const int8_t Sample) + { + Endpoint_Write_Byte(Sample); + + if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpointSize) + Endpoint_ClearIN(); + } /** Writes the next 16-bit audio sample to the current audio interface. * @@ -170,7 +231,16 @@ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. * \param[in] Sample Signed 16-bit audio sample */ - void Audio_Device_WriteSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, const int16_t Sample) ATTR_NON_NULL_PTR_ARG(1); + static inline void Audio_Device_WriteSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, + const int16_t Sample) ATTR_ALWAYS_INLINE; + static inline void Audio_Device_WriteSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, + const int16_t Sample) + { + Endpoint_Write_Word_LE(Sample); + + if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpointSize) + Endpoint_ClearIN(); + } /** Writes the next 24-bit audio sample to the current audio interface. * @@ -180,23 +250,17 @@ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. * \param[in] Sample Signed 24-bit audio sample */ - void Audio_Device_WriteSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, const int32_t Sample) ATTR_NON_NULL_PTR_ARG(1); + static inline void Audio_Device_WriteSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, + const int32_t Sample) ATTR_ALWAYS_INLINE; + static inline void Audio_Device_WriteSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, + const int32_t Sample) + { + Endpoint_Write_Byte(Sample >> 16); + Endpoint_Write_Word_LE(Sample); - /** Determines if the given audio interface is ready for a sample to be read from it. - * - * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. - * - * \return Boolean true if the given Audio interface has a sample to be read, false otherwise - */ - bool Audio_Device_IsSampleReceived(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); - - /** Determines if the given audio interface is ready to accept the next sample to be written to it. - * - * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. - * - * \return Boolean true if the given Audio interface is ready to accept the next sample, false otherwise - */ - bool Audio_Device_IsReadyForNextSample(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpointSize) + Endpoint_ClearIN(); + } /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) diff --git a/LUFA/Drivers/USB/Class/Host/HIDParser.c b/LUFA/Drivers/USB/Class/Host/HIDParser.c index 4d433e56e2..6b370af306 100644 --- a/LUFA/Drivers/USB/Class/Host/HIDParser.c +++ b/LUFA/Drivers/USB/Class/Host/HIDParser.c @@ -216,7 +216,8 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID case (TYPE_MAIN | TAG_MAIN_INPUT): case (TYPE_MAIN | TAG_MAIN_OUTPUT): case (TYPE_MAIN | TAG_MAIN_FEATURE): - for (uint8_t ReportItemNum = 0; ReportItemNum < CurrStateTable->ReportCount; ReportItemNum++) + uint8_t Count = CurrStateTable->ReportCount; + for (uint8_t ReportItemNum = 0; ReportItemNum < Count; ReportItemNum++) { HID_ReportItem_t NewReportItem; diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index 6023d53997..2e35e22b52 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -17,6 +17,8 @@ * - Removed mostly useless "TestApp" demo, as it was mainly useful only for checking for sytax errors in the library * - MIDI device demos now receive MIDI events from the host and display note ON messages via the board LEDs * - Cleanups to the Device mode Mass Storage demo applications' SCSI routines + * - Changed Audio Class driver sample read/write functions to be inline, to reduce the number of cycles needed to transfer + * samples to and from the device (allowing more time for processing and output) * * Fixed: * - Fixed PrinterHost demo returning invalid Device ID data when the attached device does not have a @@ -24,6 +26,7 @@ * - Changed LUFA_VERSION_INTEGER define to use BCD values, to make comparisons eaiser * - Fixed issue in the HID Host class driver's HID_Host_SendReportByID() routine using the incorrect mode (control/pipe) * to send report to the attached device + * - Fixed ClassDriver AudioOutput demo not selecting an audio output mode * * \section Sec_ChangeLog090924 Version 090924 * diff --git a/LUFA/ManPages/LUFAPoweredProjects.txt b/LUFA/ManPages/LUFAPoweredProjects.txt index 822f297979..4da3075244 100644 --- a/LUFA/ManPages/LUFAPoweredProjects.txt +++ b/LUFA/ManPages/LUFAPoweredProjects.txt @@ -40,6 +40,7 @@ * - NES Controller USB modification: http://projects.peterpolidoro.net/video/NESUSB.htm * - Reprap with LUFA, a LUFA powered 3D printer: http://code.google.com/p/at90usb1287-code-for-arduino-and-eclipse/ * - SEGA Megadrive/Genesis Development Cartridge: http://www.makestuff.eu/wordpress/?page_id=398 + * - SEGA Megadrive/Super Nintendo Cartridge Reader: http://www.snega2usb.com * - Stripe Snoop, a Magnetic Card reader: http://www.ossguy.com/ss_usb/ * - USB Interface for Playstation Portable Devices: http://forums.ps2dev.org/viewtopic.php?t=11001 * - Userial, a USB to Serial converter with SPI, I2C and other protocols: http://www.tty1.net/userial/