STM32G491 USB Composite(HID & UAC) problem
- July 5, 2023
- 4 replies
- 3054 views
I have recently developed a USB Compoite (HID Keyborad & Audio Speaker) device using the STM32G491.
I have been able to have it recognized as a Composite Device in the Windows 11 Device Manager, and I have been able to input keys and play PC sound from a codec (Analog Devices ADAU1761) via SAI.
However, there is one problem. I can't get any input from the PC side even if I call USBD_HID_SendReport by pressing a key while the PC is playing sound.
The audio processing is done by calling HAL_SAI_Transmit in AUDIO_PeriodicTC_FS in usbd_audio_if.c as follows.
static int8_t AUDIO_PeriodicTC_FS(uint8_t *pbuf, uint32_t size, uint8_t cmd)
{
/* USER CODE BEGIN 5 */
UNUSED(cmd);
//SEGGER_RTT_printf(0, "size = %d\n", size);
HAL_SAI_Transmit(&hsai_BlockB1, pbuf, size / 2, 0x0000FFFF);
return (USBD_OK);
/* USER CODE END 5 */
}
USBD_HID_SendReport is sent when a keystroke is detected in the while loop in the main function. The source code is available at here.
The Descriptor for the device is as in the attached txt. The version of IDE used is STM32CubeIDE v1.12.1.
Please let me know if you notice anything or have any advice.
