cancel
Showing results for 
Search instead for 
Did you mean: 

Is that possible to control the polling rate of a mouse in USB host mode?

ZIgon.1
Associate II

HI,

I'm using an STM32F4 device and CubeIDE SW to interface with a mouse as a host with an HID. I use the USBH_HID_EventCallback function to trigger mouse readings.

Can I change the mouse's polling rate so that it will be triggering faster?

The current polling rate (per USBH_HID_GetPollInterval function) is 10ms. In the mouse's data sheet, it states it can reach 1kHz polling rate.

Thanks

10 REPLIES 10
ZIgon.1
Associate II

Thanks again guys for your huge help!

So at the usbh_hid.c file, there is a section of HID_Handle initiation. On line 197, the systems gets the default polling rate for the device and verifies it is not shorter than the minimum value, as seen below:

 HID_Handle->poll   = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].bInterval;

 if (HID_Handle->poll < HID_MIN_POLL)

 {

  HID_Handle->poll = HID_MIN_POLL;

 }

After these lines, I just add an overwriting value for the polling rate and it works.

Example: HID_Handle->poll = 1U; (for a 1ms polling rate).

Thanks again 🙂