Before starting the communication phase, your application needs to initialize and configure the class to suit your needs. summarizes the initialization functions provided by the audio class. For more details about the functions parameters, refer to the Audio API.
You need to call these functions in the order shown below to successfully initialize the audio class:
- Call
USBD_Audio_Init()
This is the first function you should call and you should do it only once even if you use multiple class instances. This function initializes all internal structures and variables that the class needs. - Call
USBD_Audio_Add()
This function allocates an audio class instance. The audio instance represents an Audio Interface Collection (AIC). This function allows you to specify the Audio Peripheral Driver API. - Call
USBD_Audio_CfgAdd()
Once the audio class instance has been created, you must add it to a specific configuration. - Call
USBD_Audio_IT_Add()
This function adds an Input Terminal with its configuration to a specific AIC. An audio function will always have at least one Input Terminal. Hence, this function should be called at least once. - Call
USBD_Audio_OT_Add()
This function adds an Output Terminal with its configuration to a specific AIC. An audio function will always have at least one Output Terminal. Hence, this function should be called at least once. - Call
USBD_Audio_FU_Add()
This function adds a Feature Unit with its configuration to a specific AIC. Most of the time, an audio function will have at least one Feature Unit to control the stream (for example mute, volume). - Call
USBD_Audio_MU_Add()
This function adds a Mixer Unit with its configuration to a specific AIC. An audio function may have a Mixer Unit. In general, basics audio devices don't need a Mixer Unit (for instance microphone, speaker, headset). Hence, calling this function is optional. - Call
USBD_Audio_SU_Add()
This function adds a Selector Unit with its configuration to a specific AIC. An audio function may have a Selector Unit. In general, basics audio devices don't need a Selector Unit (for instance microphone, speaker, headset). Hence, calling this function is optional. - Call
USBD_Audio_IT_Assoc
This function associates an Output to the Input Terminal. The function is required if your audio device contains a bi-directional terminal. This terminal type describes an Input and an Output Terminal for voice communication that are closely related. If your device does not have a bi-directional terminal, calling this function is optional. - Call
USBD_Audio_OT_Assoc()
This function Specifies the entity ID (terminal or unit) connected to the specified Output Terminal and associates an Input Terminal to it. - Call
USBD_Audio_FU_Assoc()
This function specifies the terminal or unit connected to the Feature Unit. - Call
USBD_Audio_MU_Assoc()
This function specifies the terminals and/or units connected to the Mixer Unit. If your audio function does not have a Mixer Unit, calling this function is optional. - Call
USBD_Audio_SU_Assoc()
This function specifies the terminals and/or units connected to the Selector Unit. If your audio function does not have a Selector Unit, calling this function is optional. - Call
USBD_Audio_MU_MixingCtrlSet
This function configures the programmable mixing controls. - Call
USBD_Audio_AS_IF_Cfg()
This function configures a given stream according to some specified characteristics. - Call
USBD_Audio_AS_IF_Add()
This function adds an AudioStreaming interface with its configuration to a specific AIC. You can specify a name for the AudioStreaming interface.
illustrates the use of the previous functions for initializing an audio class. Note that the error handling has been omitted for clarity.
The listing does not show an example of usage of the functions
USBD_Audio_MU_Assoc
,
USBD_Audio_SU_Assoc()
and
USBD_Audio_MU_MixingCtrlSet()
to avoid overloading the code snippet. Refer to the associated function page documentation for an example.