SAMV71 Xplained Ultra Software Package 1.4

CDCAUDDDriver.h

Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------------
00002  *         SAM Software Package License 
00003  * ----------------------------------------------------------------------------
00004  * Copyright (c) 2014, Atmel Corporation
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *
00011  * - Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the disclaimer below.
00013  *
00014  * Atmel's name may not be used to endorse or promote products derived from
00015  * this software without specific prior written permission.
00016  *
00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  * ----------------------------------------------------------------------------
00028  */
00029 
00030 /**
00031  * \file
00032  *
00033  * \section Purpose
00034  *
00035  *   Definitions and methods for USB composite device implement.
00036  * 
00037  */
00038 
00039 #ifndef CDCAUDDDRIVER_H
00040 #define CDCAUDDDRIVER_H
00041 /** \addtogroup usbd_composite_cdcaud
00042  *@{
00043  */
00044 
00045 /*---------------------------------------------------------------------------
00046  *         Headers
00047  *---------------------------------------------------------------------------*/
00048 
00049 #include <USBRequests.h>
00050 #include <CDCDescriptors.h>
00051 #include <AUDDescriptors.h>
00052 #include "USBD.h"
00053 #include <USBDDriver.h>
00054 
00055 /*---------------------------------------------------------------------------
00056  *         Definitions
00057  *---------------------------------------------------------------------------*/
00058 
00059 /** \addtogroup usbd_cdc_aud_desc USB CDC(Serial) + AUD(Speaker) Definitions
00060  *      @{
00061  */
00062 /** Number of interfaces of the device (5, can be 4 if no mic support */
00063 #define CDCAUDDDriverDescriptors_MaxNumInterfaces   5
00064 /** Number of the CDC interface. */
00065 #define CDCAUDDDriverDescriptors_CDC_INTERFACE      0
00066 /** Number of the Audio interface. */
00067 #define CDCAUDDDriverDescriptors_AUD_INTERFACE      2
00068 /** Number of Audio function channels (M,L,R) */
00069 #define AUDD_NumChannels                            3
00070 /**     @}*/
00071 
00072 /*---------------------------------------------------------------------------
00073  *         Types
00074  *---------------------------------------------------------------------------*/
00075 #pragma pack(1)
00076 #if defined   ( __CC_ARM   ) /* Keil ¦̀Vision 4 */
00077 #elif defined ( __ICCARM__ ) /* IAR Ewarm */
00078 #define __attribute__(...)
00079 #define __packed__  packed
00080 #elif defined (  __GNUC__  ) /* GCC CS3 */
00081 #define __packed__  aligned(1)
00082 #endif
00083 
00084 /** Audio header descriptor with 1 interface */
00085 typedef struct _AUDHeaderDescriptor1{
00086 
00087     /** Header descriptor.*/
00088     AUDHeaderDescriptor header;
00089     /** Id of the first grouped interface.*/
00090     uint8_t bInterface0;
00091 
00092 } __attribute__ ((__packed__)) AUDHeaderDescriptor1;
00093 
00094 /** Audio header descriptor with 2 interface */
00095 typedef struct _AUDHeaderDescriptor2 {
00096 
00097     /** Header descriptor. */
00098     AUDHeaderDescriptor header;
00099     /** Id of the first grouped interface - Speaker. */
00100     uint8_t bInterface0;
00101     /** Id of the second grouped interface - Speakerphone. */
00102     uint8_t bInterface1;
00103 
00104 } __attribute__ ((__packed__)) AUDHeaderDescriptor2; /* GCC */
00105 
00106 /**
00107  * Feature unit descriptor with 3 channel controls (master, right, left).
00108  */
00109 typedef struct _AUDFeatureUnitDescriptor3{
00110 
00111     /** Feature unit descriptor.*/
00112     AUDFeatureUnitDescriptor feature;
00113     /** Available controls for each channel.*/
00114     uint8_t bmaControls[AUDD_NumChannels];
00115     /** Index of a string descriptor for the feature unit.*/
00116     uint8_t iFeature;
00117 
00118 } __attribute__ ((__packed__)) AUDFeatureUnitDescriptor3;
00119 
00120 /**
00121  * List of descriptors for detailing the audio control interface of a
00122  * device using a USB audio speaker function.
00123  */
00124 typedef struct _AUDDSpeakerAcDescriptors{
00125 
00126     /** Header descriptor (with one slave interface).*/
00127     AUDHeaderDescriptor1 header;
00128     /** Input terminal descriptor.*/
00129     AUDInputTerminalDescriptor input;
00130     /** Output terminal descriptor.*/
00131     AUDOutputTerminalDescriptor output;
00132     /** Feature unit descriptor.*/
00133     AUDFeatureUnitDescriptor3 feature;
00134 
00135 } __attribute__ ((__packed__)) AUDDSpeakerAcDescriptors;
00136 
00137 /**
00138  * List of descriptors for detailing the audio control interface of a
00139  * device using a USB Audio Speakerphoneer function.
00140  */
00141 typedef struct _AUDDSpeakerPhoneAcDescriptors {
00142 
00143     /** Header descriptor (with one slave interface). */
00144     AUDHeaderDescriptor2 header;
00145     /** Input terminal descriptor. */
00146     AUDInputTerminalDescriptor inputSpeakerPhone;
00147     /** Output terminal descriptor. */
00148     AUDOutputTerminalDescriptor outputSpeakerPhone;
00149     /** Feature unit descriptor - SpeakerPhone. */
00150     AUDFeatureUnitDescriptor3 featureSpeakerPhone;
00151     /** Input terminal descriptor. */
00152     AUDInputTerminalDescriptor inputRec;
00153     /** Output terminal descriptor. */
00154     AUDOutputTerminalDescriptor outputRec;
00155     /** Feature unit descriptor - SpeakerPhonephone. */
00156     AUDFeatureUnitDescriptor3 featureRec;
00157 
00158 } __attribute__ ((__packed__)) AUDDSpeakerPhoneAcDescriptors;
00159 
00160 /**
00161  * Format type I descriptor with one discrete sampling frequency.
00162  */
00163 typedef struct _AUDFormatTypeOneDescriptor1{
00164 
00165     /** Format type I descriptor.*/
00166     AUDFormatTypeOneDescriptor formatType;
00167     /** Sampling frequency in Hz.*/
00168     uint8_t tSamFreq[3];
00169 
00170 } __attribute__ ((__packed__)) AUDFormatTypeOneDescriptor1;
00171 
00172 /**
00173  * Configuration descriptor list for a device implementing
00174  * CDC(Serial) + Audio(Speaker) composite driver.
00175  */
00176 typedef struct _CdcAudspkdDriverConfigurationDescriptors {
00177 
00178     /** Standard configuration descriptor. */
00179     USBConfigurationDescriptor configuration;
00180 
00181     /* --- CDC 0 */
00182     /** IAD 0 */
00183     USBInterfaceAssociationDescriptor cdcIAD0;
00184     /** Communication interface descriptor */
00185     USBInterfaceDescriptor cdcCommunication0;
00186     /** CDC header functional descriptor. */
00187     CDCHeaderDescriptor cdcHeader0;
00188     /** CDC call management functional descriptor. */
00189     CDCCallManagementDescriptor cdcCallManagement0;
00190     /** CDC abstract control management functional descriptor. */
00191     CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;
00192     /** CDC union functional descriptor (with one slave interface). */
00193     CDCUnionDescriptor cdcUnion0;
00194     /** Notification endpoint descriptor. */
00195     USBEndpointDescriptor cdcNotification0;
00196     /** Data interface descriptor. */
00197     USBInterfaceDescriptor cdcData0;
00198     /** Data OUT endpoint descriptor. */
00199     USBEndpointDescriptor cdcDataOut0;
00200     /** Data IN endpoint descriptor. */
00201     USBEndpointDescriptor cdcDataIn0;
00202 
00203     /* --- AUDIO (AC) */
00204     /** IAD 1*/
00205     USBInterfaceAssociationDescriptor audIAD;
00206     /** Audio control interface.*/
00207     USBInterfaceDescriptor audInterface;
00208     /** Descriptors for the audio control interface.*/
00209     AUDDSpeakerAcDescriptors audControl;
00210     /* -- AUDIO out (AS) */
00211     /** Streaming out interface descriptor (with no endpoint, required).*/
00212     USBInterfaceDescriptor audStreamingOutNoIsochronous;
00213     /** Streaming out interface descriptor.*/
00214     USBInterfaceDescriptor audStreamingOut;
00215     /** Audio class descriptor for the streaming out interface.*/
00216     AUDStreamingInterfaceDescriptor audStreamingOutClass;
00217     /** Stream format descriptor.*/
00218     AUDFormatTypeOneDescriptor1 audStreamingOutFormatType;
00219     /** Streaming out endpoint descriptor.*/
00220     AUDEndpointDescriptor audStreamingOutEndpoint;
00221     /** Audio class descriptor for the streaming out endpoint.*/
00222     AUDDataEndpointDescriptor audStreamingOutDataEndpoint;
00223 
00224 } __attribute__ ((__packed__)) CdcAudspkdDriverConfigurationDescriptors;
00225 
00226 /**
00227  * Configuration descriptor list for a device implementing
00228  * CDC(Serial) + Audio(SpeakerPhone) composite driver.
00229  */
00230 typedef struct _CdcAuddDriverConfigurationDescriptors {
00231 
00232     /** Standard configuration descriptor. */
00233     USBConfigurationDescriptor configuration;
00234 
00235     /* --- CDC 0 */
00236     /** IAD 0 */
00237     USBInterfaceAssociationDescriptor cdcIAD0;
00238     /** Communication interface descriptor */
00239     USBInterfaceDescriptor cdcCommunication0;
00240     /** CDC header functional descriptor. */
00241     CDCHeaderDescriptor cdcHeader0;
00242     /** CDC call management functional descriptor. */
00243     CDCCallManagementDescriptor cdcCallManagement0;
00244     /** CDC abstract control management functional descriptor. */
00245     CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;
00246     /** CDC union functional descriptor (with one slave interface). */
00247     CDCUnionDescriptor cdcUnion0;
00248     /** Notification endpoint descriptor. */
00249     USBEndpointDescriptor cdcNotification0;
00250     /** Data interface descriptor. */
00251     USBInterfaceDescriptor cdcData0;
00252     /** Data OUT endpoint descriptor. */
00253     USBEndpointDescriptor cdcDataOut0;
00254     /** Data IN endpoint descriptor. */
00255     USBEndpointDescriptor cdcDataIn0;
00256 
00257     /* --- AUDIO (AC) */
00258     /** IAD 1*/
00259     USBInterfaceAssociationDescriptor audIAD;
00260     /** Audio control interface.*/
00261     USBInterfaceDescriptor audInterface;
00262     /** Descriptors for the audio control interface.*/
00263     AUDDSpeakerPhoneAcDescriptors audControl;
00264     /* -- AUDIO out (AS) */
00265     /** Streaming out interface descriptor (with no endpoint, required).*/
00266     USBInterfaceDescriptor audStreamingOutNoIsochronous;
00267     /** Streaming out interface descriptor.*/
00268     USBInterfaceDescriptor audStreamingOut;
00269     /** Audio class descriptor for the streaming out interface.*/
00270     AUDStreamingInterfaceDescriptor audStreamingOutClass;
00271     /** Stream format descriptor.*/
00272     AUDFormatTypeOneDescriptor1 audStreamingOutFormatType;
00273     /** Streaming out endpoint descriptor.*/
00274     AUDEndpointDescriptor audStreamingOutEndpoint;
00275     /** Audio class descriptor for the streaming out endpoint.*/
00276     AUDDataEndpointDescriptor audStreamingOutDataEndpoint;
00277     /*- AUDIO IN */
00278     /** Streaming in interface descriptor (with no endpoint, required). */
00279     USBInterfaceDescriptor streamingInNoIsochronous;
00280     /** Streaming in interface descriptor. */
00281     USBInterfaceDescriptor streamingIn;
00282     /** Audio class descriptor for the streaming in interface. */
00283     AUDStreamingInterfaceDescriptor streamingInClass;
00284     /** Stream format descriptor. */
00285     AUDFormatTypeOneDescriptor1 streamingInFormatType;
00286     /** Streaming in endpoint descriptor. */
00287     AUDEndpointDescriptor streamingInEndpoint;
00288     /** Audio class descriptor for the streaming in endpoint. */
00289     AUDDataEndpointDescriptor streamingInDataEndpoint;
00290 
00291 } __attribute__ ((__packed__)) CdcAuddDriverConfigurationDescriptors;
00292 
00293 #pragma pack()
00294 
00295 /*---------------------------------------------------------------------------
00296  *         Exported functions
00297  *---------------------------------------------------------------------------*/
00298 
00299 extern void CDCAUDDDriver_Initialize(const USBDDriverDescriptors * pDescriptors);
00300 extern void CDCAUDDDriver_ConfigurationChangedHandler(uint8_t cfgnum);
00301 extern void CDCAUDDDriver_InterfaceSettingChangedHandler(
00302     uint8_t interface, uint8_t setting);
00303 extern void CDCAUDDDriver_RequestHandler(const USBGenericRequest *request);
00304 
00305 /**@}*/
00306 #endif //#ifndef CDCHIDDDRIVER_H
00307 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines