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

Files at this revision

API Documentation at this revision

Comitter:
frq08711@LMECWL0871.LME.ST.COM
Date:
Fri Feb 17 12:40:57 2017 +0100
Parent:
1:ab240722d7ef
Child:
5:fc157e6bd5a5
Commit message:
fixes for USBMSD

Changed in this revision

USBHost/TARGET_STM/USBEndpoint_STM.cpp Show annotated file Show diff for this revision Revisions of this file
USBHost/TARGET_STM/USBHALHost_STM.cpp Show annotated file Show diff for this revision Revisions of this file
USBHost/USBHostTypes.h Show annotated file Show diff for this revision Revisions of this file
USBHostMSD/USBHostMSD.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/USBHost/TARGET_STM/USBEndpoint_STM.cpp	Wed Feb 15 10:49:44 2017 +0100
+++ b/USBHost/TARGET_STM/USBEndpoint_STM.cpp	Fri Feb 17 12:40:57 2017 +0100
@@ -110,7 +110,7 @@
     state = USB_TYPE_PROCESSING;
     /*  one request */
     td_current->nextTD = (hcTd*)0;
-
+    td_current->retry = 0;
     *addr = (uint32_t)td_current;
     /*  dir /setup is inverted for ST */
     /* token is useful only ctrl endpoint */
--- 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;
--- a/USBHost/USBHostTypes.h	Wed Feb 15 10:49:44 2017 +0100
+++ b/USBHost/USBHostTypes.h	Fri Feb 17 12:40:57 2017 +0100
@@ -152,11 +152,12 @@
 #if defined(USBHOST_OTHER)
 
 typedef struct hcTd {
-	__IO uint32_t state;
+	__IO  uint32_t state;
 	__IO  uint8_t *  currBufPtr;    // Physical address of current buffer pointer
 	__IO  hcTd *     nextTD;         // Physical pointer to next Transfer Descriptor
 	__IO  uint32_t   size;        // size of buffer
 	void * ep;                      // ep address where a td is linked in
+	__IO  uint32_t retry;
 } PACKED HCTD;
 // ----------- HostController EndPoint Descriptor -------------
 typedef struct hcEd {
--- a/USBHostMSD/USBHostMSD.cpp	Wed Feb 15 10:49:44 2017 +0100
+++ b/USBHostMSD/USBHostMSD.cpp	Fri Feb 17 12:40:57 2017 +0100
@@ -136,7 +136,7 @@
     if (status == 0) {
         blockCount = (result[0] << 24) | (result[1] << 16) | (result[2] << 8) | result[3];
         blockSize = (result[4] << 24) | (result[5] << 16) | (result[6] << 8) | result[7];
-        USB_INFO("MSD [dev: %p] - blockCount: %u, blockSize: %d, Capacity: %d\r\n", dev, blockCount, blockSize, blockCount*blockSize);
+        USB_INFO("MSD [dev: %p] - blockCount: %lu, blockSize: %d,Capacity: %llu\r\n", dev, blockCount, blockSize,(uint64_t)blockCount*(uint64_t)blockSize);
     }
     return status;
 }
@@ -324,7 +324,6 @@
 }
 
 int USBHostMSD::disk_write(const uint8_t* buffer, uint32_t block_number, uint32_t count) {
-    USB_DBG("FILESYSTEM: write block: %lld, count: %d", block_number, count);
     if (!disk_init) {
         disk_initialize();
     }