Adaptation of the official mbed USBHost repository to work with the LPC4088 Display Module

Dependents:   DMSupport DMSupport DMSupport DMSupport

Fork of DM_USBHost by EmbeddedArtists AB

Files at this revision

API Documentation at this revision

Comitter:
embeddedartists
Date:
Wed Oct 23 06:58:55 2019 +0000
Parent:
31:9a462d032742
Child:
33:819bbf04163b
Commit message:
Updates related to mbed OS 5

Changed in this revision

USBHost/USBHALHost.cpp Show annotated file Show diff for this revision Revisions of this file
USBHost/USBHost.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
USBHost3GModule/WANDongleSerialPort.cpp Show annotated file Show diff for this revision Revisions of this file
USBHostHub/USBHostHub.cpp 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/USBHALHost.cpp	Tue Feb 17 10:36:26 2015 +0100
+++ b/USBHost/USBHALHost.cpp	Wed Oct 23 06:58:55 2019 +0000
@@ -122,7 +122,7 @@
 
     //Cut power
     LPC_SC->PCONP &= ~(1UL<<31);
-    Thread::wait(1000);
+    ThisThread::sleep_for(1000);
 
     // turn on power for USB
     LPC_SC->PCONP       |= (1UL<<31);
@@ -166,7 +166,7 @@
     USB_DBG("initialize OHCI\n");
 
     // Wait 100 ms before apply reset
-    Thread::wait(100);
+    ThisThread::sleep_for(100);
 
     LPC_USB->HcControl       = 0; // HARDWARE RESET
     LPC_USB->HcControlHeadED = 0; // Initialize Control list head to Zero
@@ -206,7 +206,7 @@
 
     if (LPC_USB->HcRhPortStatus2 & OR_RH_PORT_CCS) {
         //Device connected
-        Thread::wait(150);
+        ThisThread::sleep_for(150);
         USB_DBG("Device connected (%08x)\n\r", LPC_USB->HcRhPortStatus2);
         deviceConnected(0, 2, LPC_USB->HcRhPortStatus2 & OR_RH_PORT_LSDA);
     }
@@ -331,7 +331,7 @@
 
     DigitalOut usb2_vbus_en(P0_12);
     usb2_vbus_en = 1;
-    Thread::wait(100); /* USB 2.0 spec says at least 50ms delay before port reset */
+    ThisThread::sleep_for(100); /* USB 2.0 spec says at least 50ms delay before port reset */
 
     // Initiate port reset
     LPC_USB->HcRhPortStatus1 = OR_RH_PORT_PRS;
@@ -352,7 +352,7 @@
     LPC_USB->HcRhPortStatus2 = OR_RH_PORT_PRSC;
     
     usb2_vbus_en = 1;
-    Thread::wait(200); /* Wait for at least 100 MS after port reset */
+    ThisThread::sleep_for(200); /* Wait for at least 100 MS after port reset */
 }
 
 
@@ -379,7 +379,7 @@
                     if (LPC_USB->HcRhPortStatus2 & OR_RH_PORT_CCS) {
 
                         // wait 150ms to avoid bounce
-                        wait_ms(150);
+                        ThisThread::sleep_for(150);
 
                         //Hub 0 (root hub), Port 2 (count starts at 1), Low or High speed
                         deviceConnected(0, 2, LPC_USB->HcRhPortStatus2 & OR_RH_PORT_LSDA);
@@ -393,7 +393,7 @@
                         }
 
                         // wait 200ms to avoid bounce
-                        wait_ms(200);
+                        ThisThread::sleep_for(200);
 
                         deviceDisconnected(0, 2, NULL, usb_hcca->DoneHead & 0xFFFFFFFE);
 
--- a/USBHost/USBHost.cpp	Tue Feb 17 10:36:26 2015 +0100
+++ b/USBHost/USBHost.cpp	Wed Oct 23 06:58:55 2019 +0000
@@ -150,7 +150,7 @@
                               break;
                           }
 
-                          Thread::wait(100);
+                          ThisThread::sleep_for(100);
                       }
 
                       USB_INFO("New device connected: %p [hub: %d - port: %d]", &devices[i], usb_msg->hub, usb_msg->port);
@@ -260,7 +260,7 @@
     ((USBHost *)arg)->usb_process();
 }
 
-USBHost::USBHost() : usbThread(USBHost::usb_process_static, (void *)this, osPriorityNormal, USB_THREAD_STACK)
+USBHost::USBHost() : usbThread(osPriorityNormal, USB_THREAD_STACK)
 {
     headControlEndpoint = NULL;
     headBulkEndpoint = NULL;
@@ -294,6 +294,8 @@
     
     listener = NULL;
     listenerSignal = 0;
+    
+    usbThread.start(callback(USBHost::usb_process_static, (void *)this));
 }
 
 USBHost::Lock::Lock(USBHost* pHost) : m_pHost(pHost)
@@ -555,7 +557,7 @@
     int index = findDevice(dev);
     if (index != -1) {
         USB_DBG("Resetting hub %d, port %d\n", dev->getHub(), dev->getPort());
-        Thread::wait(100);
+        ThisThread::sleep_for(100);
         if (dev->getHub() == 0) {
             resetRootHub();
         }
@@ -564,7 +566,7 @@
             dev->getHubParent()->portReset(dev->getPort());
         }
 #endif
-        Thread::wait(100);
+        ThisThread::sleep_for(100);
         deviceReset[index] = true;
         return USB_TYPE_OK;
     }
@@ -914,7 +916,7 @@
     } while(0);
 
     // Some devices may require this delay
-    Thread::wait(100);
+    ThisThread::sleep_for(100);
 
     return USB_TYPE_OK;
 }
--- a/USBHost/USBHostTypes.h	Tue Feb 17 10:36:26 2015 +0100
+++ b/USBHost/USBHostTypes.h	Wed Oct 23 06:58:55 2019 +0000
@@ -18,7 +18,7 @@
 #define USB_INC_H
 
 #include "mbed.h"
-#include "toolchain.h"
+#include "mbed_toolchain.h"
 
 enum USB_TYPE {
     USB_TYPE_OK = 0,
--- a/USBHost3GModule/WANDongleSerialPort.cpp	Tue Feb 17 10:36:26 2015 +0100
+++ b/USBHost3GModule/WANDongleSerialPort.cpp	Wed Oct 23 06:58:55 2019 +0000
@@ -90,7 +90,7 @@
   {
     //lock_rx.unlock();
     USB_ERR("host->bulkRead() returned %d", res);
-    Thread::wait(100);
+    ThisThread::sleep_for(100);
     return -1;
   }
   return 0;
@@ -123,7 +123,7 @@
   {
     //lock_tx.unlock();
     USB_ERR("host->bulkWrite() returned %d", res);
-    Thread::wait(100);
+    ThisThread::sleep_for(100);
     return -1;
   }
   return 0;
--- a/USBHostHub/USBHostHub.cpp	Tue Feb 17 10:36:26 2015 +0100
+++ b/USBHostHub/USBHostHub.cpp	Wed Oct 23 06:58:55 2019 +0000
@@ -129,7 +129,7 @@
         for (uint8_t j = 1; j <= nb_port; j++) {
             setPortFeature(PORT_POWER_FEATURE, j);
         }
-        Thread::wait(buf[5]*2);
+        ThisThread::sleep_for(buf[5]*2);
 
         host->interruptRead(dev, int_in, buf, 1, false);
         dev_connected = true;
@@ -242,7 +242,7 @@
             host->deviceDisconnected(dev->getHub() + 1, port, this, 0);
             break;
         }
-        Thread::wait(10);
+        ThisThread::sleep_for(10);
     }
 }
 
--- a/USBHostMSD/USBHostMSD.cpp	Tue Feb 17 10:36:26 2015 +0100
+++ b/USBHostMSD/USBHostMSD.cpp	Wed Oct 23 06:58:55 2019 +0000
@@ -322,7 +322,7 @@
 
 int USBHostMSD::disk_initialize() {
     USB_DBG("FILESYSTEM: init");
-    U16 i, timeout = 10;
+    uint16_t i, timeout = 10;
     
     if (!connected()) {
         // not connected
@@ -338,7 +338,7 @@
     getMaxLun();
 
     for (i = 0; i < timeout; i++) {
-        Thread::wait(100);
+        ThisThread::sleep_for(100);
         if (!testUnitReady())
             break;
     }