USB Host Driver with Socket Modem support. Works with revision 323 of mbed-src but broken with any later version.

Dependencies:   FATFileSystem

Fork of F401RE-USBHost by Norimasa Okamoto

Revision:
21:b4d53cc6d6ac
Parent:
18:61554f238584
Child:
24:f4d432f36ec2
--- a/USBHost/USBHALHost_KL46Z.cpp	Sun May 10 09:55:16 2015 +0000
+++ b/USBHost/USBHALHost_KL46Z.cpp	Mon Jun 22 18:49:28 2015 +0000
@@ -1,5 +1,5 @@
 // Simple USBHost for FRDM-KL46Z
-#if defined(TARGET_KL46Z)||defined(TARGET_KL25Z)||defined(TARGET_K64F)
+#if defined(TARGET_KL46Z)||defined(TARGET_KL25Z)||defined(TARGET_K64F)||defined(TARGET_GAMBIT)
 #include "USBHALHost.h"
 #include <algorithm>
 
@@ -63,8 +63,10 @@
 void USBHALHost::init() {
     // Disable IRQ
     NVIC_DisableIRQ(USB0_IRQn);
-
-#if defined(TARGET_K64F)
+#if defined(TARGET_GAMBIT)||defined(TARGET_K64F)
+    initPins();
+#endif
+#if defined(TARGET_K64F)||defined(TARGET_GAMBIT)
     MPU->CESR=0;
 #endif
 
@@ -515,6 +517,23 @@
     }
 }
 
+void USBHALHost::initPins()
+{
+    //Start with usb hub disabled in reset mode
+    DigitalOut usb_hub_nreset(PTA8,0);
+    //cell_nreset resets the cell radio
+    DigitalOut cell_nreset(PTA2,0);
+    printf("Resetting the radio to prevent processor freeze....\n");
+    printf("Start with USB hub disabled to prevent any USB transaction with Telit Module\n");
+    wait(1);
+    cell_nreset = 1;
+    wait(4);
+    //turn hub on
+    usb_hub_nreset = 1;
+    printf("turning USB hub back on\n");
+    wait(1);
+}
+
 #endif