Electronic – STM32 Audio class USB not recognized as audio device

stm32stm32f4stm32f4-discoveryusbusb device

I'm learning about USB classes using STM32F429ZI(on Discovery board). I already tried to implement Communications device class (CDC) and it worked well, now I tried to do some simple test with Audio Device Class.
I am using CubeMX to generate project, chose Audio Device Class there, it created default library files. uVision complied without errors or warnings. I flashed my MCU and in device manager it looks like this:
enter image description here

After my learning about CDC USB, I knew that I need to increase Stack_Size and Heap_Size in startup file. I tried it – nothing changes. I also found some advice to decrease HS_MAX_PACKET_SIZE – still no effect.

Well, the questions are:

  1. Why is it under COM port? Even if some configurations are not correct, shouldn't it be under sound devices?
  2. What is wrong? How to make it work? It would be good just to make it recognized as audio device at least, nothing special.

The error under the device is just generic "This device cannot start" error.

enter image description here

EDIT 1
Actually, I don't know what kind of code to attach, since everything is generated with CubeMX. I can give any snippets on request, if needed.
USB Device description generated by CubeMX.

#define USBD_VID     1155
#define USBD_LANGID_STRING     1033
#define USBD_MANUFACTURER_STRING     "STMicroelectronics"
#define USBD_PID_HS     22336
#define USBD_PRODUCT_STRING_HS     "STM32 Audio Class"
/* USER CODE BEGIN SERIALNUMBER_STRING_HS */
#define USBD_SERIALNUMBER_STRING_HS     "00000000001A"
/* USER CODE END SERIALNUMBER_STRING_HS */
#define USBD_CONFIGURATION_STRING_HS     "AUDIO Config"
#define USBD_INTERFACE_STRING_HS     "AUDIO Interface"

#define USB_SIZ_BOS_DESC            0x0C

EDIT 2
I found that USBD_AUDIO_Init() is not called anywhere by default and this can be the problem. But I have troubles understanding how can I call it when it is "Static uint8_t", so basically not callable from main. Here is the description:

usbd_audio.c

/**
  * @brief  USBD_AUDIO_Init
  *         Initialize the AUDIO interface
  * @param  pdev: device instance
  * @param  cfgidx: Configuration index
  * @retval status
  */
static uint8_t  USBD_AUDIO_Init (USBD_HandleTypeDef *pdev, 
                               uint8_t cfgidx)
{
  bunch of code
}

Best Answer

Have you tried this function?

USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id)

The documentation for this library is located here, but it's not great. In general, the HAL gives you some functions and if you use them correctly, a lot of other things happen behind the scenes. Your USBD_AUDIO_Init may be one of those things.

Related Topic