...
usbd_audio_drv_<codec-name>.h / usbd_audio_drv_<codec-name>.c
Prototype
Code Block | ||
---|---|---|
| ||
static CPU_BOOLEAN USBD_Audio_DrvStreamStart (USBD_AUDIO_DRV *p_audio_drv,
USBD_AUDIO_AS_HANDLE as_handle,
CPU_INT08U terminal_id_link); |
Arguments
p_audio_drv
Pointer to audio driver structure.
...
This listing shows an example usage of this function for a record stream.
Anchor | ||||
---|---|---|---|---|
|
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#define DMA_CH_1 1u #define DMA_MAX_NBR_CH_USED 2u static CPU_INT08U DMA_AsHandleTbl[DMA_MAX_NBR_CH_USED]; static CPU_BOOLEAN USBD_Audio_DrvStreamStart (USBD_AUDIO_DRV *p_audio_drv, CPU_INT08U as_handle, CPU_INT08U terminal_id_link) { CPU_INT16U buf_len; CPU_INT08U *p_buf; (void)&p_audio_drv; if (terminal_id_link != Mic_OT_USB_IN_ID) { (1) return (DEF_FAIL); } DMA_AsHandleTbl[DMA_CH_1] = as_handle; (2) /* $$$$ Enable record operations on audio chip if needed. */ (3) p_buf = (CPU_INT08U *)USBD_Audio_RecordBufGet(as_handle, (4) &buf_len); if (p_buf == (CPU_INT08U *)0) { return (DEF_FAIL); } /* $$$$ Prepare initial DMA transfer. */ (5) return (DEF_OK); } |
Panel | ||
---|---|---|
| ||
(1) You can verify if the stream processing is intended for the record path by checking the terminal ID associated to this stream. The function may be used to process also a playback stream. In that case, the terminal ID will differentiate the different streams. (2) You should save the AudioStreaming interface handle locally to be used by the ISR managing audio data transfer. This handle is used by the functions (3) You may have to enable the record operations on the audio chip. It could be enabling some clocks, enabling some modules, etc. It may require sending a series of I2C commands for registers access, (4) Call (5) With this buffer, prepare the initial DMA transfer.
|
This listing shows an example usage of this function for a playback stream.
Anchor Listing - USBD_Audio_DrvStreamStart() Example Usage for a Playback Stream Listing - USBD_Audio_DrvStreamStart() Example Usage for a Playback Stream
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#define DMA_CH_0 0u
#define DMA_MAX_NBR_CH_USED 2u
static CPU_INT08U DMA_AsHandleTbl[DMA_MAX_NBR_CH_USED];
static CPU_BOOLEAN USBD_Audio_DrvStreamStart (USBD_AUDIO_DRV *p_audio_drv,
CPU_INT08U as_handle,
CPU_INT08U terminal_id_link)
{
CPU_INT16U buf_len;
CPU_INT08U *p_buf;
(void)&p_audio_drv;
if (terminal_id_link != Speaker_IT_USB_OUT_ID) { (1)
return (DEF_FAIL);
}
DMA_AsHandleTbl[DMA_CH_0] = as_handle; (2)
/* $$$$ Enable playback operations on audio chip if needed. */ (3)
USBD_Audio_PlaybackTxCmpl(as_handle); (4)
USBD_Audio_PlaybackTxCmpl(as_handle);
return (DEF_OK);
} |
Panel | ||
---|---|---|
| ||
(1) You can verify if the stream processing is intended for the playback path by checking the terminal ID associated to this stream. The function may be used to process also a record stream. In that case, the terminal ID will differentiate the different streams. (2) You should save the AudioStreaming interface handle locally to be used by the ISR managing audio data transfer. This handle is used by the functions (3) You may have to enable the playback operations on the audio chip. It could be enabling some clocks, enabling some modules, etc. It may require sending a series of I2C commands for registers access, (4) Signal to the playback task the number of ready buffers that can be queued by calling |