From be5205d02081771e7aea51285f94fee83ef4fb77 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 10 Aug 2019 09:33:45 -0500 Subject: [PATCH] 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: #2048 --- shared-module/usb_hid/Device.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shared-module/usb_hid/Device.c b/shared-module/usb_hid/Device.c index a5a57419c7..26d70cb822 100644 --- a/shared-module/usb_hid/Device.c +++ b/shared-module/usb_hid/Device.c @@ -47,7 +47,11 @@ void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t* // Wait until interface is ready, timeout = 2 seconds uint64_t end_ticks = ticks_ms + 2000; - while ( (ticks_ms < end_ticks) && !tud_hid_ready() ) { } + while ( (ticks_ms < end_ticks) && !tud_hid_ready() ) { +#ifdef MICROPY_VM_HOOK_LOOP + MICROPY_VM_HOOK_LOOP; +#endif + } if ( !tud_hid_ready() ) { mp_raise_msg(&mp_type_OSError, translate("USB Busy"));