Skip to content

Commit be5205d

Browse files
committed
usb_hid: Allow USB work to progress while waiting for tud_hid_ready
Otherwise, examples like the one attached to the related issue fail because tud_hid_ready never returns true. Testing performed: Adapted the example to nrf particle xenon (it was handy), removed dependency on IR, verified that the problem occurred before this change, and that it was fixed after this change. Closes: adafruit#2048
1 parent 47a0b7c commit be5205d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

shared-module/usb_hid/Device.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t*
4747

4848
// Wait until interface is ready, timeout = 2 seconds
4949
uint64_t end_ticks = ticks_ms + 2000;
50-
while ( (ticks_ms < end_ticks) && !tud_hid_ready() ) { }
50+
while ( (ticks_ms < end_ticks) && !tud_hid_ready() ) {
51+
#ifdef MICROPY_VM_HOOK_LOOP
52+
MICROPY_VM_HOOK_LOOP;
53+
#endif
54+
}
5155

5256
if ( !tud_hid_ready() ) {
5357
mp_raise_msg(&mp_type_OSError, translate("USB Busy"));

0 commit comments

Comments
 (0)