Bugfix: super-slow interactions when no USB connected

This commit is contained in:
Peter D. Gray 2021-03-15 08:42:13 -04:00
parent a39e4b29d6
commit 2a0259abfc
No known key found for this signature in database
GPG Key ID: F0E6CC6AFC16CF7B

View File

@ -994,6 +994,10 @@ STATIC mp_uint_t pyb_usb_hid_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_
pyb_usb_hid_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_uint_t ret;
if (request == MP_STREAM_POLL) {
if(!self->usb_dev->usbd_hid_itf.base.usbd) {
// not enumerated for first time yet, structures not initalized.
return 0;
}
uintptr_t flags = arg;
ret = 0;
if ((flags & MP_STREAM_POLL_RD) && usbd_hid_rx_num(&self->usb_dev->usbd_hid_itf) > 0) {