aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-07-30 14:06:52 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-07-30 14:06:52 +0000
commit41babf1cb78a2a8e05f40f5de61c3f52bb794fc4 (patch)
tree0ad2a05c55c83817a9cfefa6c2b68cd6ae0324d5 /LUFA
parent41b54a2acd2d5515cc7f3f1ed1c3d3b17d1988a1 (diff)
downloadlufa-41babf1cb78a2a8e05f40f5de61c3f52bb794fc4.tar.gz
lufa-41babf1cb78a2a8e05f40f5de61c3f52bb794fc4.tar.bz2
lufa-41babf1cb78a2a8e05f40f5de61c3f52bb794fc4.zip
Fix incorrect configuration in the ClassDriver AudioOutput demo.
Make all audio device Class Driver functions require a reference to the Audio class instance, so that the endpoint size can be checked (and to standardize the APIs). Make LEDs more responsive in the AudioOutput device demos.
Diffstat (limited to 'LUFA')
-rw-r--r--LUFA/Drivers/USB/Class/Device/Audio.c32
-rw-r--r--LUFA/Drivers/USB/Class/Device/Audio.h20
-rw-r--r--LUFA/ManPages/ChangeLog.txt32
3 files changed, 49 insertions, 35 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/Audio.c b/LUFA/Drivers/USB/Class/Device/Audio.c
index b018d6686..210a3c800 100644
--- a/LUFA/Drivers/USB/Class/Device/Audio.c
+++ b/LUFA/Drivers/USB/Class/Device/Audio.c
@@ -89,75 +89,81 @@ void Audio_Device_USBTask(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo
}
-int8_t Audio_Device_ReadSample8(void)
+int8_t Audio_Device_ReadSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)
{
int8_t Sample;
Sample = Endpoint_Read_Byte();
- if (!(Endpoint_IsReadWriteAllowed()))
+ if (!(Endpoint_BytesInEndpoint()))
Endpoint_ClearOUT();
return Sample;
}
-int16_t Audio_Device_ReadSample16(void)
+int16_t Audio_Device_ReadSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)
{
int16_t Sample;
Sample = (int16_t)Endpoint_Read_Word_LE();
- if (!(Endpoint_IsReadWriteAllowed()))
+ if (!(Endpoint_BytesInEndpoint()))
Endpoint_ClearOUT();
return Sample;
}
-int32_t Audio_Device_ReadSample24(void)
+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_IsReadWriteAllowed()))
+ if (!(Endpoint_BytesInEndpoint()))
Endpoint_ClearOUT();
return Sample;
}
-void Audio_Device_WriteSample8(const int8_t Sample)
+void Audio_Device_WriteSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, const int8_t Sample)
{
Endpoint_Write_Byte(Sample);
- if (!(Endpoint_IsReadWriteAllowed()))
+ if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpointSize)
Endpoint_ClearIN();
}
-void Audio_Device_WriteSample16(const int16_t Sample)
+void Audio_Device_WriteSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, const int16_t Sample)
{
Endpoint_Write_Word_LE(Sample);
- if (!(Endpoint_IsReadWriteAllowed()))
+ if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpointSize)
Endpoint_ClearIN();
}
-void Audio_Device_WriteSample24(const int32_t Sample)
+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_IsReadWriteAllowed()))
+ if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpointSize)
Endpoint_ClearIN();
}
bool Audio_Device_IsSampleReceived(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)
{
- Endpoint_SelectEndpoint(AudioInterfaceInfo->Config.DataOUTEndpointNumber);
+ if ((USB_DeviceState != DEVICE_STATE_Configured) || !(AudioInterfaceInfo->State.InterfaceEnabled))
+ return false;
+
+ Endpoint_SelectEndpoint(AudioInterfaceInfo->Config.DataOUTEndpointNumber);
return Endpoint_IsOUTReceived();
}
bool Audio_Device_IsReadyForNextSample(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)
{
+ if ((USB_DeviceState != DEVICE_STATE_Configured) || !(AudioInterfaceInfo->State.InterfaceEnabled))
+ return false;
+
Endpoint_SelectEndpoint(AudioInterfaceInfo->Config.DataINEndpointNumber);
return Endpoint_IsINReady();
}
diff --git a/LUFA/Drivers/USB/Class/Device/Audio.h b/LUFA/Drivers/USB/Class/Device/Audio.h
index eef7f9049..2c91dae7c 100644
--- a/LUFA/Drivers/USB/Class/Device/Audio.h
+++ b/LUFA/Drivers/USB/Class/Device/Audio.h
@@ -125,54 +125,62 @@
* \note This should be preceeded immediately by a call to the USB_Audio_IsSampleReceived() function to ensure that
* the correct endpoint is selected and ready for data.
*
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
+ *
* \return Signed 8-bit audio sample from the audio interface
*/
- int8_t Audio_Device_ReadSample8(void);
+ int8_t Audio_Device_ReadSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo);
/** Reads the next 16-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
* the correct endpoint is selected and ready for data.
*
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
+ *
* \return Signed 16-bit audio sample from the audio interface
*/
- int16_t Audio_Device_ReadSample16(void);
+ int16_t Audio_Device_ReadSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo);
/** Reads the next 24-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
* the correct endpoint is selected and ready for data.
*
+ * \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(void);
+ int32_t Audio_Device_ReadSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo);
/** Writes the next 8-bit audio sample to the current audio interface.
*
* \note This should be preceeded immediately by a call to the USB_Audio_IsReadyForNextSample() function to ensure that
* the correct endpoint is selected and ready for data.
*
+ * \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(const int8_t Sample);
+ void Audio_Device_WriteSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, const int8_t Sample);
/** Writes the next 16-bit audio sample to the current audio interface.
*
* \note This should be preceeded immediately by a call to the USB_Audio_IsReadyForNextSample() function to ensure that
* the correct endpoint is selected and ready for data.
*
+ * \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(const int16_t Sample);
+ void Audio_Device_WriteSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, const int16_t Sample);
/** Writes the next 24-bit audio sample to the current audio interface.
*
* \note This should be preceeded immediately by a call to the USB_Audio_IsReadyForNextSample() function to ensure that
* the correct endpoint is selected and ready for data.
*
+ * \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(const int32_t Sample);
+ void Audio_Device_WriteSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, const int32_t Sample);
/** Determines if the given audio interface is ready for a sample to be read from it.
*
diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt
index 02146a20a..813a5b45d 100644
--- a/LUFA/ManPages/ChangeLog.txt
+++ b/LUFA/ManPages/ChangeLog.txt
@@ -10,52 +10,52 @@
*
* <b>New:</b>
* - Added new class drivers and matching demos to the library for rapid application development
+ * - Added new PrinterHost demo (thanks to John Andrews)
+ * - Added USB Missle Launcher project, submitted by Dave Fletcher
+ * - Added new Benito Arduino Programmer project
* - Added incomplete device and host mode demos for later enhancement
+ * - Updated MassStorage device block write routines to use ping-pong Dataflash buffering to increase throughput by around 30%
* - Error status LEDs shown when device endpoint configuration fails to complete in all demos and projects
* - Added new USB_Host_SetDeviceConfiguration() convenience function for easy configuration selection of devices while in USB
* host mode
* - Added new USB_Host_ClearPipeStall() convenience function to clear a stall condition on an attached device's endpoint
* - Added new USB_Host_GetDeviceDescriptor() convenience function to retrieve the attached device's Device descriptor
- * - Added USB Missle Launcher project, submitted by Dave Fletcher
+ * - Added new Endpoint_ClearStatusStage() convenience function to assist with the status stages of control transfers
* - Added new USE_INTERNAL_SERIAL define for using the unique serial numbers in some AVR models as the USB device's serial number,
* added NO_INTERNAL_SERIAL compile time option to turn off new serial number reading code
* - Added new DATAFLASH_CHIP_MASK() macro to the Dataflash driver, which returns the Dataflash select mask for the given chip index
- * - Updated MassStorage device block write routines to use ping-pong Dataflash buffering to increase throughput by around 30%
* - Added new HOST_STATE_WaitForDeviceRemoval host state machine state for non-blocking disabling of device communications until the
* device has been removed (for use when an error occurs or communications with the device have completed)
* - Added new FAST_STREAM_TRANSFERS compile time option for faster stream transfers via multiple bytes copied per stream loop
- * - Added stdio stream demo code to the low-level CDC demo, to show how to create standard streams out of the virtual serial ports
+ * - Added stdio stream demo code to the CDC device demos, to show how to create standard streams out of the virtual serial ports
* - Added new EEPROM and FLASH buffer versions of the Endpoint and Pipe stream functions
* - Added new USE_FLASH_DESCRIPTORS and TOTAL_NUM_CONFIGURATIONS compile time options
* - Added support for the new ATMEGA32U2, ATMEGA16U2 and ATMEGA8U2 AVR models
- * - Added new PrinterHost demo (thanks to John Andrews)
* - Added new USB_DeviceState variable to keep track of the current Device mode USB state
- * - Added new Endpoint_ClearStatusStage() convenience function to assist with the status stages of control transfers
- * - Added new Benito Arduino Programmer project
* - Added new LEDs_ToggleLEDs() function to the LEDs driver
* - Added new Pipe_BoundEndpointNumber() and Pipe_IsEndpointBound() functions
* - Added new DEVICE_STATE_AS_GPIOR and HOST_STATE_AS_GPIOR compile time options
- * - Added 404 errors to the Webserver in the RNDIS demos to indicate invalid URLs
+ * - Added 404 Not Found errors to the webserver in the RNDIS demos to indicate invalid URLs
*
* <b>Changed:</b>
* - Deprecated psuedo-scheduler and removed dynamic memory allocator from the library (first no longer needed and second unused)
+ * - The device-mode CALLBACK_USB_GetDescriptor() function now has an extra parameter so that the memory space in which the requested
+ * descriptor is located can be specified. This means that descriptors can now be located in multiple memory spaces within a device.
+ * - Removed vague USB_IsConnected global - test USB_DeviceState or USB_HostState explicitly to gain previous functionality
+ * - Removed USB_IsSuspended global - test USB_DeviceState against DEVICE_STATE_Suspended instead
+ * - Extended USB_GetDeviceConfigDescriptor() routine to require the configuration number within the device to fetch
+ * - Dataflash_WaitWhileBusy() now always ensures that the dataflash is ready for the next command immediately after returning,
+ * no need to call Dataflash_ToggleSelectedChipCS() afterwards
* - Low level API MIDI device demo no longer blocks if a note change event is sent while the endpoint is not ready
- * - Internal per-device preprocessing conditions changed to per-device series rather than per controller group for finer-grain
- * internal control
* - Pipe_GetErrorFlags() now returns additional error flags for overflow and underflow errors
- * - Extended USB_GetDeviceConfigDescriptor() routine to require the configuration number within the device to fetch
* - Pipe stream functions now automatically set the correct pipe token, so that bidirectional pipes can be used
* - Pipe_ConfigurePipe() now automatically defaults IN pipes to accepting infinite IN requests, this can still be changed by calling
* the existing Pipe_SetFiniteINRequests() function
- * - Dataflash_WaitWhileBusy() now always ensures that the dataflash is ready for the next command immediately after returning,
- * no need to call Dataflash_ToggleSelectedChipCS() afterwards
* - Changed F_CLOCK entries in project makefiles to alias to F_CPU by default, as this is the most common case
- * - The device-mode CALLBACK_USB_GetDescriptor() function now has an extra parameter so that the memory space in which the requested
- * descriptor is located can be specified. This means that descriptors can now be located in multiple memory spaces within a device.
* - Host mode demos now use sane terminal escape codes, so that text is always readable and events/program output is visually distinguished
* from oneanother using foreground colours
- * - Removed vague USB_IsConnected global - test USB_DeviceState or USB_HostState explicitly to gain previous functionality
- * - Removed USB_IsSuspended global - test USB_DeviceState against DEVICE_STATE_Suspended instead
+ * - Internal per-device preprocessing conditions changed to per-device series rather than per-controller group for finer-grain
+ * internal control
*
* <b>Fixed:</b>
* - Changed bootloaders to use FLASHEND rather than the existence of RAMPZ to determine if far FLASH pointers are needed to fix