BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: 'USBH_HID_get_report()' timeout problem monitoring mouse activity  (Read 551 times)

ksw

  • Newbie
  • *
  • Posts: 5
    • View Profile

Hi,

I'm experimenting with the 'USBH Example HID' example to acquire data from a fast mouse (1ms update rate). Does anyone know a way to read the HID reports in a non-blocking manner? In the example code, the API function 'USBH_HID_get_report()' waits until the HID has something to report, and if there's nothing (for what looks to be 10 seconds) it issues a 'USBH_ERR_TIMEOUT'. I'm unclear where this 10s interval is configured, since the underlying functions appear to define the timeout as 1000ms).

The bottom line is that I'd like to get the data from the mouse as soon as it starts generating it, but the problem with the example code is that on calling 'USBH_HID_get_report()' after a timeout it doesn't respond to mouse activity for another 10 seconds.

Keith
Logged

ksw

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: 'USBH_HID_get_report()' timeout problem monitoring mouse activity
« Reply #1 on: February 09, 2022, 05:03:38 PM »

Update: I discovered the interrupt hander in the example code is running at 10ms interval rather than 1ms, which probably accounts for the timeout being 10s rather than the expected 1s. I currently don't understand why the the timer interrupts are at this rate when the setup does suggest it should be 1ms.
 
Further to a previous post, I'm still unable to view the timer registers from the Eclipse debugger, so can't verify they've been configured correctly.
Logged

ksw

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: 'USBH_HID_get_report()' timeout problem monitoring mouse activity
« Reply #2 on: February 09, 2022, 05:33:07 PM »

Further update: the timer A prescaler is 1000 in the example code and should be 100 for 1ms interrupts, so that mystery solved at least!
I still need to find a way round the 'USBH_HID_get_report()' timeout issue in my original post though.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 586
    • View Profile
Re: 'USBH_HID_get_report()' timeout problem monitoring mouse activity
« Reply #3 on: February 17, 2022, 04:23:41 PM »

Hello,

The hardware library (libft900.a) has an API defined in the header files that utilises general purpose functions for accessing the hardware peripherals on the chip. The drivers, for instance the USB Host HID driver, sit above the hardware peripheral code and aren’t really optimised for any particular application and instead provide a simple method to do most tasks required for the operation of the peripheral.

During normal operation, the USBH_transfer calls are all blocking and are best used to read data from somewhere that you know there is data waiting. An alternative is the USBH_transfer_async function which is asynchronous, i.e. it has a callback when completed. At present the callback comes during the call to USBH_Process.

So, the USBH_HID_get_report function can be replaced by something that will send asynchronous reads and report back in another callback function. The endpoint information used in USB Host HID driver are available to the calling program in the USBH_HID_context structure.

Best regards

BRT Community
Logged