cancel
Showing results for 
Search instead for 
Did you mean: 

USBX on STM32C0 incomplete?

pretoriandave
Associate III

Hi All,

I have previously experiemented with USB HID mouse coding on STM32F0 series and got code working very quickly.

However, I am now trying to get the same going using USBX on STM32C0. My application has been built in MX but wouldn't enumerate. I asked ST if they could take a look at my code, which they did, and said that I needed to add some code to app_usbx_device.c to configure the endpoints and a periodic call in main(). It now enumerates fine and although they didn't say as much I presume its absence in the MX build is a bug as MX knows exactly which endpoints I need enabled.

The applications engineer finished his email by saying 'and now you should be able to send reports' without elaborating. There's no USBD_HID_Mouse_SendReport function in the code that MX built as I would normally expect and am having extreme difficulty figuring out how to do it myself due to inexperience on my part.

My question is whether I have perhaps started too soon with C0 when the MX provision isn't complete? The STM32CubeC0 code was only released recently (I'm using vesion 1.4.0) and perhaps the absence of USBD_HID_Mouse_SendReport is also a bug.

For sure, the code doesn't work straight out of the blocks as the F0 code did so it seems it may be incomplete. I did ask the applications engineer but he hasn't replied.

Thanks for any insight.

 

1 REPLY 1
FBL
ST Employee

Hi @pretoriandave 

USBX is a middleware solution that abstracts USB operations, and it's a bit different from the standard USB library you might have used with the STM32F0 series. To send HID reports, you typically need to 

VOID USBX_DEVICE_HID_MOUSE_Task(VOID) { UX_SLAVE_DEVICE *device; UX_SLAVE_CLASS_HID_EVENT hid_event; device = &_ux_system_slave->ux_system_slave_device; ux_utility_memory_set(&hid_event, 0, sizeof(UX_SLAVE_CLASS_HID_EVENT)); /* Check if the device state already configured */ if ((device->ux_slave_device_state == UX_DEVICE_CONFIGURED) && (hid_mouse != UX_NULL)) { /* Check if user button is pressed */ if (User_Button_State) { /* Get the new position */ GetPointerData(&hid_event); /* Send an event to the hid */ ux_device_class_hid_event_set(hid_mouse, &hid_event); /* Reset User Button state */ User_Button_State = 0U; } } }

 

 

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.