USBLibAPIGuide  1.00.00.01
usbdaudio.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // usbdaudio.h - USB audio device class driver.
4 //
5 // Copyright (c) 2009-2017 Texas Instruments Incorporated. All rights reserved.
6 // Software License Agreement
7 //
8 // Texas Instruments (TI) is supplying this software for use solely and
9 // exclusively on TI's microcontroller products. The software is owned by
10 // TI and/or its suppliers, and is protected under applicable copyright
11 // laws. You may not combine this software with "viral" open-source
12 // software in order to form a larger program.
13 //
14 // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
15 // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
16 // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
18 // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
19 // DAMAGES, FOR ANY REASON WHATSOEVER.
20 //
21 //
22 //*****************************************************************************
23 
24 #ifndef __USBDAUDIO_H__
25 #define __USBDAUDIO_H__
26 
27 //*****************************************************************************
28 //
29 // If building with a C++ compiler, make all of the definitions in this header
30 // have a C binding.
31 //
32 //*****************************************************************************
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37 
38 //*****************************************************************************
39 //
42 //
43 //*****************************************************************************
44 
45 typedef void (* tUSBAudioBufferCallback)(void *pvBuffer, uint32_t ui32Param,
46  uint32_t ui32Event);
47 
48 //*****************************************************************************
49 //
50 // PRIVATE
51 //
52 // This structure defines the private instance data and state variables for the
53 // audio device class. The memory for this structure is pointed to by
54 // the pi16PrivateData field in the tUSBDAudioDevice structure passed on
55 // USBDAudioInit() and should not be modified by any code outside of the audio
56 // device.
57 //
58 //*****************************************************************************
59 typedef struct
60 {
61  //
62  // Base address for the USB controller.
63  //
64  uint32_t ui32USBBase;
65 
66  //
67  // The device info to interact with the lower level DCD code.
68  //
70 
71  //
72  // The maximum volume expressed as an 8.8 signed value.
73  //
74  int16_t i16VolumeMax;
75 
76  //
77  // The minimum volume expressed as an 8.8 signed value.
78  //
79  int16_t i16VolumeMin;
80 
81  //
82  // The minimum volume step expressed as an 8.8 signed value.
83  //
84  int16_t i16VolumeStep;
85 
86  struct
87  {
88  //
89  // Pointer to a buffer provided by caller.
90  //
91  void *pvData;
92 
93  //
94  // Size of the data area provided in pvData in bytes.
95  //
96  uint32_t ui32Size;
97 
98  //
99  // Number of valid bytes copied into the pvData area.
100  //
101  uint32_t ui32NumBytes;
102 
103  //
104  // The buffer callback for this function.
105  //
107  }
108  sBuffer;
109 
110  //
111  // Pending request type.
112  //
113  uint16_t ui16RequestType;
114 
115  //
116  // Pending request.
117  //
118  uint8_t ui8Request;
119 
120  //
121  // Pending update value.
122  //
123  uint16_t ui16Update;
124 
125  //
126  // Current Volume setting.
127  //
128  int16_t i16Volume;
129 
130  //
131  // Current Mute setting.
132  //
133  uint8_t ui8Mute;
134 
135  //
136  // Current Sample rate, this is not writable but the host will try.
137  //
138  uint32_t ui32SampleRate;
139 
140  //
141  // The OUT endpoint in use by this instance.
142  //
143  uint8_t ui8OUTEndpoint;
144 
145  //
146  // The OUT endpoint DMA channel in use by this instance.
147  //
148  uint8_t ui8OUTDMA;
149 
150  //
151  // The control interface number associated with this instance.
152  //
154 
155  //
156  // The audio interface number associated with this instance.
157  //
159 
160  //
161  // A copy of the DMA instance data used with calls to USBLibDMA functions.
162  //
164 }
166 
167 //*****************************************************************************
168 //
169 // This is the size of the g_pui8IADAudioDescriptor array in bytes.
170 //
171 //*****************************************************************************
172 #define AUDIODESCRIPTOR_SIZE (8)
173 
174 //*****************************************************************************
175 //
176 // This is the size of the g_pui8AudioControlInterface array in bytes.
177 //
178 //*****************************************************************************
179 #define CONTROLINTERFACE_SIZE (52)
180 
181 //*****************************************************************************
182 //
183 // This is the size of the g_pui8AudioStreamInterface array in bytes.
184 //
185 //*****************************************************************************
186 #define STREAMINTERFACE_SIZE (52)
187 
188 //*****************************************************************************
189 //
194 //
195 //*****************************************************************************
196 #define COMPOSITE_DAUDIO_SIZE (AUDIODESCRIPTOR_SIZE + \
197  CONTROLINTERFACE_SIZE + STREAMINTERFACE_SIZE)
198 
199 //*****************************************************************************
200 //
203 //
204 //*****************************************************************************
205 typedef struct
206 {
207  //
209  //
210  const uint16_t ui16VID;
211 
212  //
214  //
215  const uint16_t ui16PID;
216 
217  //
219  //
220  const char pcVendor[8];
221 
222  //
224  //
225  const char pcProduct[16];
226 
227  //
229  //
230  const char pcVersion[4];
231 
232  //
234  //
235  const uint16_t ui16MaxPowermA;
236 
237  //
241  //
242  const uint8_t ui8PwrAttributes;
243 
244  //
248  //
250 
251  //
263  //
264  const uint8_t * const *ppui8StringDescriptors;
265 
266  //
270  //
271  const uint32_t ui32NumStringDescriptors;
272 
273  //
275  //
276  const int16_t i16VolumeMax;
277 
278  //
280  //
281  const int16_t i16VolumeMin;
282 
283  //
285  //
286  const int16_t i16VolumeStep;
287 
288  //
290  //
292 }
294 
295 //*****************************************************************************
296 //
297 // Audio specific device class driver events
298 //
299 //*****************************************************************************
300 
301 //*****************************************************************************
302 //
304 //
305 //*****************************************************************************
306 #define USBD_AUDIO_EVENT_IDLE (USBD_AUDIO_EVENT_BASE + 0)
307 
308 //*****************************************************************************
309 //
312 //
313 //*****************************************************************************
314 #define USBD_AUDIO_EVENT_ACTIVE (USBD_AUDIO_EVENT_BASE + 1)
315 
316 //*****************************************************************************
317 //
324 //
325 //*****************************************************************************
326 #define USBD_AUDIO_EVENT_DATAOUT (USBD_AUDIO_EVENT_BASE + 2)
327 
328 //*****************************************************************************
329 //
336 //
337 //*****************************************************************************
338 #define USBD_AUDIO_EVENT_VOLUME (USBD_AUDIO_EVENT_BASE + 4)
339 
340 //*****************************************************************************
341 //
345 //
346 //*****************************************************************************
347 #define USBD_AUDIO_EVENT_MUTE (USBD_AUDIO_EVENT_BASE + 5)
348 
349 //*****************************************************************************
350 //
351 // API Function Prototypes
352 //
353 //*****************************************************************************
354 extern void *USBDAudioInit(uint32_t ui32Index,
355  tUSBDAudioDevice *psAudioDevice);
356 extern void *USBDAudioCompositeInit(uint32_t ui32Index,
357  tUSBDAudioDevice *psAudioDevice,
358  tCompositeEntry *psCompEntry);
359 extern void USBDAudioTerm(void *pvAudioDevice);
360 extern int32_t USBAudioBufferOut(void *pvAudioDevice, void *pvBuffer,
361  uint32_t ui32Size,
362  tUSBAudioBufferCallback pfnCallback);
363 
364 //*****************************************************************************
365 //
366 // Close the Doxygen group.
368 //
369 //*****************************************************************************
370 
371 //*****************************************************************************
372 //
373 // Mark the end of the C bindings section for C++ compilers.
374 //
375 //*****************************************************************************
376 #ifdef __cplusplus
377 }
378 #endif
379 
380 #endif
381 
int32_t USBAudioBufferOut(void *pvAudioDevice, void *pvBuffer, uint32_t ui32Size, tUSBAudioBufferCallback pfnCallback)
Definition: usbdaudio.c:1459
void * pvData
Definition: usbdaudio.h:91
const uint16_t ui16MaxPowermA
The maximum power consumption of the device, expressed in mA.
Definition: usbdaudio.h:235
uint8_t ui8Request
Definition: usbdaudio.h:118
Definition: usbdaudio.h:205
uint8_t ui8InterfaceControl
Definition: usbdaudio.h:153
Definition: usbdevice.h:135
int16_t i16VolumeMin
Definition: usbdaudio.h:79
tUSBDMAInstance * psDMAInstance
Definition: usbdaudio.h:163
void * USBDAudioCompositeInit(uint32_t ui32Index, tUSBDAudioDevice *psAudioDevice, tCompositeEntry *psCompEntry)
Definition: usbdaudio.c:994
const int16_t i16VolumeStep
The minimum volume step expressed as an 8.8 signed value.
Definition: usbdaudio.h:286
const tUSBCallback pfnCallback
Definition: usbdaudio.h:249
uint8_t ui8OUTDMA
Definition: usbdaudio.h:148
tUSBAudioBufferCallback pfnCallback
Definition: usbdaudio.h:106
uint8_t ui8Mute
Definition: usbdaudio.h:133
const uint8_t *const * ppui8StringDescriptors
Definition: usbdaudio.h:264
uint16_t ui16RequestType
Definition: usbdaudio.h:113
uint8_t ui8InterfaceAudio
Definition: usbdaudio.h:158
Definition: usbdevice.h:66
uint32_t ui32NumBytes
Definition: usbdaudio.h:101
uint32_t(* tUSBCallback)(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgParam, void *pvMsgData)
Definition: usblib.h:1220
int16_t i16Volume
Definition: usbdaudio.h:128
const uint8_t ui8PwrAttributes
Definition: usbdaudio.h:242
uint16_t ui16Update
Definition: usbdaudio.h:123
void(* tUSBAudioBufferCallback)(void *pvBuffer, uint32_t ui32Param, uint32_t ui32Event)
Definition: usbdaudio.h:45
uint32_t ui32Size
Definition: usbdaudio.h:96
const int16_t i16VolumeMax
The maximum volume expressed as an 8.8 signed value.
Definition: usbdaudio.h:276
void * USBDAudioInit(uint32_t ui32Index, tUSBDAudioDevice *psAudioDevice)
Definition: usbdaudio.c:902
const uint16_t ui16VID
The vendor ID that this device is to present in the device descriptor.
Definition: usbdaudio.h:210
Definition: usblibpriv.h:177
int16_t i16VolumeStep
Definition: usbdaudio.h:84
uint8_t ui8OUTEndpoint
Definition: usbdaudio.h:143
Definition: usbdaudio.h:59
int16_t i16VolumeMax
Definition: usbdaudio.h:74
tDeviceInfo sDevInfo
Definition: usbdaudio.h:69
const uint16_t ui16PID
The product ID that this device is to present in the device descriptor.
Definition: usbdaudio.h:215
tAudioInstance sPrivateData
The private instance data for the audio device.
Definition: usbdaudio.h:291
const uint32_t ui32NumStringDescriptors
Definition: usbdaudio.h:271
void USBDAudioTerm(void *pvAudioDevice)
Definition: usbdaudio.c:1107
uint32_t ui32USBBase
Definition: usbdaudio.h:64
uint32_t ui32SampleRate
Definition: usbdaudio.h:138
const int16_t i16VolumeMin
The minimum volume expressed as an 8.8 signed value.
Definition: usbdaudio.h:281
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale