cancel
Showing results for 
Search instead for 
Did you mean: 

How to setup the Custom HID and CDC classes on the STM32H5 without using RTOS ?

shashikumardh
Associate II

Hello ST team,

 

I am working on a POC for USB, in which I need to use two classes (Custom HID and CDC) both at a time. And for this I want to generate a code without using Azure RTOS. 

 

Can anyone help me out with this to get a sample code without RTOS and to use Custom HID and CDC both at a time.

 

Thanks in advance

6 REPLIES 6
FBL
ST Employee

Hi @shashikumardh 

Check this repo on GitHub for H5 products, you can find examples of HID class for USB without AzureRTOS 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

shashikumardh
Associate II

Hi FBL,

Thanks for the quick response. The repo which you shared is having only examples for one class. I need a reference example for usage of two classes at a time (custom hid + cdc) i.e composite examples.

 

please help me with this

hardrock
Associate III

In my experience, this is easy and very excellent solution for STM32 USB Composite devices.

 

I-CUBE-USBD-Composite

https://github.com/alambe94/I-CUBE-USBD-Composite

 

shashikumardh
Associate II

Hello Hardrock,

 

Thanks for the lead. Although I generated a code using AL94.I-CUBE-USBD-COMPOSITE.1.0.3.pack software package I am still facing some issue in device discovery. Attaching snapshot for the reference.

shashikumardh_0-1714469135397.png

Kindly anyone help me to resolve this and please let me know will this AL94.I-CUBE-USBD-COMPOSITE.1.0.3.pack software package is compactible for H5 as well.

hardrock
Associate III

1. You must install "STM32 Virtual COM Port Driver" for USB CDC in your PC.

https://www.st.com/en/development-tools/stsw-stm32102.html

 

2. For the USB Composite CDC and HID, you have to design the custom interface respectively.

/Middlewares/Third_Party/AL94_USB_Composite/COMPOSITE/App/

[USB CDC] usbd_cdc_acm_if.c
[USB HID] usbd_hid_custom_if.c


for example, CDC_Receive() in usbd_cdc_acm_if.c
this sample interface just echo back on same channel.

* USB COM RX Interface : CDC_Receive()
* USB COM TX Interface : CDC_Transmit()

static int8_t CDC_Receive(uint8_t cdc_ch, uint8_t *Buf, uint32_t *Len)
{
/* USER CODE BEGIN 6 */
//HAL_UART_Transmit_DMA(CDC_CH_To_UART_Handle(cdc_ch), Buf, *Len);
CDC_Transmit(cdc_ch, Buf, *Len); // echo back on same channel

USBD_CDC_SetRxBuffer(cdc_ch, &hUsbDevice, &Buf[0]);
USBD_CDC_ReceivePacket(cdc_ch, &hUsbDevice);
return (USBD_OK);
/* USER CODE END 6 */
}