Having problem setting up USB Audio(Microphone) for STM32H743
Hello,
I am having problem configuring usb audio microphone for STM32H743-Nucleo144.
What I want to do is to connect several microphones (actually more than 8 microphone but that will be another issue, so I will just stick to 8 microphones) to STM32H743 through DFSDM and forward the PCM data to (audio) USB. I think I already figure out configuring the DFSDM but now having problem with USB audio. The setting that I would like to have is 24 bit and 48kHz.
The generated code for the USB audio was configured for speaker, so I need to change the usbd_audio.h/c file somehow. I found an example code but from STM32L476 + CCA02M2. So I replace the usbd_audio(was configured for speaker) with usbd_audio_in(configured for microphone) from the CCA02M2 example. That does not seems to work for H743(I did try generating my own code with STM32L476 , replace usbd_audio with usbd_audio_in and modified and add some code. It works).
Later on I found an example program called X-CUBE-USB-AUDIO and going through the STM32F769I_DISCO_UAC10-REC. This code looks promising but I am still having trouble to understand and implement the code. The code looks kind of similar to CCA02M2 but the flow is different.
For example,in CCA02M2 the usb configuration written in main() are as follows(Notice that usb descriptor was called before USBD_Init() :(
//The USB descriptor is called at the start
USBD_AUDIO_Init_Microphone_Descriptor(&hUSBDDevice, AUDIO_IN_SAMPLING_FREQUENCY, AUDIO_IN_CHANNELS);
USBD_Init(&hUSBDDevice, &AUDIO_Desc, 0);
USBD_RegisterClass(&hUSBDDevice, &USBD_AUDIO);
USBD_AUDIO_RegisterInterface(&hUSBDDevice, &USBD_AUDIO_fops);
USBD_Start(&hUSBDDevice);But in X-CUBE-USB-AUDIO(STM32F769I_DISCO_UAC10-REC) , the same usb configurations were used but the implementation is different. The usb descriptor was called if I am not mistaken in USBD_AUDIO_RegisterInterface().
//In main()
USBD_Init(&USBD_Device, &AUDIO_Desc, 0);
USBD_RegisterClass(&USBD_Device, USBD_AUDIO_CLASS);
USBD_AUDIO_RegisterInterface(&USBD_Device, &audio_class_interface);
USBD_Start(&USBD_Device);
//--------------------------------------------------------------------------------------------------------
//The USB Description was called inside USBD_AUDIO_RegisterInterface(..)
uint8_t USBD_AUDIO_RegisterInterface (USBD_HandleTypeDef *pdev,
USBD_AUDIO_InterfaceCallbacksfTypeDef *aifc)
{
if(aifc != NULL)
{
pdev->pUserData= aifc;
aifc->GetConfigDesc(&USBD_AUDIO_CfgDesc, &USBD_AUDIO_CfgDescSize, aifc->private_data);
}
return 0;
}Both program kind of want to do the same thing, which is configuring and initialize the audio usb but they are implemented differently under the hood. Example A call the USB descriptor at this point and Example B call the USB descriptor at different point.
Another problem is, the code example in CCA02M2 create completely new functions and new struct instead of using the one generated by cube ide, so now I am really confuse if I should add this function or the code example just redefine the code that already generated.
So now, when I generate my code and want to implement the 2 example in my code, it is really difficult and confusing. What do I need to change to implement usb audio microphone so that it has the setting of 24 bit and 48kHz. Is it just usbd_audio.h/c? or other file like usbd_core,usbd_ctlreq, usbd_def, usbd_ioreq, usbd_audio_if, usb_device?
I change the bSubFrameSize and bBitResolution in the usbd_audio_in.c that I got from CCA02M2, so that setting is 24 bit and 48kHz but my USB was not recognised.
Can anyone help me?
Thanks in advance.
