cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX code / USB Audio class / Correct management of DMA callbacks between Driver BSP, USB audio?

jmf1
Associate III

Hello,

Short: I'm developing a USB to I2S bridge, hopefully multi-channels in the end. I don't understand ST designers intention about flow for I2S DMA callbacks . How to do it correctly as expected by ST designers, based on CubeMX generated code?

 

Longer: I want to rely as much as possible on CubeMX code generation and on ST USB UAC1 middleware for future portability reasons. I have a difficulty to understand how ST code intends to implement the mechanism to rearm the I2S DMA once the first transfer is complete between the usbd_audio_if.c and the driver BSP code,

 

I looked at 3 ST examples:

  • Audio_playback_and_record for STM32F4-DISCO (the board I have for development). DMA call back BSP_AUDIO_OUT_xxxxTransfer_CallBacks are coded inside waveplayer.c application code, not in the BSP drive code. Example is working,
  • AUDIO_Standalone for STM324x9I-EVAL. BSP_AUDIO_OUT_xxxxTransfer_CallBacks are coded now inside usbd_audio_if.c application code, so not in the BSP drive code.
  • AUDIO_Standalone for STM32L552E-EV, which looked interesting as with complete CubeMXIDE config. BSP_AUDIO_OUT_xxxxTransfer_CallBacks are empty, not re-declared elsewhere. I suspect the example not to be working.

USB Audio middleware defines in usbd_audio_if.c two functions TransferComplete_CallBack_FS and HalfTransfer_CallBack_FS but they are not used/called in the examples.

The I2S/SAI DMA callbacks is always coded in the driver BSP code, which looks to be expected to be independent from lower level layers (especially usbd_audio_if). So no easy call from there to TransferComplete_CallBack_FS and HalfTransfer_CallBack_FS.

This middleware USB stack, and the logic behind the Audio Class is let's say not KISS / natural (at least to me). Different levels of abstraction makes the execution flow complex. I imagine there was a plan, and some intention for the mandatory management of DMA callbacks, BSP_AUDIO_OUT_xxxxTransfer_CallBacks, ransferComplete_CallBack_FS and HalfTransfer_CallBack_FS.

How to do it according to the ST designers intention ? How to do it correctly?

(I'm using the last versions of STM32CibeIDE and F4 packages).

Best regards,

JMF

0 REPLIES 0