USBLibAPIGuide
1.00.00.01
|
Data Structures | |
struct | tAudioInstance |
struct | tUSBDAudioDevice |
Macros | |
#define | AUDIO_IN_TERMINAL_ID 1 |
#define | AUDIO_OUT_TERMINAL_ID 2 |
#define | AUDIO_CONTROL_ID 3 |
#define | AUDIO_INTERFACE_CONTROL 0 |
#define | AUDIO_INTERFACE_OUTPUT 1 |
#define | ISOC_OUT_ENDPOINT USB_EP_1 |
#define | ISOC_OUT_EP_MAX_SIZE ((48000*4)/1000) |
#define | NUM_AUDIO_SECTIONS |
#define | AUDIODESCRIPTOR_SIZE (8) |
#define | CONTROLINTERFACE_SIZE (52) |
#define | STREAMINTERFACE_SIZE (52) |
#define | COMPOSITE_DAUDIO_SIZE |
#define | USBD_AUDIO_EVENT_IDLE (USBD_AUDIO_EVENT_BASE + 0) |
This USB audio event indicates that the device is connected but not active. More... | |
#define | USBD_AUDIO_EVENT_ACTIVE (USBD_AUDIO_EVENT_BASE + 1) |
#define | USBD_AUDIO_EVENT_DATAOUT (USBD_AUDIO_EVENT_BASE + 2) |
#define | USBD_AUDIO_EVENT_VOLUME (USBD_AUDIO_EVENT_BASE + 4) |
#define | USBD_AUDIO_EVENT_MUTE (USBD_AUDIO_EVENT_BASE + 5) |
Typedefs | |
typedef void(* | tUSBAudioBufferCallback) (void *pvBuffer, uint32_t ui32Param, uint32_t ui32Event) |
Functions | |
void * | USBDAudioInit (uint32_t ui32Index, tUSBDAudioDevice *psAudioDevice) |
void * | USBDAudioCompositeInit (uint32_t ui32Index, tUSBDAudioDevice *psAudioDevice, tCompositeEntry *psCompEntry) |
void | USBDAudioTerm (void *pvAudioDevice) |
int32_t | USBAudioBufferOut (void *pvAudioDevice, void *pvBuffer, uint32_t ui32Size, tUSBAudioBufferCallback pfnCallback) |
Variables | |
uint8_t | g_pui8IADAudioDescriptor [AUDIODESCRIPTOR_SIZE] |
const tConfigSection | g_sIADAudioConfigSection |
const uint8_t | g_pui8AudioControlInterface [CONTROLINTERFACE_SIZE] |
const uint8_t | g_pui8AudioStreamInterface [STREAMINTERFACE_SIZE] |
const tConfigSection | g_sAudioConfigSection |
const tConfigSection | g_sAudioStreamInterfaceSection |
const tConfigSection | g_sAudioControlInterfaceSection |
const tConfigSection * | g_psAudioSections [] |
const tConfigHeader | g_sAudioConfigHeader |
const tConfigHeader *const | g_ppAudioConfigDescriptors [] |
#define AUDIO_IN_TERMINAL_ID 1 |
#define AUDIO_OUT_TERMINAL_ID 2 |
#define AUDIO_CONTROL_ID 3 |
#define AUDIO_INTERFACE_CONTROL 0 |
#define AUDIO_INTERFACE_OUTPUT 1 |
#define ISOC_OUT_ENDPOINT USB_EP_1 |
#define ISOC_OUT_EP_MAX_SIZE ((48000*4)/1000) |
Referenced by USBAudioBufferOut().
#define NUM_AUDIO_SECTIONS |
#define AUDIODESCRIPTOR_SIZE (8) |
#define CONTROLINTERFACE_SIZE (52) |
#define STREAMINTERFACE_SIZE (52) |
#define COMPOSITE_DAUDIO_SIZE |
The size of the memory that should be allocated to create a configuration descriptor for a single instance of the USB Audio Device. This does not include the configuration descriptor which is automatically ignored by the composite device class.
#define USBD_AUDIO_EVENT_IDLE (USBD_AUDIO_EVENT_BASE + 0) |
This USB audio event indicates that the device is connected but not active.
#define USBD_AUDIO_EVENT_ACTIVE (USBD_AUDIO_EVENT_BASE + 1) |
This USB audio event indicates that the device is connected and is now active.
#define USBD_AUDIO_EVENT_DATAOUT (USBD_AUDIO_EVENT_BASE + 2) |
This USB audio event indicates that the device is returning a data buffer provided by the USBAudioBufferOut() function back to the application with valid audio data received from the USB host controller. The pvBuffer parameter holds the pointer to the buffer with the new audio data and the ui32Param value holds the amount of valid data in bytes that are contained in the pvBuffer parameter.
#define USBD_AUDIO_EVENT_VOLUME (USBD_AUDIO_EVENT_BASE + 4) |
This USB audio event indicates that a volume change has occurred. The ui32Param value contains a signed 8.8 fixed point value that represents the current volume gain/attenuation in decibels(dB). The provided message handler should be prepared to handle negative and positive values with the value 0x8000 indicating maximum attenuation. The pvBuffer parameter should be ignored.
#define USBD_AUDIO_EVENT_MUTE (USBD_AUDIO_EVENT_BASE + 5) |
This USB audio event indicates that a mute request has occurred. The ui32Param value will either be a 1 to indicate that the audio is now muted, and a value of 0 indicates that the audio has been unmuted.
typedef void(* tUSBAudioBufferCallback) (void *pvBuffer, uint32_t ui32Param, uint32_t ui32Event) |
void * USBDAudioInit | ( | uint32_t | ui32Index, |
tUSBDAudioDevice * | psAudioDevice | ||
) |
This function should be called once for the audio class device to initialized basic operation and prepare for enumeration.
ui32Index | is the index of the USB controller to initialize for audio class device operation. |
psAudioDevice | points to a structure containing parameters customizing the operation of the audio device. |
In order for an application to initialize the USB audio device class, it must first call this function with the a valid audio device class structure in the psAudioDevice parameter. This allows this function to initialize the USB controller and device code to be prepared to enumerate and function as a USB audio device.
This function returns a void pointer that must be passed in to all other APIs used by the audio class.
See the documentation on the tUSBDAudioDevice structure for more information on how to properly fill the structure members.
References tUSBDAudioDevice::ppui8StringDescriptors, and USBDAudioCompositeInit().
void * USBDAudioCompositeInit | ( | uint32_t | ui32Index, |
tUSBDAudioDevice * | psAudioDevice, | ||
tCompositeEntry * | psCompEntry | ||
) |
This function should be called once for the audio class device to initialized basic operation and prepare for enumeration.
ui32Index | is the index of the USB controller to initialize for audio class device operation. |
psAudioDevice | points to a structure containing parameters customizing the operation of the audio device. |
psCompEntry | is the composite device entry to initialize when creating a composite device. |
In order for an application to initialize the USB audio device class, it must first call this function with the a valid audio device class structure in the psAudioDevice parameter. This allows this function to initialize the USB controller and device code to be prepared to enumerate and function as a USB audio device. When this audio device is part of a composite device, then the psCompEntry should point to the composite device entry to initialize. This is part of the array that is passed to the USBDCompositeInit() function.
This function returns a void pointer that must be passed in to all other APIs used by the audio class.
See the documentation on the tUSBDAudioDevice structure for more information on how to properly fill the structure members.
References tUSBDAudioDevice::ppui8StringDescriptors, tDeviceInfo::psCallbacks, tCompositeEntry::psDevInfo, tCompositeEntry::pvInstance, tAudioInstance::sDevInfo, tUSBDAudioDevice::sPrivateData, and tAudioInstance::ui32USBBase.
Referenced by USBDAudioInit().
void USBDAudioTerm | ( | void * | pvAudioDevice | ) |
Shuts down the audio device.
pvAudioDevice | is the pointer to the device instance structure as returned by USBDAudioInit(). |
This function terminates audio interface for the instance supplied. This function should not be called if the audio device is part of a composite device and instead the USBDCompositeTerm() function should be called for the full composite device. Following this call, the pvAudioDevice instance should not me used in any other calls.
References USBDCDTerm().
int32_t USBAudioBufferOut | ( | void * | pvAudioDevice, |
void * | pvBuffer, | ||
uint32_t | ui32Size, | ||
tUSBAudioBufferCallback | pfnCallback | ||
) |
This function is used to supply buffers to the audio class to be filled from the USB host device.
pvAudioDevice | is the pointer to the device instance structure as returned by USBDAudioInit() or USBDAudioCompositeInit(). |
pvBuffer | is a pointer to the buffer to fill with audio data. |
ui32Size | is the size in bytes of the buffer pointed to by the pvBuffer parameter. |
pfnCallback | is a callback that will provide notification when this buffer has valid data. |
This function fills the buffer pointed to by the pvBuffer parameter with at most ui32Size one packet of data from the host controller. The ui32Size has a minimum value of ISOC_OUT_EP_MAX_SIZE since each USB packet can be at most ISOC_OUT_EP_MAX_SIZE bytes in size. Since the audio data may not be received in amounts that evenly fit in the buffer provided, the buffer may not be completely filled. The pfnCallback function will provide the amount of valid data that was actually stored in the buffer provided. The function will return zero if the buffer could be scheduled to be filled, otherwise the function will return a non-zero value if there was some reason that the buffer could not be added.
References ISOC_OUT_EP_MAX_SIZE, tAudioInstance::pfnCallback, tAudioInstance::pvData, tAudioInstance::sBuffer, tUSBDAudioDevice::sPrivateData, tAudioInstance::ui32NumBytes, and tAudioInstance::ui32Size.
uint8_t g_pui8IADAudioDescriptor[AUDIODESCRIPTOR_SIZE] |
const tConfigSection g_sIADAudioConfigSection |
const uint8_t g_pui8AudioControlInterface[CONTROLINTERFACE_SIZE] |
const uint8_t g_pui8AudioStreamInterface[STREAMINTERFACE_SIZE] |
const tConfigSection g_sAudioConfigSection |
const tConfigSection g_sAudioStreamInterfaceSection |
const tConfigSection g_sAudioControlInterfaceSection |
const tConfigSection* g_psAudioSections[] |
const tConfigHeader g_sAudioConfigHeader |
const tConfigHeader* const g_ppAudioConfigDescriptors[] |