ST/USBHOST forked to add another HID handler for raw keyboard data to get more detail not available with current handlers (all pressed keys, all releases, and periodic updates)
Dependents: C64-stm429_discovery
Diff: USBHost/TARGET_STM/USBHALHost_STM.cpp
- Revision:
- 3:1c76b46ad779
- Parent:
- 1:ab240722d7ef
- Child:
- 5:fc157e6bd5a5
--- a/USBHost/TARGET_STM/USBHALHost_STM.cpp Wed Feb 15 10:49:44 2017 +0100 +++ b/USBHost/TARGET_STM/USBHALHost_STM.cpp Fri Feb 17 12:40:57 2017 +0100 @@ -93,13 +93,13 @@ return; } td->state = (urb_state == URB_DONE) ? USB_TYPE_IDLE : USB_TYPE_ERROR; - if (urb_state == URB_NOTREADY) - USB_ERR("urb_state != URB_NOTREADY"); - /* move buffer pointer , for size */ + /* move buffer pointer , for size */ if ((type != EP_TYPE_BULK) && (type != EP_TYPE_CTRL )) { /* in packet */ } else { if (urb_state == URB_DONE) { + /* reset retry counter */ + td->retry = 0; if (td->size > max_size) { /* enqueue another request */ td->currBufPtr += max_size; @@ -108,6 +108,19 @@ MBED_ASSERT(HAL_HCD_HC_SubmitRequest(hhcd, chnum, dir ,type , 1,(uint8_t*) td->currBufPtr, length, 0)==HAL_OK); return; } + }else if (urb_state == URB_NOTREADY) { + /* try again */ + /* abritary limit , to avoid dead lock if other error than + * slow response is */ + if (td->retry < 1000) { + /* increment retry counter */ + td->retry++; + length = td->size <= max_size ? td->size : max_size; + MBED_ASSERT(HAL_HCD_HC_SubmitRequest(hhcd, chnum, dir ,type , 1,(uint8_t*) td->currBufPtr, length, 0)==HAL_OK); + return; + }else USB_ERR("urb_state != URB_NOTREADY"); + + } } td->state = (urb_state == URB_DONE) ? USB_TYPE_IDLE : USB_TYPE_ERROR;