3 Copyright (C) Dean Camera, 2009.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
31 /** \ingroup Group_USBClassAudio
32 * @defgroup Group_USBClassAudioDevice Audio Class Device Mode Driver
34 * \section Module Description
35 * Device Mode USB Class driver framework interface, for the Audio USB Class driver.
40 #ifndef _AUDIO_CLASS_DEVICE_H_
41 #define _AUDIO_CLASS_DEVICE_H_
44 #include "../../USB.h"
45 #include "../Common/Audio.h"
49 /* Enable C linkage for C++ Compilers: */
50 #if defined(__cplusplus)
54 /* Function Prototypes: */
55 /** Configures the endpoints of a given Audio interface, ready for use. This should be linked to the library
56 * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the
57 * given Audio interface is selected.
59 * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
61 * \return Boolean true if the endpoints were sucessfully configured, false otherwise
63 bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_t
* AudioInterfaceInfo
);
65 /** Processes incomming control requests from the host, that are directed to the given Audio class interface. This should be
66 * linked to the library \ref EVENT_USB_UnhandledControlPacket() event.
68 * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
70 void Audio_Device_ProcessControlPacket(USB_ClassInfo_Audio_t
* AudioInterfaceInfo
);
72 /** General management task for a given Audio class interface, required for the correct operation of the interface. This should
73 * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().
75 * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
77 void Audio_Device_USBTask(USB_ClassInfo_Audio_t
* AudioInterfaceInfo
);
79 /** Reads the next 8-bit audio sample from the current audio interface.
81 * \note This should be preceeded immediately by a call to the USB_Audio_IsSampleReceived() function to ensure that
82 * the correct endpoint is selected and ready for data.
84 * \return Signed 8-bit audio sample from the audio interface
86 int8_t Audio_Device_ReadSample8(void);
88 /** Reads the next 16-bit audio sample from the current audio interface.
90 * \note This should be preceeded immediately by a call to the USB_Audio_IsSampleReceived() function to ensure that
91 * the correct endpoint is selected and ready for data.
93 * \return Signed 16-bit audio sample from the audio interface
95 int16_t Audio_Device_ReadSample16(void);
97 /** Reads the next 24-bit audio sample from the current audio interface.
99 * \note This should be preceeded immediately by a call to the USB_Audio_IsSampleReceived() function to ensure that
100 * the correct endpoint is selected and ready for data.
102 * \return Signed 24-bit audio sample from the audio interface
104 int32_t Audio_Device_ReadSample24(void);
106 /** Writes the next 8-bit audio sample to the current audio interface.
108 * \note This should be preceeded immediately by a call to the USB_Audio_IsReadyForNextSample() function to ensure that
109 * the correct endpoint is selected and ready for data.
111 * \param Sample Signed 8-bit audio sample
113 void Audio_Device_WriteSample8(int8_t Sample
);
115 /** Writes the next 16-bit audio sample to the current audio interface.
117 * \note This should be preceeded immediately by a call to the USB_Audio_IsReadyForNextSample() function to ensure that
118 * the correct endpoint is selected and ready for data.
120 * \param Sample Signed 16-bit audio sample
122 void Audio_Device_WriteSample16(int16_t Sample
);
124 /** Writes the next 24-bit audio sample to the current audio interface.
126 * \note This should be preceeded immediately by a call to the USB_Audio_IsReadyForNextSample() function to ensure that
127 * the correct endpoint is selected and ready for data.
129 * \param Sample Signed 24-bit audio sample
131 void Audio_Device_WriteSample24(int32_t Sample
);
133 /** Determines if the given audio interface is ready for a sample to be read from it.
135 * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
137 * \return Boolean true if the given Audio interface has a sample to be read, false otherwise
139 bool Audio_Device_IsSampleReceived(USB_ClassInfo_Audio_t
* AudioInterfaceInfo
);
141 /** Determines if the given audio interface is ready to accept the next sample to be written to it.
143 * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
145 * \return Boolean true if the given Audio interface is ready to accept the next sample, false otherwise
147 bool Audio_Device_IsReadyForNextSample(USB_ClassInfo_Audio_t
* AudioInterfaceInfo
);
149 /* Disable C linkage for C++ Compilers: */
150 #if defined(__cplusplus)