diff options
Diffstat (limited to 'usb/device/audio-looprec')
-rw-r--r-- | usb/device/audio-looprec/AUDDLoopRecChannel.c | 129 | ||||
-rw-r--r-- | usb/device/audio-looprec/AUDDLoopRecChannel.h | 92 | ||||
-rw-r--r-- | usb/device/audio-looprec/AUDDLoopRecDriver.c | 493 | ||||
-rw-r--r-- | usb/device/audio-looprec/AUDDLoopRecDriver.h | 163 | ||||
-rw-r--r-- | usb/device/audio-looprec/AUDDLoopRecDriverDescriptors.c | 1461 | ||||
-rw-r--r-- | usb/device/audio-looprec/AUDDLoopRecDriverDescriptors.h | 148 | ||||
-rw-r--r-- | usb/device/audio-looprec/audio-looprec.dir | 51 |
7 files changed, 2537 insertions, 0 deletions
diff --git a/usb/device/audio-looprec/AUDDLoopRecChannel.c b/usb/device/audio-looprec/AUDDLoopRecChannel.c new file mode 100644 index 0000000..c6d9a08 --- /dev/null +++ b/usb/device/audio-looprec/AUDDLoopRecChannel.c @@ -0,0 +1,129 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/*
+ Title: AUDDLoopRecChannel implementation
+
+ About: Purpose
+ Implementation of the AUDDLoopRecChannel functions.
+*/
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include "AUDDLoopRecChannel.h"
+#include <utility/trace.h>
+
+//------------------------------------------------------------------------------
+// Callbacks
+//------------------------------------------------------------------------------
+/*
+ Function: AUDDLoopRecChannel_MuteChanged
+ Callback triggered when the mute status of a channel changes. This is
+ a default implementation which does nothing and must be overriden.
+
+ Parameters:
+ channel - Pointer to a AUDDLoopRecChannel instance.
+ muted - New mute status.
+*/
+//__attribute__ ((weak)) void AUDDLoopRecChannel_MuteChanged(
+// AUDDLoopRecChannel *channel,
+// unsigned char muted)
+//{
+// TRACE_DEBUG("MuteChanged(%d, %d) ", channel->number, muted);
+//}
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Initializes the member variables of an AUDDLoopRecChannel object to the
+/// given values.
+/// \param channel Pointer to an AUDDLoopRecChannel instance.
+/// \param number Channel number in the audio function.
+/// \param muted Indicates if the channel is muted.
+//------------------------------------------------------------------------------
+void AUDDLoopRecChannel_Initialize(AUDDLoopRecChannel *channel,
+ unsigned char number,
+ unsigned char muted)
+{
+ channel->number = number;
+ channel->muted = muted;
+}
+
+//------------------------------------------------------------------------------
+/// Indicates the number of a channel.
+/// \param channel Pointer to an AUDDLoopRecChannel instance.
+/// \return Channel number.
+//------------------------------------------------------------------------------
+unsigned char AUDDLoopRecChannel_GetNumber(const AUDDLoopRecChannel *channel)
+{
+ return channel->number;
+}
+
+//------------------------------------------------------------------------------
+/// Mutes the given channel and triggers the MuteChanged callback if
+/// necessary.
+/// \param channel Pointer to an AUDDLoopRecChannelInstance.
+//------------------------------------------------------------------------------
+void AUDDLoopRecChannel_Mute(AUDDLoopRecChannel *channel)
+{
+ if (!channel->muted) {
+
+ channel->muted = 1;
+ AUDDLoopRecChannel_MuteChanged(channel, 1);
+ }
+}
+
+//------------------------------------------------------------------------------
+/// Unmutes the given channel and triggers the MuteChanged callback if
+/// necessary.
+/// \param channel Pointer to an AUDDLoopRecChannelInstance.
+//------------------------------------------------------------------------------
+void AUDDLoopRecChannel_Unmute(AUDDLoopRecChannel *channel)
+{
+ if (channel->muted) {
+
+ channel->muted = 0;
+ AUDDLoopRecChannel_MuteChanged(channel, 0);
+ }
+}
+
+//------------------------------------------------------------------------------
+/// Indicates if the given channel is currently muted or not.
+/// \param channel Pointer an AUDDLoopRecChannel instance.
+/// \return 1 if the channel is muted; otherwise 0.
+//------------------------------------------------------------------------------
+unsigned char AUDDLoopRecChannel_IsMuted(const AUDDLoopRecChannel *channel)
+{
+ return channel->muted;
+}
+
diff --git a/usb/device/audio-looprec/AUDDLoopRecChannel.h b/usb/device/audio-looprec/AUDDLoopRecChannel.h new file mode 100644 index 0000000..6cfad6b --- /dev/null +++ b/usb/device/audio-looprec/AUDDLoopRecChannel.h @@ -0,0 +1,92 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/**
+ \unit
+
+ !Purpose
+
+ Manipulation of the channels of an USB audio LoopRec device.
+
+ !Usage
+
+ -# Initialize a AUDDLoopRecChannel instance using
+ AUDDLoopRecChannel_Initialize.
+ -# Retrieves the current status of a channel with the
+ AUDDLoopRecChannel_IsMuted method.
+ -# Re-implement the AUDDLoopRecChannel_MuteChanged callback to get
+ notified when the status of a channel changes.
+*/
+
+#ifndef AUDDLOOPRECCHANNEL_H
+#define AUDDLOOPRECCHANNEL_H
+
+//------------------------------------------------------------------------------
+// Types
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Modelizes a channel of an USB audio LoopRec device.
+//------------------------------------------------------------------------------
+typedef struct {
+
+ /// Zero-based channel number in the audio function.
+ unsigned char number;
+ /// Indicates if the channel is currently muted.
+ unsigned char muted;
+
+} AUDDLoopRecChannel;
+
+//------------------------------------------------------------------------------
+// Callbacks
+//------------------------------------------------------------------------------
+
+extern void AUDDLoopRecChannel_MuteChanged(AUDDLoopRecChannel *channel,
+ unsigned char muted);
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+
+extern void AUDDLoopRecChannel_Initialize(AUDDLoopRecChannel *channel,
+ unsigned char number,
+ unsigned char muted);
+
+extern unsigned char AUDDLoopRecChannel_GetNumber(
+ const AUDDLoopRecChannel *channel);
+
+extern void AUDDLoopRecChannel_Mute(AUDDLoopRecChannel *channel);
+
+extern void AUDDLoopRecChannel_Unmute(AUDDLoopRecChannel *channel);
+
+extern unsigned char AUDDLoopRecChannel_IsMuted(
+ const AUDDLoopRecChannel *channel);
+
+#endif //#ifndef AUDDLOOPRECCHANNEL_H
+
diff --git a/usb/device/audio-looprec/AUDDLoopRecDriver.c b/usb/device/audio-looprec/AUDDLoopRecDriver.c new file mode 100644 index 0000000..45534b5 --- /dev/null +++ b/usb/device/audio-looprec/AUDDLoopRecDriver.c @@ -0,0 +1,493 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include "AUDDLoopRecDriver.h"
+#include "AUDDLoopRecDriverDescriptors.h"
+#include "AUDDLoopRecChannel.h"
+#include <utility/trace.h>
+#include <utility/assert.h>
+#include <utility/led.h>
+#include <usb/common/audio/AUDGenericRequest.h>
+#include <usb/common/audio/AUDFeatureUnitRequest.h>
+#include <usb/device/core/USBDDriver.h>
+
+//------------------------------------------------------------------------------
+// Internal types
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Audio LoopRec driver internal state.
+//------------------------------------------------------------------------------
+typedef struct {
+
+ /// USB device driver instance.
+ USBDDriver usbdDriver;
+ #if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)
+ /// Multi-Buffer-Transfer List
+ USBDTransferBuffer * pMbl;
+ /// List Size
+ unsigned short listSize;
+ /// Current buffer
+ unsigned short currBuffer;
+ #endif
+ /// Callback for ISO IN
+ AUDDFrameTransferCallback fWrCallback;
+ /// List of AUDDLoopRecChannel instances for playback.
+ AUDDLoopRecChannel channels[AUDDLoopRecDriver_NUMCHANNELS+1];
+ /// List of AUDDLoopRecChannel instances for record.
+ AUDDLoopRecChannel recChannels[1];
+
+} AUDDLoopRecDriver;
+
+//------------------------------------------------------------------------------
+// Internal variables
+//------------------------------------------------------------------------------
+
+/// Global USB audio LoopRec driver instance.
+static AUDDLoopRecDriver auddLoopRecDriver;
+/// Array for storing the current setting of each interface.
+static unsigned char auddLoopRecDriverInterfaces[3];
+/// Intermediate storage variable for the mute status of a channel.
+static unsigned char muted;
+
+//------------------------------------------------------------------------------
+// Internal functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Callback triggered after the new mute status of a channel has been read
+/// by AUDDLoopRecDriver_SetFeatureCurrentValue. Changes the mute status
+/// of the given channel accordingly.
+/// \param channel Number of the channel whose mute status has changed.
+//------------------------------------------------------------------------------
+static void AUDDLoopRecDriver_MuteReceived(unsigned int channel)
+{
+ AUDDLoopRecChannel * pChannel;
+ if ((unsigned char)(channel >> 8) ==
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC) {
+ pChannel = &auddLoopRecDriver.recChannels[0];
+ }
+ else {
+ pChannel = &auddLoopRecDriver.channels[channel];
+ }
+ if (muted) {
+
+ AUDDLoopRecChannel_Mute(pChannel);
+ }
+ else {
+
+ AUDDLoopRecChannel_Unmute(pChannel);
+ }
+
+ USBD_Write(0, 0, 0, 0, 0);
+}
+
+//------------------------------------------------------------------------------
+/// Sets the current value of a particular Feature control of a channel.
+/// \param entity Entity number.
+/// \param channel Channel number.
+/// \param control Control selector value (see TODO).
+/// \param length Length of the data containing the new value.
+//------------------------------------------------------------------------------
+static void AUDDLoopRecDriver_SetFeatureCurrentValue(unsigned char entity,
+ unsigned char channel,
+ unsigned char control,
+ unsigned short length)
+{
+ TRACE_INFO_WP("sFeature ");
+ TRACE_DEBUG("\b(E%d, CS%d, CN%d, L%d) ",
+ entity, control, channel, length);
+
+ // Check the the requested control is supported
+ // Control/channel combination not supported
+ if ((control != AUDFeatureUnitRequest_MUTE) ||
+ (length != 1) ||
+ ((entity == AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL) &&
+ (channel > AUDDLoopRecDriver_NUMCHANNELS)) ||
+ ((entity == AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC) &&
+ (channel > 0))) {
+
+ USBD_Stall(0);
+ }
+ // Mute control on master channel / speakerphone
+ else {
+
+ unsigned int argument = channel | (entity << 8);
+ USBD_Read(0, // Endpoint #0
+ &muted,
+ sizeof(muted),
+ (TransferCallback) AUDDLoopRecDriver_MuteReceived,
+ (void *) argument);
+ }
+}
+
+//------------------------------------------------------------------------------
+/// Sends the current value of a particular channel Feature to the USB host.
+/// \param entity Entity number.
+/// \param channel Channel number.
+/// \param control Control selector value (see TODO).
+/// \param length Length of the data to return.
+//------------------------------------------------------------------------------
+static void AUDDLoopRecDriver_GetFeatureCurrentValue(unsigned char entity,
+ unsigned char channel,
+ unsigned char control,
+ unsigned char length)
+{
+ TRACE_INFO_WP("gFeature ");
+ TRACE_DEBUG("\b(CS%d, CN%d, L%d) ", control, channel, length);
+
+ // Check that the requested control is supported
+ // Master channel mute control
+ if ((control == AUDFeatureUnitRequest_MUTE)
+ && (channel < (AUDDLoopRecDriver_NUMCHANNELS+1))
+ && (length == 1)) {
+
+ if (entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT) {
+ muted = auddLoopRecDriver.channels[channel].muted;
+ }
+ else {
+ muted = auddLoopRecDriver.recChannels[0].muted;
+ }
+ USBD_Write(0, &muted, sizeof(muted), 0, 0);
+ }
+ else {
+
+ USBD_Stall(0);
+ }
+}
+
+//------------------------------------------------------------------------------
+/// Callback used by MBL transfer functions (USBD_Read & USBD_Write) to notify
+/// that a transaction is complete.
+/// \param pArg Pointer to callback arguments.
+/// \param status USBD status.
+/// \param nbBuffer Number of buffer that is processed.
+//------------------------------------------------------------------------------
+void AUDDLoopRecDriver_MblWriteCallback(void *pArg,
+ unsigned char status,
+ unsigned int nbBuffer)
+{
+ char rc = 1;
+ if (auddLoopRecDriver.fWrCallback) {
+
+ rc = auddLoopRecDriver.fWrCallback(pArg, status);
+ }
+ if (rc && status == USBD_STATUS_PARTIAL_DONE) {
+
+ while(nbBuffer --) {
+ USBD_MblReuse(AUDDLoopRecDriverDescriptors_DATAIN,
+ 0, 0);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+// Callback re-implementation
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Triggered when the USB host emits a new SETUP request. The request is
+/// forward to <AUDDLoopRecDriver_RequestHandler>.
+/// \param request Pointer to a USBGenericRequest instance.
+//------------------------------------------------------------------------------
+#if !defined(NOAUTOCALLBACK)
+void USBDCallbacks_RequestReceived(const USBGenericRequest *request)
+{
+ AUDDLoopRecDriver_RequestHandler(request);
+}
+#endif
+
+//------------------------------------------------------------------------------
+/// Invoked whenever the active setting of an interface is changed by the
+/// host. Changes the status of the third LED accordingly.
+/// \param interface Interface number.
+/// \param setting Newly active setting.
+//------------------------------------------------------------------------------
+void USBDDriverCallbacks_InterfaceSettingChanged(unsigned char interface,
+ unsigned char setting)
+{
+ if ((interface == AUDDLoopRecDriverDescriptors_STREAMING)
+ && (setting == 0)) {
+
+ LED_Clear(USBD_LEDOTHER);
+ }
+ else {
+
+ LED_Set(USBD_LEDOTHER);
+ }
+}
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Initializes an USB audio LoopRec device driver, as well as the underlying
+/// USB controller.
+//------------------------------------------------------------------------------
+void AUDDLoopRecDriver_Initialize()
+{
+ // Reset callback function
+ auddLoopRecDriver.fWrCallback = 0;
+
+ // Initialize LoopRec channels
+ AUDDLoopRecChannel_Initialize(&(auddLoopRecDriver.channels[0]),
+ AUDDLoopRecDriver_MASTERCHANNEL,
+ 0);
+ AUDDLoopRecChannel_Initialize(&(auddLoopRecDriver.channels[1]),
+ AUDDLoopRecDriver_LEFTCHANNEL,
+ 0);
+ AUDDLoopRecChannel_Initialize(&(auddLoopRecDriver.channels[2]),
+ AUDDLoopRecDriver_RIGHTCHANNEL,
+ 0);
+ AUDDLoopRecChannel_Initialize(&(auddLoopRecDriver.recChannels[0]),
+ AUDDLoopRecDriver_RECCHANNEL,
+ 0);
+
+ // Initialize the USB driver
+ USBDDriver_Initialize(&(auddLoopRecDriver.usbdDriver),
+ &auddLoopRecDriverDescriptors,
+ auddLoopRecDriverInterfaces);
+ USBD_Init();
+
+ // Initialize the third LED to indicate when the audio interface is active
+ LED_Configure(USBD_LEDOTHER);
+}
+
+//------------------------------------------------------------------------------
+/// Handles audio-specific USB requests sent by the host, and forwards
+/// standard ones to the USB device driver.
+/// \param request Pointer to a USBGenericRequest instance.
+//------------------------------------------------------------------------------
+void AUDDLoopRecDriver_RequestHandler(const USBGenericRequest *request)
+{
+ unsigned char entity;
+ unsigned char interface;
+
+ TRACE_INFO_WP("NewReq ");
+
+ // Check if this is a class request
+ if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) {
+
+ // Check if the request is supported
+ switch (USBGenericRequest_GetRequest(request)) {
+
+ case AUDGenericRequest_SETCUR:
+ TRACE_INFO_WP(
+ "sCur(0x%04X) ",
+ USBGenericRequest_GetIndex(request));
+
+ // Check the target interface and entity
+ entity = AUDGenericRequest_GetEntity(request);
+ interface = AUDGenericRequest_GetInterface(request);
+ if (((entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT)
+ ||(entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC))
+ && (interface == AUDDLoopRecDriverDescriptors_CONTROL)) {
+
+ AUDDLoopRecDriver_SetFeatureCurrentValue(
+ entity,
+ AUDFeatureUnitRequest_GetChannel(request),
+ AUDFeatureUnitRequest_GetControl(request),
+ USBGenericRequest_GetLength(request));
+ }
+ else {
+
+ TRACE_WARNING(
+ "AUDDLoopRecDriver_RequestHandler: Unsupported entity/interface combination (0x%04X)\n\r",
+ USBGenericRequest_GetIndex(request));
+ USBD_Stall(0);
+ }
+ break;
+
+ case AUDGenericRequest_GETCUR:
+ TRACE_INFO_WP(
+ "gCur(0x%04X) ",
+ USBGenericRequest_GetIndex(request));
+
+ // Check the target interface and entity
+ entity = AUDGenericRequest_GetEntity(request);
+ interface = AUDGenericRequest_GetInterface(request);
+ if (((entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT)
+ ||(entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC))
+ && (interface == AUDDLoopRecDriverDescriptors_CONTROL)) {
+
+ AUDDLoopRecDriver_GetFeatureCurrentValue(
+ entity,
+ AUDFeatureUnitRequest_GetChannel(request),
+ AUDFeatureUnitRequest_GetControl(request),
+ USBGenericRequest_GetLength(request));
+ }
+ else {
+
+ TRACE_WARNING(
+ "AUDDLoopRecDriver_RequestHandler: Unsupported entity/interface combination (0x%04X)\n\r",
+ USBGenericRequest_GetIndex(request));
+ USBD_Stall(0);
+ }
+ break;
+
+ default:
+
+ TRACE_WARNING(
+ "AUDDLoopRecDriver_RequestHandler: Unsupported request (%d)\n\r",
+ USBGenericRequest_GetRequest(request));
+ USBD_Stall(0);
+ }
+ }
+ // Check if this is a standard request
+ else if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) {
+
+ // Forward request to the standard handler
+ USBDDriver_RequestHandler(&(auddLoopRecDriver.usbdDriver), request);
+ }
+ // Unsupported request type
+ else {
+
+ TRACE_WARNING(
+ "AUDDLoopRecDriver_RequestHandler: Unsupported request type (%d)\n\r",
+ USBGenericRequest_GetType(request));
+ USBD_Stall(0);
+ }
+}
+
+//------------------------------------------------------------------------------
+/// Reads incoming audio data sent by the USB host into the provided
+/// buffer. When the transfer is complete, an optional callback function is
+/// invoked.
+/// \param buffer Pointer to the data storage buffer.
+/// \param length Size of the buffer in bytes.
+/// \param callback Optional callback function.
+/// \param argument Optional argument to the callback function.
+/// \return USBD_STATUS_SUCCESS if the transfer is started successfully;
+/// otherwise an error code.
+//------------------------------------------------------------------------------
+unsigned char AUDDLoopRecDriver_Read(void *buffer,
+ unsigned int length,
+ TransferCallback callback,
+ void *argument)
+{
+ return USBD_Read(AUDDLoopRecDriverDescriptors_DATAOUT,
+ buffer,
+ length,
+ callback,
+ argument);
+}
+
+//------------------------------------------------------------------------------
+/// Initialize Frame List for sending audio data.
+/// \param pMultiBufferList Pointer to the transfer list to initialize.
+/// \param pBufferList Pointer list to the buffers used for frames sending.
+/// \param listSize Number of frames.
+/// \param frameSize Size in number of bytes of each frame.
+//------------------------------------------------------------------------------
+void AUDDLoopRecDriver_SetupWriteMbl(void * pMultiBufferList,
+ unsigned char **pBufferList,
+ unsigned short listSize,
+ unsigned short frameSize)
+{
+ int i;
+
+ SANITY_CHECK(pMultiBufferList && pBufferList && listSize && frameSize);
+
+#if (defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)) && defined(DMA)
+ // Initialize for circled DMA LLI
+ {
+ USBDDmaDescriptor * pLl = (USBDDmaDescriptor*)pMultiBufferList;
+ for (i = 0; ; i ++) {
+ pLl[i].pDataAddr = pBufferList[i];
+ pLl[i].bufferLength = frameSize;
+ if (i < listSize - 1) {
+ pLl[i].pNxtDesc = &pLl[i + 1];
+ }
+ else {
+ pLl[i].pNxtDesc = &pLl[0];
+ break;
+ }
+ }
+ }
+#else
+ // Initialize for circled multi-buffer-list
+ {
+ USBDTransferBuffer * pMbl = (USBDTransferBuffer*)pMultiBufferList;
+ for (i = 0; i < listSize; i ++) {
+ pMbl[i].pBuffer = pBufferList[i];
+ pMbl[i].size = frameSize;
+ pMbl[i].transferred = 0;
+ pMbl[i].buffered = 0;
+ pMbl[i].remaining = frameSize;
+ }
+ }
+#endif
+}
+
+//------------------------------------------------------------------------------
+/// Start sending audio data, through MBL window.
+/// When any frame is complete, an optional callback function is invoked, return
+/// 1 of the callback cause the frame buffer re-used.
+/// If callback not assigned, frames always reused.
+/// \param buffer Pointer to the data storage buffer.
+/// \param length Size of the buffer in bytes.
+/// \param callback Optional callback function.
+/// \param argument Optional argument to the callback function.
+/// \return USBD_STATUS_SUCCESS if the transfer is started successfully;
+/// otherwise an error code.
+//------------------------------------------------------------------------------
+unsigned char AUDDLoopRecDriver_Write(void * pMbl,
+ unsigned short listSize,
+ AUDDFrameTransferCallback callback,
+ void * argument)
+{
+ auddLoopRecDriver.fWrCallback = callback;
+ return USBD_MblWrite(AUDDLoopRecDriverDescriptors_DATAIN,
+ pMbl,
+ listSize,
+ 1,
+ 0,
+ AUDDLoopRecDriver_MblWriteCallback,
+ argument);
+}
+
+//-----------------------------------------------------------------------------
+/// Starts a remote wake-up sequence if the host has explicitely enabled it
+/// by sending the appropriate SET_FEATURE request.
+//-----------------------------------------------------------------------------
+void AUDDLoopRecDriver_RemoteWakeUp(void)
+{
+ // Remote wake-up has been enabled
+ if (USBDDriver_IsRemoteWakeUpEnabled(&auddLoopRecDriver.usbdDriver)) {
+
+ USBD_RemoteWakeUp();
+ }
+}
+
+
diff --git a/usb/device/audio-looprec/AUDDLoopRecDriver.h b/usb/device/audio-looprec/AUDDLoopRecDriver.h new file mode 100644 index 0000000..8db30a1 --- /dev/null +++ b/usb/device/audio-looprec/AUDDLoopRecDriver.h @@ -0,0 +1,163 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/**
+ \unit
+
+ !Purpose
+
+ Definition of a USB Audio Loop Record Driver with two playback channels
+ and one record channel.
+
+ !Usage
+
+ -# Enable and setup USB related pins (see pio & board.h).
+ -# Configure the USB Audio Loop Record driver using
+ AUDDLoopRecDriver_Initialize
+ -# To get %audio stream frames from host, use
+ AUDDLoopRecDriver_Read
+ -# To send %audio sampling stream to host, use
+ AUDDLoopRecDriver_Write
+
+*/
+
+#ifndef AUDDLoopRecDriver_H
+#define AUDDLoopRecDriver_H
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include <board.h>
+#include <usb/common/core/USBGenericRequest.h>
+#include <usb/device/core/USBD.h>
+
+//------------------------------------------------------------------------------
+// Definitions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "Audio Loop Record stream information"
+///
+/// This page lists codes for USB Audio Loop Record stream information.
+///
+/// !Code
+/// - AUDDLoopRecDriver_SAMPLERATE
+/// - AUDDLoopRecDriver_NUMCHANNELS
+/// - AUDDLoopRecDriver_BYTESPERSAMPLE
+/// - AUDDLoopRecDriver_BITSPERSAMPLE
+/// - AUDDLoopRecDriver_SAMPLESPERFRAME
+/// - AUDDLoopRecDriver_BYTESPERFRAME
+
+#if defined(at91sam7s) || defined(at91sam9xe)
+ /// Sample rate in Hz.
+ #define AUDDLoopRecDriver_SAMPLERATE 32000
+ /// Number of channels in audio stream.
+ #define AUDDLoopRecDriver_NUMCHANNELS 1
+ /// Number of bytes in one sample.
+ #define AUDDLoopRecDriver_BYTESPERSAMPLE 2
+#else
+ /// Sample rate in Hz.
+ #define AUDDLoopRecDriver_SAMPLERATE 48000
+ /// Number of channels in audio stream.
+ #define AUDDLoopRecDriver_NUMCHANNELS 2
+ /// Number of bytes in one sample.
+ #define AUDDLoopRecDriver_BYTESPERSAMPLE 2
+#endif
+/// Number of bits in one sample.
+#define AUDDLoopRecDriver_BITSPERSAMPLE (AUDDLoopRecDriver_BYTESPERSAMPLE * 8)
+/// Number of bytes in one USB subframe.
+#define AUDDLoopRecDriver_BYTESPERSUBFRAME (AUDDLoopRecDriver_NUMCHANNELS * \
+ AUDDLoopRecDriver_BYTESPERSAMPLE)
+/// Number of samples in one USB frame.
+#define AUDDLoopRecDriver_SAMPLESPERFRAME (AUDDLoopRecDriver_SAMPLERATE / 1000 \
+ * AUDDLoopRecDriver_NUMCHANNELS)
+/// Number of bytes in one USB frame.
+#define AUDDLoopRecDriver_BYTESPERFRAME (AUDDLoopRecDriver_SAMPLESPERFRAME * \
+ AUDDLoopRecDriver_BYTESPERSAMPLE)
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "Audio Loop Record Channel Numbers"
+///
+/// This page lists codes for USB Audio Loop Record channel numbers.
+///
+/// !Playback channel numbers
+/// - AUDDLoopRecDriver_MASTERCHANNEL
+/// - AUDDLoopRecDriver_LEFTCHANNEL
+/// - AUDDLoopRecDriver_RIGHTCHANNEL
+///
+/// !Record channel number
+/// - AUDDLoopRecDriver_RECCHANNEL
+
+/// Master channel of playback.
+#define AUDDLoopRecDriver_MASTERCHANNEL 0
+/// Front left channel of playback.
+#define AUDDLoopRecDriver_LEFTCHANNEL 1
+/// Front right channel of playback.
+#define AUDDLoopRecDriver_RIGHTCHANNEL 2
+/// Channel of record.
+#define AUDDLoopRecDriver_RECCHANNEL 0
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Callback function for audio frames.
+/// \param pArg Pointer to transfer arguments.
+/// \param status Frame transfer status.
+/// \return 1 to continue, 0 to stop frames.
+//------------------------------------------------------------------------------
+typedef char (*AUDDFrameTransferCallback)(void* pArg, char status);
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+
+extern void AUDDLoopRecDriver_Initialize();
+
+extern void AUDDLoopRecDriver_RequestHandler(const USBGenericRequest *request);
+
+extern unsigned char AUDDLoopRecDriver_Read(void *buffer,
+ unsigned int length,
+ TransferCallback callback,
+ void *argument);
+
+extern void AUDDLoopRecDriver_SetupWriteMbl(void * pMultiBufferList,
+ unsigned char **pBufferList,
+ unsigned short listSize,
+ unsigned short frameSize);
+
+extern unsigned char AUDDLoopRecDriver_Write(void * pMbl,
+ unsigned short listSize,
+ AUDDFrameTransferCallback callback,
+ void *argument);
+
+extern void AUDDLoopRecDriver_RemoteWakeUp(void);
+
+#endif //#ifndef AUDDLoopRecDriver_H
+
diff --git a/usb/device/audio-looprec/AUDDLoopRecDriverDescriptors.c b/usb/device/audio-looprec/AUDDLoopRecDriverDescriptors.c new file mode 100644 index 0000000..9f961fd --- /dev/null +++ b/usb/device/audio-looprec/AUDDLoopRecDriverDescriptors.c @@ -0,0 +1,1461 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include "AUDDLoopRecDriverDescriptors.h"
+#include "AUDDLoopRecDriver.h"
+#include <board.h>
+#include <usb/common/core/USBGenericDescriptor.h>
+#include <usb/common/core/USBDeviceDescriptor.h>
+#include <usb/common/core/USBConfigurationDescriptor.h>
+#include <usb/common/core/USBInterfaceDescriptor.h>
+#include <usb/common/core/USBEndpointDescriptor.h>
+#include <usb/common/core/USBStringDescriptor.h>
+#include <usb/common/audio/AUDGenericDescriptor.h>
+#include <usb/common/audio/AUDDeviceDescriptor.h>
+#include <usb/common/audio/AUDControlInterfaceDescriptor.h>
+#include <usb/common/audio/AUDStreamingInterfaceDescriptor.h>
+#include <usb/common/audio/AUDEndpointDescriptor.h>
+#include <usb/common/audio/AUDDataEndpointDescriptor.h>
+#include <usb/common/audio/AUDFormatTypeOneDescriptor.h>
+#include <usb/common/audio/AUDHeaderDescriptor.h>
+#include <usb/common/audio/AUDFeatureUnitDescriptor.h>
+#include <usb/common/audio/AUDInputTerminalDescriptor.h>
+#include <usb/common/audio/AUDOutputTerminalDescriptor.h>
+
+//------------------------------------------------------------------------------
+// Definitions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "Audio Loop Record Device Codes"
+///
+/// This page lists the %device IDs and release number of the USB Audio Loop Record
+/// %device.
+///
+/// !Codes
+/// - AUDDLoopRecDriverDescriptors_VENDORID
+/// - AUDDLoopRecDriverDescriptors_PRODUCTID
+/// - AUDDLoopRecDriverDescriptors_RELEASE
+
+/// Device vendor ID.
+#define AUDDLoopRecDriverDescriptors_VENDORID 0x03EB
+/// Device product ID.
+#define AUDDLoopRecDriverDescriptors_PRODUCTID 0x6128
+/// Device release number in BCD format.
+#define AUDDLoopRecDriverDescriptors_RELEASE 0x0100
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// Internal types
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Audio control header descriptor with one slave interface.
+//------------------------------------------------------------------------------
+#ifdef __ICCARM__ // IAR
+#pragma pack(1) // IAR
+#define __attribute__(...) // IAR
+#endif // IAR
+
+//------------------------------------------------------------------------------
+/// Header descriptor with 1 interface.
+//------------------------------------------------------------------------------
+typedef struct {
+
+ /// Header descriptor.
+ AUDHeaderDescriptor header;
+ /// Id of the first grouped interface - Speaker.
+ unsigned char bInterface0;
+ /// Id of the second grouped interface - Speakerphone.
+ unsigned char bInterface1;
+
+} __attribute__ ((packed)) AUDHeaderDescriptor2; // GCC
+
+//------------------------------------------------------------------------------
+/// Feature unit descriptor with 3 channel controls (master, right, left).
+//------------------------------------------------------------------------------
+typedef struct {
+
+ /// Feature unit descriptor.
+ AUDFeatureUnitDescriptor feature;
+ /// Available controls for each channel.
+ unsigned char bmaControls[3];
+ /// Index of a string descriptor for the feature unit.
+ unsigned char iFeature;
+
+} __attribute__ ((packed)) AUDFeatureUnitDescriptor3; // GCC
+
+//------------------------------------------------------------------------------
+/// List of descriptors for detailling the audio control interface of a
+/// device using a USB Audio Loop Recorder driver.
+//------------------------------------------------------------------------------
+typedef struct {
+
+ /// Header descriptor (with one slave interface).
+ AUDHeaderDescriptor2 header;
+ /// Input terminal descriptor.
+ AUDInputTerminalDescriptor inputLoopRec;
+ /// Output terminal descriptor.
+ AUDOutputTerminalDescriptor outputLoopRec;
+ /// Feature unit descriptor - LoopRec.
+ AUDFeatureUnitDescriptor3 featureLoopRec;
+ /// Input terminal descriptor.
+ AUDInputTerminalDescriptor inputRec;
+ /// Output terminal descriptor.
+ AUDOutputTerminalDescriptor outputRec;
+ /// Feature unit descriptor - LoopRecphone.
+ AUDFeatureUnitDescriptor3 featureRec;
+
+} __attribute__ ((packed)) AUDDLoopRecDriverAudioControlDescriptors; // GCC
+
+//------------------------------------------------------------------------------
+/// Format type I descriptor with one discrete sampling frequency.
+//------------------------------------------------------------------------------
+typedef struct {
+
+ /// Format type I descriptor.
+ AUDFormatTypeOneDescriptor formatType;
+ /// Sampling frequency in Hz.
+ unsigned char tSamFreq[3];
+
+} __attribute__ ((packed)) AUDFormatTypeOneDescriptor1; // GCC
+
+//------------------------------------------------------------------------------
+/// Holds a list of descriptors returned as part of the configuration of
+/// a USB Audio Loop Record device.
+//------------------------------------------------------------------------------
+typedef struct {
+
+ /// Standard configuration.
+ USBConfigurationDescriptor configuration;
+ /// Audio control interface.
+ USBInterfaceDescriptor control;
+ /// Descriptors for the audio control interface.
+ AUDDLoopRecDriverAudioControlDescriptors controlDescriptors;
+ //- AUDIO OUT
+ /// Streaming out interface descriptor (with no endpoint, required).
+ USBInterfaceDescriptor streamingOutNoIsochronous;
+ /// Streaming out interface descriptor.
+ USBInterfaceDescriptor streamingOut;
+ /// Audio class descriptor for the streaming out interface.
+ AUDStreamingInterfaceDescriptor streamingOutClass;
+ /// Stream format descriptor.
+ AUDFormatTypeOneDescriptor1 streamingOutFormatType;
+ /// Streaming out endpoint descriptor.
+ AUDEndpointDescriptor streamingOutEndpoint;
+ /// Audio class descriptor for the streaming out endpoint.
+ AUDDataEndpointDescriptor streamingOutDataEndpoint;
+ //- AUDIO IN
+ /// Streaming in interface descriptor (with no endpoint, required).
+ USBInterfaceDescriptor streamingInNoIsochronous;
+ /// Streaming in interface descriptor.
+ USBInterfaceDescriptor streamingIn;
+ /// Audio class descriptor for the streaming in interface.
+ AUDStreamingInterfaceDescriptor streamingInClass;
+ /// Stream format descriptor.
+ AUDFormatTypeOneDescriptor1 streamingInFormatType;
+ /// Streaming in endpoint descriptor.
+ AUDEndpointDescriptor streamingInEndpoint;
+ /// Audio class descriptor for the streaming in endpoint.
+ AUDDataEndpointDescriptor streamingInDataEndpoint;
+
+} __attribute__ ((packed)) AUDDLoopRecDriverConfigurationDescriptors; // GCC
+
+#ifdef __ICCARM__ // IAR
+#pragma pack() // IAR
+#endif // IAR
+
+//------------------------------------------------------------------------------
+// Exported variables
+//------------------------------------------------------------------------------
+
+/// Device descriptor for a USB Audio Loop Record driver.
+const USBDeviceDescriptor deviceDescriptor = {
+
+ sizeof(USBDeviceDescriptor),
+ USBGenericDescriptor_DEVICE,
+ USBDeviceDescriptor_USB2_00,
+ AUDDeviceDescriptor_CLASS,
+ AUDDeviceDescriptor_SUBCLASS,
+ AUDDeviceDescriptor_PROTOCOL,
+ CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
+ AUDDLoopRecDriverDescriptors_VENDORID,
+ AUDDLoopRecDriverDescriptors_PRODUCTID,
+ AUDDLoopRecDriverDescriptors_RELEASE,
+ 1, // Manufacturer string descriptor index
+ 2, // Product string descriptor index
+ 3, // Index of serial number string descriptor
+ 1 // One possible configuration
+};
+
+#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)
+
+/// USB device qualifier descriptor.
+const USBDeviceQualifierDescriptor qualifierDescriptor = {
+
+ sizeof(USBDeviceQualifierDescriptor),
+ USBGenericDescriptor_DEVICEQUALIFIER,
+ USBDeviceDescriptor_USB2_00,
+ AUDDeviceDescriptor_CLASS,
+ AUDDeviceDescriptor_SUBCLASS,
+ AUDDeviceDescriptor_PROTOCOL,
+ CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
+ 1, // Device has one possible configuration
+ 0 // Reserved
+};
+
+/// HS Configuration descriptors for a USB Audio Loop Record driver.
+const AUDDLoopRecDriverConfigurationDescriptors hsConfigurationDescriptors = {
+
+ // Configuration descriptor
+ {
+ sizeof(USBConfigurationDescriptor),
+ USBGenericDescriptor_CONFIGURATION,
+ sizeof(AUDDLoopRecDriverConfigurationDescriptors),
+ 3, // This configuration has 3 interfaces
+ 1, // This is configuration #1
+ 0, // No string descriptor
+ BOARD_USB_BMATTRIBUTES,
+ USBConfigurationDescriptor_POWER(100)
+ },
+ // Audio control interface standard descriptor
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_CONTROL,
+ 0, // This is alternate setting #0
+ 0, // This interface uses no endpoint
+ AUDControlInterfaceDescriptor_CLASS,
+ AUDControlInterfaceDescriptor_SUBCLASS,
+ AUDControlInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio control interface descriptors
+ {
+ // Header descriptor
+ {
+ {
+ sizeof(AUDHeaderDescriptor2),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_HEADER,
+ AUDHeaderDescriptor_AUD1_00,
+ sizeof(AUDDLoopRecDriverAudioControlDescriptors),
+ 2 // Two streaming interface
+ },
+ AUDDLoopRecDriverDescriptors_STREAMING,
+ AUDDLoopRecDriverDescriptors_STREAMINGIN
+ },
+ // Input terminal descriptor ( speaker )
+ {
+ sizeof(AUDInputTerminalDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_INPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
+ AUDInputTerminalDescriptor_USBSTREAMING,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
+ AUDDLoopRecDriver_NUMCHANNELS,
+ #if AUDDLoopRecDriver_NUMCHANNELS > 1
+ AUDInputTerminalDescriptor_LEFTFRONT
+ | AUDInputTerminalDescriptor_RIGHTFRONT,
+ #else
+ 0, // Mono sets no position bits.
+ #endif
+ 0, // No string descriptor for channels
+ 0 // No string descriptor for input terminal
+ },
+ // Output terminal descriptor ( speaker )
+ {
+ sizeof(AUDOutputTerminalDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_OUTPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
+ AUDOutputTerminalDescriptor_SPEAKER,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_FEATUREUNIT,
+ 0 // No string descriptor
+ },
+ // Feature unit descriptor ( speaker )
+ {
+ {
+ sizeof(AUDFeatureUnitDescriptor3),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_FEATUREUNIT,
+ AUDDLoopRecDriverDescriptors_FEATUREUNIT,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
+ 1, // 1 byte per channel for controls
+ },
+ {
+ AUDFeatureUnitDescriptor_MUTE, // Master channel controls
+ 0, // Right channel controls
+ 0 // Left channel controls
+ },
+ 0 // No string descriptor
+ },
+ // Input terminal descriptor ( speakerphone )
+ {
+ sizeof(AUDInputTerminalDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_INPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
+ AUDInputTerminalDescriptor_SPEAKERPHONE,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
+ AUDDLoopRecDriver_NUMCHANNELS,
+ #if AUDDLoopRecDriver_NUMCHANNELS > 1
+ AUDInputTerminalDescriptor_LEFTFRONT
+ | AUDInputTerminalDescriptor_RIGHTFRONT,
+ #else
+ 0, // Mono sets no position bits.
+ #endif
+ 0, // No string descriptor for channels
+ 0 // No string descriptor for input terminal
+ },
+ // Output terminal descriptor ( speakerphone )
+ {
+ sizeof(AUDOutputTerminalDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_OUTPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
+ AUDOutputTerminalDescriptor_USBTREAMING,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
+ AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
+ 0 // No string descriptor
+ },
+ // Feature unit descriptor ( speakerphone )
+ {
+ {
+ sizeof(AUDFeatureUnitDescriptor3),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_FEATUREUNIT,
+ AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
+ 1
+ },
+ {
+ AUDFeatureUnitDescriptor_MUTE, // Mic controls
+ 0,
+ 0
+ },
+ 0 // No string descriptor
+ }
+ },
+ // - AUIDO OUT
+ // Audio streaming interface with 0 endpoints
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_STREAMING,
+ 0, // This is alternate setting #0
+ 0, // This interface uses no endpoints
+ AUDStreamingInterfaceDescriptor_CLASS,
+ AUDStreamingInterfaceDescriptor_SUBCLASS,
+ AUDStreamingInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio streaming interface with data endpoint
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_STREAMING,
+ 1, // This is alternate setting #1
+ 1, // This interface uses 1 endpoint
+ AUDStreamingInterfaceDescriptor_CLASS,
+ AUDStreamingInterfaceDescriptor_SUBCLASS,
+ AUDStreamingInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio streaming class-specific descriptor
+ {
+ sizeof(AUDStreamingInterfaceDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDStreamingInterfaceDescriptor_GENERAL,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
+ 0, // No internal delay because of data path
+ AUDFormatTypeOneDescriptor_PCM
+ },
+ // Format type I descriptor
+ {
+ {
+ sizeof(AUDFormatTypeOneDescriptor1),
+ AUDGenericDescriptor_INTERFACE,
+ AUDStreamingInterfaceDescriptor_FORMATTYPE,
+ AUDFormatTypeOneDescriptor_FORMATTYPEONE,
+ AUDDLoopRecDriver_NUMCHANNELS,
+ AUDDLoopRecDriver_BYTESPERSAMPLE,
+ AUDDLoopRecDriver_BYTESPERSAMPLE*8,
+ 1 // One discrete frequency supported
+ },
+ {
+ AUDDLoopRecDriver_SAMPLERATE & 0xFF,
+ (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
+ (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
+ }
+ },
+ // Audio streaming endpoint standard descriptor
+ {
+ sizeof(AUDEndpointDescriptor),
+ USBGenericDescriptor_ENDPOINT,
+ USBEndpointDescriptor_ADDRESS(
+ USBEndpointDescriptor_OUT,
+ AUDDLoopRecDriverDescriptors_DATAOUT),
+ USBEndpointDescriptor_ISOCHRONOUS,
+ AUDDLoopRecDriver_BYTESPERFRAME,
+ AUDDLoopRecDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms
+ 0, // This is not a synchronization endpoint
+ 0 // No associated synchronization endpoint
+ },
+ // Audio streaming endpoint class-specific descriptor
+ {
+ sizeof(AUDDataEndpointDescriptor),
+ AUDGenericDescriptor_ENDPOINT,
+ AUDDataEndpointDescriptor_SUBTYPE,
+ 0, // No attributes
+ 0, // Endpoint is not synchronized
+ 0 // Endpoint is not synchronized
+ },
+ //- AUDIO IN
+ // Audio streaming interface with 0 endpoints
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_STREAMINGIN,
+ 0, // This is alternate setting #0
+ 0, // This interface uses no endpoints
+ AUDStreamingInterfaceDescriptor_CLASS,
+ AUDStreamingInterfaceDescriptor_SUBCLASS,
+ AUDStreamingInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio streaming interface with data endpoint
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_STREAMINGIN,
+ 1, // This is alternate setting #1
+ 1, // This interface uses 1 endpoint
+ AUDStreamingInterfaceDescriptor_CLASS,
+ AUDStreamingInterfaceDescriptor_SUBCLASS,
+ AUDStreamingInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio streaming class-specific descriptor
+ {
+ sizeof(AUDStreamingInterfaceDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDStreamingInterfaceDescriptor_GENERAL,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
+ 0, // No internal delay because of data path
+ AUDFormatTypeOneDescriptor_PCM
+ },
+ // Format type I descriptor
+ {
+ {
+ sizeof(AUDFormatTypeOneDescriptor1),
+ AUDGenericDescriptor_INTERFACE,
+ AUDStreamingInterfaceDescriptor_FORMATTYPE,
+ AUDFormatTypeOneDescriptor_FORMATTYPEONE,
+ AUDDLoopRecDriver_NUMCHANNELS,
+ AUDDLoopRecDriver_BYTESPERSAMPLE,
+ AUDDLoopRecDriver_BYTESPERSAMPLE*8,
+ 1 // One discrete frequency supported
+ },
+ {
+ AUDDLoopRecDriver_SAMPLERATE & 0xFF,
+ (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
+ (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
+ }
+ },
+ // Audio streaming endpoint standard descriptor
+ {
+ sizeof(AUDEndpointDescriptor),
+ USBGenericDescriptor_ENDPOINT,
+ USBEndpointDescriptor_ADDRESS(
+ USBEndpointDescriptor_IN,
+ AUDDLoopRecDriverDescriptors_DATAIN),
+ USBEndpointDescriptor_ISOCHRONOUS,
+ AUDDLoopRecDriver_BYTESPERFRAME,
+ AUDDLoopRecDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms
+ 0, // This is not a synchronization endpoint
+ 0 // No associated synchronization endpoint
+ },
+ // Audio streaming endpoint class-specific descriptor
+ {
+ sizeof(AUDDataEndpointDescriptor),
+ AUDGenericDescriptor_ENDPOINT,
+ AUDDataEndpointDescriptor_SUBTYPE,
+ 0, // No attributes
+ 0, // Endpoint is not synchronized
+ 0 // Endpoint is not synchronized
+ }
+};
+
+/// HS Other Speed Configuration descriptors for a USB Audio Loop Record driver.
+const AUDDLoopRecDriverConfigurationDescriptors
+ fsOtherSpeedConfigurationDescriptors = {
+
+ // Configuration descriptor
+ {
+ sizeof(USBConfigurationDescriptor),
+ USBGenericDescriptor_OTHERSPEEDCONFIGURATION,
+ sizeof(AUDDLoopRecDriverConfigurationDescriptors),
+ 3, // This configuration has 3 interfaces
+ 1, // This is configuration #1
+ 0, // No string descriptor
+ BOARD_USB_BMATTRIBUTES,
+ USBConfigurationDescriptor_POWER(100)
+ },
+ // Audio control interface standard descriptor
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_CONTROL,
+ 0, // This is alternate setting #0
+ 0, // This interface uses no endpoint
+ AUDControlInterfaceDescriptor_CLASS,
+ AUDControlInterfaceDescriptor_SUBCLASS,
+ AUDControlInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio control interface descriptors
+ {
+ // Header descriptor
+ {
+ {
+ sizeof(AUDHeaderDescriptor2),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_HEADER,
+ AUDHeaderDescriptor_AUD1_00,
+ sizeof(AUDDLoopRecDriverAudioControlDescriptors),
+ 2 // Two streaming interface
+ },
+ AUDDLoopRecDriverDescriptors_STREAMING,
+ AUDDLoopRecDriverDescriptors_STREAMINGIN
+ },
+ // Input terminal descriptor ( speaker )
+ {
+ sizeof(AUDInputTerminalDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_INPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
+ AUDInputTerminalDescriptor_USBSTREAMING,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
+ AUDDLoopRecDriver_NUMCHANNELS,
+ #if AUDDLoopRecDriver_NUMCHANNELS > 1
+ AUDInputTerminalDescriptor_LEFTFRONT
+ | AUDInputTerminalDescriptor_RIGHTFRONT,
+ #else
+ 0, // Mono sets no position bits.
+ #endif
+ 0, // No string descriptor for channels
+ 0 // No string descriptor for input terminal
+ },
+ // Output terminal descriptor ( speaker )
+ {
+ sizeof(AUDOutputTerminalDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_OUTPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
+ AUDOutputTerminalDescriptor_SPEAKER,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_FEATUREUNIT,
+ 0 // No string descriptor
+ },
+ // Feature unit descriptor ( speaker )
+ {
+ {
+ sizeof(AUDFeatureUnitDescriptor3),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_FEATUREUNIT,
+ AUDDLoopRecDriverDescriptors_FEATUREUNIT,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
+ 1, // 1 byte per channel for controls
+ },
+ {
+ AUDFeatureUnitDescriptor_MUTE, // Master channel controls
+ 0, // Right channel controls
+ 0 // Left channel controls
+ },
+ 0 // No string descriptor
+ },
+ // Input terminal descriptor ( speakerphone )
+ {
+ sizeof(AUDInputTerminalDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_INPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
+ AUDInputTerminalDescriptor_SPEAKERPHONE,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
+ AUDDLoopRecDriver_NUMCHANNELS,
+ #if AUDDLoopRecDriver_NUMCHANNELS > 1
+ AUDInputTerminalDescriptor_LEFTFRONT
+ | AUDInputTerminalDescriptor_RIGHTFRONT,
+ #else
+ 0, // Mono sets no position bits.
+ #endif
+ 0, // No string descriptor for channels
+ 0 // No string descriptor for input terminal
+ },
+ // Output terminal descriptor ( speakerphone )
+ {
+ sizeof(AUDOutputTerminalDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_OUTPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
+ AUDOutputTerminalDescriptor_USBTREAMING,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
+ AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
+ 0 // No string descriptor
+ },
+ // Feature unit descriptor ( speakerphone )
+ {
+ {
+ sizeof(AUDFeatureUnitDescriptor3),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_FEATUREUNIT,
+ AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
+ 1
+ },
+ {
+ AUDFeatureUnitDescriptor_MUTE, // Mic controls
+ 0,
+ 0
+ },
+ 0 // No string descriptor
+ }
+ },
+ // - AUIDO OUT
+ // Audio streaming interface with 0 endpoints
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_STREAMING,
+ 0, // This is alternate setting #0
+ 0, // This interface uses no endpoints
+ AUDStreamingInterfaceDescriptor_CLASS,
+ AUDStreamingInterfaceDescriptor_SUBCLASS,
+ AUDStreamingInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio streaming interface with data endpoint
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_STREAMING,
+ 1, // This is alternate setting #1
+ 1, // This interface uses 1 endpoint
+ AUDStreamingInterfaceDescriptor_CLASS,
+ AUDStreamingInterfaceDescriptor_SUBCLASS,
+ AUDStreamingInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio streaming class-specific descriptor
+ {
+ sizeof(AUDStreamingInterfaceDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDStreamingInterfaceDescriptor_GENERAL,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
+ 0, // No internal delay because of data path
+ AUDFormatTypeOneDescriptor_PCM
+ },
+ // Format type I descriptor
+ {
+ {
+ sizeof(AUDFormatTypeOneDescriptor1),
+ AUDGenericDescriptor_INTERFACE,
+ AUDStreamingInterfaceDescriptor_FORMATTYPE,
+ AUDFormatTypeOneDescriptor_FORMATTYPEONE,
+ AUDDLoopRecDriver_NUMCHANNELS,
+ AUDDLoopRecDriver_BYTESPERSAMPLE,
+ AUDDLoopRecDriver_BYTESPERSAMPLE*8,
+ 1 // One discrete frequency supported
+ },
+ {
+ AUDDLoopRecDriver_SAMPLERATE & 0xFF,
+ (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
+ (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
+ }
+ },
+ // Audio streaming endpoint standard descriptor
+ {
+ sizeof(AUDEndpointDescriptor),
+ USBGenericDescriptor_ENDPOINT,
+ USBEndpointDescriptor_ADDRESS(
+ USBEndpointDescriptor_OUT,
+ AUDDLoopRecDriverDescriptors_DATAOUT),
+ USBEndpointDescriptor_ISOCHRONOUS,
+ AUDDLoopRecDriver_BYTESPERFRAME,
+ AUDDLoopRecDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms
+ 0, // This is not a synchronization endpoint
+ 0 // No associated synchronization endpoint
+ },
+ // Audio streaming endpoint class-specific descriptor
+ {
+ sizeof(AUDDataEndpointDescriptor),
+ AUDGenericDescriptor_ENDPOINT,
+ AUDDataEndpointDescriptor_SUBTYPE,
+ 0, // No attributes
+ 0, // Endpoint is not synchronized
+ 0 // Endpoint is not synchronized
+ },
+ //- AUDIO IN
+ // Audio streaming interface with 0 endpoints
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_STREAMINGIN,
+ 0, // This is alternate setting #0
+ 0, // This interface uses no endpoints
+ AUDStreamingInterfaceDescriptor_CLASS,
+ AUDStreamingInterfaceDescriptor_SUBCLASS,
+ AUDStreamingInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio streaming interface with data endpoint
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_STREAMINGIN,
+ 1, // This is alternate setting #1
+ 1, // This interface uses 1 endpoint
+ AUDStreamingInterfaceDescriptor_CLASS,
+ AUDStreamingInterfaceDescriptor_SUBCLASS,
+ AUDStreamingInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio streaming class-specific descriptor
+ {
+ sizeof(AUDStreamingInterfaceDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDStreamingInterfaceDescriptor_GENERAL,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
+ 0, // No internal delay because of data path
+ AUDFormatTypeOneDescriptor_PCM
+ },
+ // Format type I descriptor
+ {
+ {
+ sizeof(AUDFormatTypeOneDescriptor1),
+ AUDGenericDescriptor_INTERFACE,
+ AUDStreamingInterfaceDescriptor_FORMATTYPE,
+ AUDFormatTypeOneDescriptor_FORMATTYPEONE,
+ AUDDLoopRecDriver_NUMCHANNELS,
+ AUDDLoopRecDriver_BYTESPERSAMPLE,
+ AUDDLoopRecDriver_BYTESPERSAMPLE*8,
+ 1 // One discrete frequency supported
+ },
+ {
+ AUDDLoopRecDriver_SAMPLERATE & 0xFF,
+ (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
+ (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
+ }
+ },
+ // Audio streaming endpoint standard descriptor
+ {
+ sizeof(AUDEndpointDescriptor),
+ USBGenericDescriptor_ENDPOINT,
+ USBEndpointDescriptor_ADDRESS(
+ USBEndpointDescriptor_IN,
+ AUDDLoopRecDriverDescriptors_DATAIN),
+ USBEndpointDescriptor_ISOCHRONOUS,
+ AUDDLoopRecDriver_BYTESPERFRAME,
+ AUDDLoopRecDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms
+ 0, // This is not a synchronization endpoint
+ 0 // No associated synchronization endpoint
+ },
+ // Audio streaming endpoint class-specific descriptor
+ {
+ sizeof(AUDDataEndpointDescriptor),
+ AUDGenericDescriptor_ENDPOINT,
+ AUDDataEndpointDescriptor_SUBTYPE,
+ 0, // No attributes
+ 0, // Endpoint is not synchronized
+ 0 // Endpoint is not synchronized
+ }
+};
+
+/// HS Other Speed Configuration descriptors.
+const AUDDLoopRecDriverConfigurationDescriptors
+ hsOtherSpeedConfigurationDescriptors = {
+
+ // Configuration descriptor
+ {
+ sizeof(USBConfigurationDescriptor),
+ USBGenericDescriptor_OTHERSPEEDCONFIGURATION,
+ sizeof(AUDDLoopRecDriverConfigurationDescriptors),
+ 3, // This configuration has 3 interfaces
+ 1, // This is configuration #1
+ 0, // No string descriptor
+ BOARD_USB_BMATTRIBUTES,
+ USBConfigurationDescriptor_POWER(100)
+ },
+ // Audio control interface standard descriptor
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_CONTROL,
+ 0, // This is alternate setting #0
+ 0, // This interface uses no endpoint
+ AUDControlInterfaceDescriptor_CLASS,
+ AUDControlInterfaceDescriptor_SUBCLASS,
+ AUDControlInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio control interface descriptors
+ {
+ // Header descriptor
+ {
+ {
+ sizeof(AUDHeaderDescriptor2),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_HEADER,
+ AUDHeaderDescriptor_AUD1_00,
+ sizeof(AUDDLoopRecDriverAudioControlDescriptors),
+ 2 // Two streaming interface
+ },
+ AUDDLoopRecDriverDescriptors_STREAMING,
+ AUDDLoopRecDriverDescriptors_STREAMINGIN
+ },
+ // Input terminal descriptor ( speaker )
+ {
+ sizeof(AUDInputTerminalDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_INPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
+ AUDInputTerminalDescriptor_USBSTREAMING,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
+ AUDDLoopRecDriver_NUMCHANNELS,
+ #if AUDDLoopRecDriver_NUMCHANNELS > 1
+ AUDInputTerminalDescriptor_LEFTFRONT
+ | AUDInputTerminalDescriptor_RIGHTFRONT,
+ #else
+ 0, // Mono sets no position bits.
+ #endif
+ 0, // No string descriptor for channels
+ 0 // No string descriptor for input terminal
+ },
+ // Output terminal descriptor ( speaker )
+ {
+ sizeof(AUDOutputTerminalDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_OUTPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
+ AUDOutputTerminalDescriptor_SPEAKER,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_FEATUREUNIT,
+ 0 // No string descriptor
+ },
+ // Feature unit descriptor ( speaker )
+ {
+ {
+ sizeof(AUDFeatureUnitDescriptor3),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_FEATUREUNIT,
+ AUDDLoopRecDriverDescriptors_FEATUREUNIT,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
+ 1, // 1 byte per channel for controls
+ },
+ {
+ AUDFeatureUnitDescriptor_MUTE, // Master channel controls
+ 0, // Right channel controls
+ 0 // Left channel controls
+ },
+ 0 // No string descriptor
+ },
+ // Input terminal descriptor ( speakerphone )
+ {
+ sizeof(AUDInputTerminalDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_INPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
+ AUDInputTerminalDescriptor_SPEAKERPHONE,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
+ AUDDLoopRecDriver_NUMCHANNELS,
+ #if AUDDLoopRecDriver_NUMCHANNELS > 1
+ AUDInputTerminalDescriptor_LEFTFRONT
+ | AUDInputTerminalDescriptor_RIGHTFRONT,
+ #else
+ 0, // Mono sets no position bits.
+ #endif
+ 0, // No string descriptor for channels
+ 0 // No string descriptor for input terminal
+ },
+ // Output terminal descriptor ( speakerphone )
+ {
+ sizeof(AUDOutputTerminalDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_OUTPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
+ AUDOutputTerminalDescriptor_USBTREAMING,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
+ AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
+ 0 // No string descriptor
+ },
+ // Feature unit descriptor ( speakerphone )
+ {
+ {
+ sizeof(AUDFeatureUnitDescriptor3),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_FEATUREUNIT,
+ AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
+ 1
+ },
+ {
+ AUDFeatureUnitDescriptor_MUTE, // Mic controls
+ 0,
+ 0
+ },
+ 0 // No string descriptor
+ }
+ },
+ // - AUIDO OUT
+ // Audio streaming interface with 0 endpoints
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_STREAMING,
+ 0, // This is alternate setting #0
+ 0, // This interface uses no endpoints
+ AUDStreamingInterfaceDescriptor_CLASS,
+ AUDStreamingInterfaceDescriptor_SUBCLASS,
+ AUDStreamingInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio streaming interface with data endpoint
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_STREAMING,
+ 1, // This is alternate setting #1
+ 1, // This interface uses 1 endpoint
+ AUDStreamingInterfaceDescriptor_CLASS,
+ AUDStreamingInterfaceDescriptor_SUBCLASS,
+ AUDStreamingInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio streaming class-specific descriptor
+ {
+ sizeof(AUDStreamingInterfaceDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDStreamingInterfaceDescriptor_GENERAL,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
+ 0, // No internal delay because of data path
+ AUDFormatTypeOneDescriptor_PCM
+ },
+ // Format type I descriptor
+ {
+ {
+ sizeof(AUDFormatTypeOneDescriptor1),
+ AUDGenericDescriptor_INTERFACE,
+ AUDStreamingInterfaceDescriptor_FORMATTYPE,
+ AUDFormatTypeOneDescriptor_FORMATTYPEONE,
+ AUDDLoopRecDriver_NUMCHANNELS,
+ AUDDLoopRecDriver_BYTESPERSAMPLE,
+ AUDDLoopRecDriver_BYTESPERSAMPLE*8,
+ 1 // One discrete frequency supported
+ },
+ {
+ AUDDLoopRecDriver_SAMPLERATE & 0xFF,
+ (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
+ (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
+ }
+ },
+ // Audio streaming endpoint standard descriptor
+ {
+ sizeof(AUDEndpointDescriptor),
+ USBGenericDescriptor_ENDPOINT,
+ USBEndpointDescriptor_ADDRESS(
+ USBEndpointDescriptor_OUT,
+ AUDDLoopRecDriverDescriptors_DATAOUT),
+ USBEndpointDescriptor_ISOCHRONOUS,
+ AUDDLoopRecDriver_BYTESPERFRAME,
+ AUDDLoopRecDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms
+ 0, // This is not a synchronization endpoint
+ 0 // No associated synchronization endpoint
+ },
+ // Audio streaming endpoint class-specific descriptor
+ {
+ sizeof(AUDDataEndpointDescriptor),
+ AUDGenericDescriptor_ENDPOINT,
+ AUDDataEndpointDescriptor_SUBTYPE,
+ 0, // No attributes
+ 0, // Endpoint is not synchronized
+ 0 // Endpoint is not synchronized
+ },
+ //- AUDIO IN
+ // Audio streaming interface with 0 endpoints
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_STREAMINGIN,
+ 0, // This is alternate setting #0
+ 0, // This interface uses no endpoints
+ AUDStreamingInterfaceDescriptor_CLASS,
+ AUDStreamingInterfaceDescriptor_SUBCLASS,
+ AUDStreamingInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio streaming interface with data endpoint
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_STREAMINGIN,
+ 1, // This is alternate setting #1
+ 1, // This interface uses 1 endpoint
+ AUDStreamingInterfaceDescriptor_CLASS,
+ AUDStreamingInterfaceDescriptor_SUBCLASS,
+ AUDStreamingInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio streaming class-specific descriptor
+ {
+ sizeof(AUDStreamingInterfaceDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDStreamingInterfaceDescriptor_GENERAL,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
+ 0, // No internal delay because of data path
+ AUDFormatTypeOneDescriptor_PCM
+ },
+ // Format type I descriptor
+ {
+ {
+ sizeof(AUDFormatTypeOneDescriptor1),
+ AUDGenericDescriptor_INTERFACE,
+ AUDStreamingInterfaceDescriptor_FORMATTYPE,
+ AUDFormatTypeOneDescriptor_FORMATTYPEONE,
+ AUDDLoopRecDriver_NUMCHANNELS,
+ AUDDLoopRecDriver_BYTESPERSAMPLE,
+ AUDDLoopRecDriver_BYTESPERSAMPLE*8,
+ 1 // One discrete frequency supported
+ },
+ {
+ AUDDLoopRecDriver_SAMPLERATE & 0xFF,
+ (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
+ (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
+ }
+ },
+ // Audio streaming endpoint standard descriptor
+ {
+ sizeof(AUDEndpointDescriptor),
+ USBGenericDescriptor_ENDPOINT,
+ USBEndpointDescriptor_ADDRESS(
+ USBEndpointDescriptor_IN,
+ AUDDLoopRecDriverDescriptors_DATAIN),
+ USBEndpointDescriptor_ISOCHRONOUS,
+ AUDDLoopRecDriver_BYTESPERFRAME,
+ AUDDLoopRecDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms
+ 0, // This is not a synchronization endpoint
+ 0 // No associated synchronization endpoint
+ },
+ // Audio streaming endpoint class-specific descriptor
+ {
+ sizeof(AUDDataEndpointDescriptor),
+ AUDGenericDescriptor_ENDPOINT,
+ AUDDataEndpointDescriptor_SUBTYPE,
+ 0, // No attributes
+ 0, // Endpoint is not synchronized
+ 0 // Endpoint is not synchronized
+ }
+};
+
+#endif // defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)
+
+/// FS Configuration descriptors for a USB Audio Loop Record driver.
+const AUDDLoopRecDriverConfigurationDescriptors fsConfigurationDescriptors = {
+
+ // Configuration descriptor
+ {
+ sizeof(USBConfigurationDescriptor),
+ USBGenericDescriptor_CONFIGURATION,
+ sizeof(AUDDLoopRecDriverConfigurationDescriptors),
+ 3, // This configuration has 3 interfaces
+ 1, // This is configuration #1
+ 0, // No string descriptor
+ BOARD_USB_BMATTRIBUTES,
+ USBConfigurationDescriptor_POWER(100)
+ },
+ // Audio control interface standard descriptor
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_CONTROL,
+ 0, // This is alternate setting #0
+ 0, // This interface uses no endpoint
+ AUDControlInterfaceDescriptor_CLASS,
+ AUDControlInterfaceDescriptor_SUBCLASS,
+ AUDControlInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio control interface descriptors
+ {
+ // Header descriptor
+ {
+ {
+ sizeof(AUDHeaderDescriptor2),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_HEADER,
+ AUDHeaderDescriptor_AUD1_00,
+ sizeof(AUDDLoopRecDriverAudioControlDescriptors),
+ 2 // Two streaming interface
+ },
+ AUDDLoopRecDriverDescriptors_STREAMING,
+ AUDDLoopRecDriverDescriptors_STREAMINGIN
+ },
+ // Input terminal descriptor ( speaker )
+ {
+ sizeof(AUDInputTerminalDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_INPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
+ AUDInputTerminalDescriptor_USBSTREAMING,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
+ AUDDLoopRecDriver_NUMCHANNELS,
+ #if AUDDLoopRecDriver_NUMCHANNELS > 1
+ AUDInputTerminalDescriptor_LEFTFRONT
+ | AUDInputTerminalDescriptor_RIGHTFRONT,
+ #else
+ 0, // Mono sets no position bits.
+ #endif
+ 0, // No string descriptor for channels
+ 0 // No string descriptor for input terminal
+ },
+ // Output terminal descriptor ( speaker )
+ {
+ sizeof(AUDOutputTerminalDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_OUTPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
+ AUDOutputTerminalDescriptor_SPEAKER,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_FEATUREUNIT,
+ 0 // No string descriptor
+ },
+ // Feature unit descriptor ( speaker )
+ {
+ {
+ sizeof(AUDFeatureUnitDescriptor3),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_FEATUREUNIT,
+ AUDDLoopRecDriverDescriptors_FEATUREUNIT,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
+ 1, // 1 byte per channel for controls
+ },
+ {
+ AUDFeatureUnitDescriptor_MUTE, // Master channel controls
+ 0, // Right channel controls
+ 0 // Left channel controls
+ },
+ 0 // No string descriptor
+ },
+ // Input terminal descriptor ( speakerphone )
+ {
+ sizeof(AUDInputTerminalDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_INPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
+ AUDInputTerminalDescriptor_SPEAKERPHONE,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
+ AUDDLoopRecDriver_NUMCHANNELS,
+ #if AUDDLoopRecDriver_NUMCHANNELS > 1
+ AUDInputTerminalDescriptor_LEFTFRONT
+ | AUDInputTerminalDescriptor_RIGHTFRONT,
+ #else
+ 0, // Mono sets no position bits.
+ #endif
+ 0, // No string descriptor for channels
+ 0 // No string descriptor for input terminal
+ },
+ // Output terminal descriptor ( speakerphone )
+ {
+ sizeof(AUDOutputTerminalDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_OUTPUTTERMINAL,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
+ AUDOutputTerminalDescriptor_USBTREAMING,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
+ AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
+ 0 // No string descriptor
+ },
+ // Feature unit descriptor ( speakerphone )
+ {
+ {
+ sizeof(AUDFeatureUnitDescriptor3),
+ AUDGenericDescriptor_INTERFACE,
+ AUDGenericDescriptor_FEATUREUNIT,
+ AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
+ 1
+ },
+ {
+ AUDFeatureUnitDescriptor_MUTE, // Mic controls
+ 0,
+ 0
+ },
+ 0 // No string descriptor
+ }
+ },
+ // - AUIDO OUT
+ // Audio streaming interface with 0 endpoints
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_STREAMING,
+ 0, // This is alternate setting #0
+ 0, // This interface uses no endpoints
+ AUDStreamingInterfaceDescriptor_CLASS,
+ AUDStreamingInterfaceDescriptor_SUBCLASS,
+ AUDStreamingInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio streaming interface with data endpoint
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_STREAMING,
+ 1, // This is alternate setting #1
+ 1, // This interface uses 1 endpoint
+ AUDStreamingInterfaceDescriptor_CLASS,
+ AUDStreamingInterfaceDescriptor_SUBCLASS,
+ AUDStreamingInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio streaming class-specific descriptor
+ {
+ sizeof(AUDStreamingInterfaceDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDStreamingInterfaceDescriptor_GENERAL,
+ AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
+ 0, // No internal delay because of data path
+ AUDFormatTypeOneDescriptor_PCM
+ },
+ // Format type I descriptor
+ {
+ {
+ sizeof(AUDFormatTypeOneDescriptor1),
+ AUDGenericDescriptor_INTERFACE,
+ AUDStreamingInterfaceDescriptor_FORMATTYPE,
+ AUDFormatTypeOneDescriptor_FORMATTYPEONE,
+ AUDDLoopRecDriver_NUMCHANNELS,
+ AUDDLoopRecDriver_BYTESPERSAMPLE,
+ AUDDLoopRecDriver_BYTESPERSAMPLE*8,
+ 1 // One discrete frequency supported
+ },
+ {
+ AUDDLoopRecDriver_SAMPLERATE & 0xFF,
+ (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
+ (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
+ }
+ },
+ // Audio streaming endpoint standard descriptor
+ {
+ sizeof(AUDEndpointDescriptor),
+ USBGenericDescriptor_ENDPOINT,
+ USBEndpointDescriptor_ADDRESS(
+ USBEndpointDescriptor_OUT,
+ AUDDLoopRecDriverDescriptors_DATAOUT),
+ USBEndpointDescriptor_ISOCHRONOUS,
+ AUDDLoopRecDriver_BYTESPERFRAME,
+ AUDDLoopRecDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms
+ 0, // This is not a synchronization endpoint
+ 0 // No associated synchronization endpoint
+ },
+ // Audio streaming endpoint class-specific descriptor
+ {
+ sizeof(AUDDataEndpointDescriptor),
+ AUDGenericDescriptor_ENDPOINT,
+ AUDDataEndpointDescriptor_SUBTYPE,
+ 0, // No attributes
+ 0, // Endpoint is not synchronized
+ 0 // Endpoint is not synchronized
+ },
+ //- AUDIO IN
+ // Audio streaming interface with 0 endpoints
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_STREAMINGIN,
+ 0, // This is alternate setting #0
+ 0, // This interface uses no endpoints
+ AUDStreamingInterfaceDescriptor_CLASS,
+ AUDStreamingInterfaceDescriptor_SUBCLASS,
+ AUDStreamingInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio streaming interface with data endpoint
+ {
+ sizeof(USBInterfaceDescriptor),
+ USBGenericDescriptor_INTERFACE,
+ AUDDLoopRecDriverDescriptors_STREAMINGIN,
+ 1, // This is alternate setting #1
+ 1, // This interface uses 1 endpoint
+ AUDStreamingInterfaceDescriptor_CLASS,
+ AUDStreamingInterfaceDescriptor_SUBCLASS,
+ AUDStreamingInterfaceDescriptor_PROTOCOL,
+ 0 // No string descriptor
+ },
+ // Audio streaming class-specific descriptor
+ {
+ sizeof(AUDStreamingInterfaceDescriptor),
+ AUDGenericDescriptor_INTERFACE,
+ AUDStreamingInterfaceDescriptor_GENERAL,
+ AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
+ 0, // No internal delay because of data path
+ AUDFormatTypeOneDescriptor_PCM
+ },
+ // Format type I descriptor
+ {
+ {
+ sizeof(AUDFormatTypeOneDescriptor1),
+ AUDGenericDescriptor_INTERFACE,
+ AUDStreamingInterfaceDescriptor_FORMATTYPE,
+ AUDFormatTypeOneDescriptor_FORMATTYPEONE,
+ AUDDLoopRecDriver_NUMCHANNELS,
+ AUDDLoopRecDriver_BYTESPERSAMPLE,
+ AUDDLoopRecDriver_BYTESPERSAMPLE*8,
+ 1 // One discrete frequency supported
+ },
+ {
+ AUDDLoopRecDriver_SAMPLERATE & 0xFF,
+ (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
+ (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
+ }
+ },
+ // Audio streaming endpoint standard descriptor
+ {
+ sizeof(AUDEndpointDescriptor),
+ USBGenericDescriptor_ENDPOINT,
+ USBEndpointDescriptor_ADDRESS(
+ USBEndpointDescriptor_IN,
+ AUDDLoopRecDriverDescriptors_DATAIN),
+ USBEndpointDescriptor_ISOCHRONOUS,
+ AUDDLoopRecDriver_BYTESPERFRAME,
+ AUDDLoopRecDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms
+ 0, // This is not a synchronization endpoint
+ 0 // No associated synchronization endpoint
+ },
+ // Audio streaming endpoint class-specific descriptor
+ {
+ sizeof(AUDDataEndpointDescriptor),
+ AUDGenericDescriptor_ENDPOINT,
+ AUDDataEndpointDescriptor_SUBTYPE,
+ 0, // No attributes
+ 0, // Endpoint is not synchronized
+ 0 // Endpoint is not synchronized
+ }
+};
+
+/// String descriptor with the supported languages.
+const unsigned char languageIdDescriptor[] = {
+
+ USBStringDescriptor_LENGTH(1),
+ USBGenericDescriptor_STRING,
+ USBStringDescriptor_ENGLISH_US
+};
+
+/// Manufacturer name.
+const unsigned char manufacturerDescriptor[] = {
+
+ USBStringDescriptor_LENGTH(5),
+ USBGenericDescriptor_STRING,
+ USBStringDescriptor_UNICODE('A'),
+ USBStringDescriptor_UNICODE('t'),
+ USBStringDescriptor_UNICODE('m'),
+ USBStringDescriptor_UNICODE('e'),
+ USBStringDescriptor_UNICODE('l')
+};
+
+/// Product name.
+const unsigned char productDescriptor[] = {
+
+ USBStringDescriptor_LENGTH(15),
+ USBGenericDescriptor_STRING,
+ USBStringDescriptor_UNICODE('D'),
+ USBStringDescriptor_UNICODE('e'),
+ USBStringDescriptor_UNICODE('s'),
+ USBStringDescriptor_UNICODE('k'),
+ USBStringDescriptor_UNICODE('t'),
+ USBStringDescriptor_UNICODE('o'),
+ USBStringDescriptor_UNICODE('p'),
+ USBStringDescriptor_UNICODE(' '),
+ USBStringDescriptor_UNICODE('s'),
+ USBStringDescriptor_UNICODE('p'),
+ USBStringDescriptor_UNICODE('e'),
+ USBStringDescriptor_UNICODE('a'),
+ USBStringDescriptor_UNICODE('k'),
+ USBStringDescriptor_UNICODE('e'),
+ USBStringDescriptor_UNICODE('r')
+};
+
+/// Product serial number.
+const unsigned char serialNumberDescriptor[] = {
+
+ USBStringDescriptor_LENGTH(4),
+ USBGenericDescriptor_STRING,
+ USBStringDescriptor_UNICODE('0'),
+ USBStringDescriptor_UNICODE('1'),
+ USBStringDescriptor_UNICODE('2'),
+ USBStringDescriptor_UNICODE('3')
+};
+
+/// Array of pointers to the four string descriptors.
+const unsigned char *stringDescriptors[] = {
+
+ languageIdDescriptor,
+ manufacturerDescriptor,
+ productDescriptor,
+ serialNumberDescriptor,
+};
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+
+/// List of descriptors required by an USB Audio Loop Recorder device driver.
+const USBDDriverDescriptors auddLoopRecDriverDescriptors = {
+
+ &deviceDescriptor,
+ (const USBConfigurationDescriptor *) &fsConfigurationDescriptors,
+#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)
+ &qualifierDescriptor,
+ (const USBConfigurationDescriptor *) &fsOtherSpeedConfigurationDescriptors,
+ &deviceDescriptor,
+ (const USBConfigurationDescriptor *) &hsConfigurationDescriptors,
+ &qualifierDescriptor,
+ (const USBConfigurationDescriptor *) &hsOtherSpeedConfigurationDescriptors,
+#else
+ 0, 0, 0, 0, 0, 0,
+#endif
+ stringDescriptors,
+ 4 // Number of string descriptors
+};
+
diff --git a/usb/device/audio-looprec/AUDDLoopRecDriverDescriptors.h b/usb/device/audio-looprec/AUDDLoopRecDriverDescriptors.h new file mode 100644 index 0000000..4b333d7 --- /dev/null +++ b/usb/device/audio-looprec/AUDDLoopRecDriverDescriptors.h @@ -0,0 +1,148 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/**
+ \unit
+
+ !!!Purpose
+
+ Declaration of the descriptors required by a USB audio speaker driver.
+
+ !!!Usage
+
+ -# Initialize a USBDDriver instance using the
+ auddSpeakerDriverDescriptors list.
+*/
+
+#ifndef AUDDLOOPRECDESCRIPTORS_H
+#define AUDDLOOPRECDESCRIPTORS_H
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include <board.h>
+#include <usb/device/core/USBDDriverDescriptors.h>
+
+//------------------------------------------------------------------------------
+// Definitions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "Audio Speaker Endpoint Numbers"
+///
+/// This page lists the endpoint number settings for USB Audio Speaker device.
+///
+/// !Endpoints
+/// - AUDDLoopRecDriverDescriptors_DATAOUT
+/// - AUDDLoopRecDriverDescriptors_DATAIN
+/// - AUDDLoopRecDriverDescriptors_HS_INTERVAL
+/// - AUDDLoopRecDriverDescriptors_FS_INTERVAL
+
+#if defined(at91sam7s) || defined(at91sam9xe)
+ /// Data out endpoint number, size 64B.
+ #define AUDDLoopRecDriverDescriptors_DATAOUT 0x01
+ /// Data in endpoint number, size 64B
+ #define AUDDLoopRecDriverDescriptors_DATAIN 0x02
+#elif defined(CHIP_USB_UDP)
+ /// Data out endpoint number, size 192B.
+ #define AUDDLoopRecDriverDescriptors_DATAOUT 0x04
+ /// Data in endpoint number, size 192B.
+ #define AUDDLoopRecDriverDescriptors_DATAIN 0x05
+#elif defined(at91sam9m10ek) || defined(at91sam9m10ekes)
+ /// Data out endpoint number, size 192B.
+ #define AUDDLoopRecDriverDescriptors_DATAOUT 0x01
+ /// Data in endpoint number, size 192B
+ #define AUDDLoopRecDriverDescriptors_DATAIN 0x06
+#else
+ /// Data out endpoint number, size 192B.
+ #define AUDDLoopRecDriverDescriptors_DATAOUT 0x05
+ /// Data in endpoint number, size 192B
+ #define AUDDLoopRecDriverDescriptors_DATAIN 0x06
+#endif
+
+/// Endpoint polling interval 2^(x-1) * 125us
+#define AUDDLoopRecDriverDescriptors_HS_INTERVAL 0x04
+/// Endpoint polling interval 2^(x-1) * ms
+#define AUDDLoopRecDriverDescriptors_FS_INTERVAL 0x01
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "Audio Speaker Interface IDs"
+///
+/// This page lists the interface numbers for USB Audio Speaker device.
+///
+/// !Interfaces
+/// - AUDDLoopRecDriverDescriptors_CONTROL
+/// - AUDDLoopRecDriverDescriptors_STREAMING
+/// - AUDDLoopRecDriverDescriptors_STREAMINGIN
+
+/// Audio control interface ID.
+#define AUDDLoopRecDriverDescriptors_CONTROL 0
+/// Audio streaming interface ID (OUT, for playback).
+#define AUDDLoopRecDriverDescriptors_STREAMING 1
+/// Audio streaming interface ID (IN, for record).
+#define AUDDLoopRecDriverDescriptors_STREAMINGIN 2
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "Audio Speaker Entity IDs"
+///
+/// This page lists the entity IDs for USB Audio Speaker device.
+///
+/// !Entities
+/// - AUDDLoopRecDriverDescriptors_INPUTTERMINAL
+/// - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL
+/// - AUDDLoopRecDriverDescriptors_FEATUREUNIT
+/// - AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC
+/// - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC
+/// - AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC
+
+/// Playback input terminal ID.
+#define AUDDLoopRecDriverDescriptors_INPUTTERMINAL 0
+/// Playback output terminal ID.
+#define AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL 1
+/// Playback feature unit ID.
+#define AUDDLoopRecDriverDescriptors_FEATUREUNIT 2
+/// Record input terminal ID.
+#define AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC 3
+/// Record output terminal ID.
+#define AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC 4
+/// Record feature unit ID
+#define AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC 5
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// Exported variables
+//------------------------------------------------------------------------------
+
+extern const USBDDriverDescriptors auddLoopRecDriverDescriptors;
+
+#endif //#ifndef AUDDLOOPRECDESCRIPTORS_H
+
diff --git a/usb/device/audio-looprec/audio-looprec.dir b/usb/device/audio-looprec/audio-looprec.dir new file mode 100644 index 0000000..bbd6c6a --- /dev/null +++ b/usb/device/audio-looprec/audio-looprec.dir @@ -0,0 +1,51 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+//------------------------------------------------------------------------------
+/// \dir
+///
+/// !!!Purpose
+///
+/// This directory provides definitions, structs and functions for a USB Audio
+/// Class device - USB audio-looprec demo, to implement an USB desktop speaker
+/// which echos audio stream back to host.
+///
+/// !!!Contents
+/// There are two things for the implement of the audio-speaker device driver:
+/// - Implement the audio-looprec driver structs and functions for the device,
+/// to initialize, to handle audio class specific requests and dispach
+/// standard requests in USBD callbacks, to read/write through assigned USB
+/// endpoints,
+/// - Create the audio-speaker device's descriptors that should be passed to
+/// the USBDDriver instance on initialization, so that the host can
+/// recognize the device as a USB audio "desktop speaker" device.
+///
+/// This project is simply addon to the audio speaker demo. For more
+/// information, please refer to "USB Audio Speaker Device".
+//------------------------------------------------------------------------------
\ No newline at end of file |