...
usbd_audio_drv_<codec-name>.h / usbd_audio_drv_<codec-name>.c
Prototype
Code Block | ||
---|---|---|
| ||
static void USBD_Audio_DrvInit (USBD_AUDIO_DRV *p_audio_drv,
USBD_ERR *p_err); |
Arguments
p_audio_drv
Pointer to audio driver structure.
...
- Allocating an optional internal data structure using µC/LIB memory functions (refer to Memory Allocation Functions). This structure can then be saved in the
DataPtr
field ofUSBD_AUDIO_DRV
structure. - Setting all clocks required by peripherals (for instance I2C, I2S controllers, etc.) communicating with the audio chip.
- Setting any I/O required to interface peripherals to the audio chip.
- Setting any interrupt needed by peripherals. It may also encompass installing ISR (Interrupt Service Routine) for those peripherals (for instance, an ISR for I2C communication, an ISR for I2S communication if no DMA is used).
- Initializing the DMA controller if it is used to transfer audio data.
- Initializing the audio chip by configuring its registers accessed by I2C or SPI for instance.
- Initializing any software resources needed for the driver functioning. For instance:
- Allocating DMA descriptors if it is required by your DMA controller implementation from the heap or a dedicated memory using µC/LIB memory functions (refer to Memory Allocation Functions).
- Allocating the silence buffer using µC/LIB memory functions if a playback stream is required and initializing it with zeros using
Mem_Clr()
. - Allocating a dummy buffer using µC/LIB memory functions if a record stream is required.
- Set
p_err
toUSBD_ERR_AUDIO_CODEC_INIT_FAILED
if any error occurs during the initialization sequence. Otherwise set it toUSBD_ERR_NONE
.
...