SAMV71 Xplained Ultra Software Package 1.5

AUDDStream.h

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------- */
00002 /*                  Atmel Microcontroller Software Support                      */
00003 /*                       SAM Software Package License                           */
00004 /* ---------------------------------------------------------------------------- */
00005 /* Copyright (c) 2015, Atmel Corporation                                        */
00006 /*                                                                              */
00007 /* All rights reserved.                                                         */
00008 /*                                                                              */
00009 /* Redistribution and use in source and binary forms, with or without           */
00010 /* modification, are permitted provided that the following condition is met:    */
00011 /*                                                                              */
00012 /* - Redistributions of source code must retain the above copyright notice,     */
00013 /* this list of conditions and the disclaimer below.                            */
00014 /*                                                                              */
00015 /* Atmel's name may not be used to endorse or promote products derived from     */
00016 /* this software without specific prior written permission.                     */
00017 /*                                                                              */
00018 /* DISCLAIMER:  THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR   */
00019 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
00020 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE   */
00021 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,      */
00022 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
00023 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,  */
00024 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
00025 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING         */
00026 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
00027 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                           */
00028 /* ---------------------------------------------------------------------------- */
00029 
00030 /** \file
00031  *  USB Audio Device Streaming interface with controls.
00032  *  (3 channels (including master) supported).
00033  */
00034 
00035 /** \addtogroup usbd_audio_speakerphone
00036  *@{
00037  *  Implement speakerphone function that combine 1 AC interface, 1 AS interface
00038  *  for speaker and 1 AS interface for microphone.
00039  */
00040 
00041 #ifndef _AUDD_STREAM_H_
00042 #define _AUDD_STREAM_H_
00043 
00044 /*------------------------------------------------------------------------------
00045  *         Headers
00046  *------------------------------------------------------------------------------*/
00047 
00048 #include <stdint.h>
00049 
00050 #include "USBD.h"
00051 #include <USBDDriver.h>
00052 
00053 /*------------------------------------------------------------------------------
00054  *         Defines
00055  *------------------------------------------------------------------------------*/
00056 
00057 /** \addtopage usbd_audio_ec Audio Device Event codes
00058  *      @{
00059  */
00060 /** Mute status changed */
00061 #define AUDD_EC_MuteChanged         1
00062 /** Volume status changed */
00063 #define AUDD_EC_VolumeChanged       2
00064 /**     @}*/
00065 
00066 /*------------------------------------------------------------------------------
00067  *         Types
00068  *------------------------------------------------------------------------------*/
00069 
00070 /** Callback function for Audio Stream Event */
00071 typedef void (*AUDDStreamEventCallback)(uint32_t ec,
00072                                         uint8_t  channel,
00073                                         void* pArg);
00074 
00075 /**
00076  * Struct of USB Audio Stream Interface.
00077  * Support 1 control interface, with I & O stream.
00078  * Unit ID 0xFF is reserved for not implemented.
00079  */
00080 typedef struct _AUDDStream {
00081     /** AudioControl Interface number */
00082     uint8_t     bAcInterface;
00083     /** AudioControl Feature Unit ID for IN */
00084     uint8_t     bFeatureUnitOut;
00085     /** AudioControl Feature Unit ID for OUT */
00086     uint8_t     bFeatureUnitIn;
00087     /** AudioStreaming Interface number */
00088     uint8_t     bAsInterface;
00089     /** Streaming OUT endpoint address */
00090     uint8_t     bEndpointOut;
00091     /** Streaming IN  endpoint address */
00092     uint8_t     bEndpointIn;
00093     /** Number of channels (<=8) */
00094     uint8_t     bNumChannels;
00095     /** Mute control bits  (8b) */
00096     uint8_t     bmMute;
00097     /** Volume control data */
00098     uint16_t   *pwVolumes;
00099 
00100     /** Audio Streaming Events Callback */
00101     AUDDStreamEventCallback fCallback;
00102     /** Callback arguments */
00103     void* pArg;
00104 } AUDDStream;
00105 
00106 /*------------------------------------------------------------------------------
00107  *         Functions
00108  *------------------------------------------------------------------------------*/
00109 
00110 extern void AUDDStream_Initialize(
00111     AUDDStream * pAuds,
00112     uint8_t numChannels,
00113     uint16_t wChannelVolumes [ ],
00114     AUDDStreamEventCallback fCallback,
00115     void * pArg);
00116 
00117 extern uint32_t AUDDStream_ChangeMute(
00118     AUDDStream * pAuds,
00119     uint8_t bChannel,
00120     uint8_t bMute);
00121 
00122 extern uint32_t AUDDStream_SetVolume(
00123     AUDDStream * pAuds,
00124     uint8_t bChannel,
00125     uint16_t wVolume);
00126 
00127 extern uint32_t AUDDStream_IsRequestAccepted(
00128     AUDDStream *pAuds,
00129     const USBGenericRequest *pReq);
00130 
00131 extern uint32_t AUDDStream_Read(
00132     AUDDStream * pAuds,
00133     void * pData, uint32_t dwSize,
00134     TransferCallback fCallback,void * pArg);
00135 
00136 extern uint32_t AUDDStream_SetupWrite(
00137     AUDDStream * pAuds,
00138     void * pListInit, void * pDmaInit, uint16_t listSize,
00139     uint16_t delaySize,
00140     TransferCallback callback,void * argument);
00141 
00142 extern uint32_t AUDDStream_Write(
00143     AUDDStream * pAuds,
00144     void * pBuffer,uint16_t wLength);
00145 
00146 extern uint32_t AUDDStream_Close(AUDDStream * pStream);
00147 
00148 #endif /* _AUDD_STREAM_H_ */
00149 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines