Description
Configure AudioStreaming interface settings by:
...
usbd_audio.h / usbd_audio.c
Prototype
Code Block | ||
---|---|---|
| ||
USBD_AUDIO_AS_IF_HANDLE USBD_Audio_AS_IF_Cfg (const USBD_AUDIO_STREAM_CFG *p_stream_cfg,
const USBD_AUDIO_AS_IF_CFG *p_as_if_cfg,
const USBD_AUDIO_DRV_AS_API *p_as_api,
MEM_SEG *p_seg,
CPU_INT08U terminal_ID,
USBD_AUDIO_PLAYBACK_CORR_FNCT corr_callback,
USBD_ERR *p_err); |
Arguments
p_stream_cfg
Pointer to general stream configuration.
...
Application.
Notes / Warnings
The listing presents Listing - USBD_Audio_AS_IF_Cfg() Example Usage presents an example of usage using a memory segment to allocate the stream buffers. Listing shows Listing Listing - Audio Class Initialization Example shows the same function using a general heap for the stream buffers.
Anchor | ||||
---|---|---|---|---|
|
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#define APP_CFG_USBD_AUDIO_PLAYBACK_NBR_BUF 20u #define APP_CFG_USBD_AUDIO_BUF_EXTRA_BYTE (USBD_AUDIO_STEREO * USBD_AUDIO_FMT_TYPE_I_SUBFRAME_SIZE_2) #define APP_CFG_USBD_AUDIO_DEMO_MEM_SEG_SIZE (APP_CFG_USBD_AUDIO_PLAYBACK_NBR_BUF \ * (USBD_AUDIO_FMT_TYPE_I_SAMFREQ_48KHZ / 1000u) \ * USBD_AUDIO_STEREO \ * USBD_AUDIO_FMT_TYPE_I_SUBFRAME_SIZE_2 \ * APP_CFG_USBD_AUDIO_BUF_EXTRA_BYTE) static CPU_INT08U App_USBD_Audio_MemSegData[APP_CFG_USBD_AUDIO_DEMO_MEM_SEG_SIZE]; static MEM_SEG App_USBD_Audio_MemSegInfo; USBD_AUDIO_AS_IF_HANDLE speaker_playback_as_if_handle; Mem_SegCreate( "Audio Data Memory Segment", (1) &App_USBD_Audio_MemSegInfo, (CPU_ADDR)App_USBD_Audio_MemSegData, APP_CFG_USBD_AUDIO_DEMO_MEM_SEG_SIZE, LIB_MEM_PADDING_ALIGN_NONE, &err_lib); if (err_lib!= LIB_MEM_ERR_NONE) { /* $$$$ Handle the error. */ } speaker_playback_as_if_handle = USBD_Audio_AS_IF_Cfg(&USBD_SpeakerStreamCfg, &USBD_AS_IF1_SpeakerCfg, &USBD_Audio_DrvAS_API_Simulation, &App_USBD_Audio_MemSegInfo, (2) Speaker_IT_USB_OUT_ID, DEF_NULL, &err); if (err != USBD_ERR_NONE) { /* $$$$ Handle the error. */ } |
Panel | ||
---|---|---|
| ||
(1) Create the memory segment. The memory segment will be created on a statically allocated buffer whose size will fit the necessary number of playback buffers. The base address of the memory segment data can also point to a controller dedicated memory. In that case, you may define the memory segment size to the the available dedicated memory size. Other stream buffers may be allocated from the same memory. In this example, the constant (2) Pass the memory segment structure to the function |