USB device stack, fixes for USBSerial & KL25Z

Fork of USBDevice by mbed official

Files at this revision

API Documentation at this revision

Comitter:
alpov
Date:
Mon Apr 28 12:15:41 2014 +0000
Parent:
22:5b7d31d9d3f3
Commit message:
fixed bus reset for KL25Z, added more terminal_connected checking stuff

Changed in this revision

USBDevice/USBHAL_KL25Z.cpp Show annotated file Show diff for this revision Revisions of this file
USBSerial/USBCDC.cpp Show annotated file Show diff for this revision Revisions of this file
USBSerial/USBCDC.h Show annotated file Show diff for this revision Revisions of this file
USBSerial/USBSerial.cpp Show annotated file Show diff for this revision Revisions of this file
USBSerial/USBSerial.h Show annotated file Show diff for this revision Revisions of this file
diff -r 5b7d31d9d3f3 -r c7639faed2eb USBDevice/USBHAL_KL25Z.cpp
--- a/USBDevice/USBHAL_KL25Z.cpp	Wed Apr 02 21:00:41 2014 +0100
+++ b/USBDevice/USBHAL_KL25Z.cpp	Mon Apr 28 12:15:41 2014 +0000
@@ -450,6 +450,9 @@
         USB0->ERREN   =  0xFF;  // enable error interrupt sources
         USB0->ADDR    =  0x00;  // set default address
 
+        // reset bus for USBDevice layer
+        busReset();
+
         return;
     }
 
diff -r 5b7d31d9d3f3 -r c7639faed2eb USBSerial/USBCDC.cpp
--- a/USBSerial/USBCDC.cpp	Wed Apr 02 21:00:41 2014 +0100
+++ b/USBSerial/USBCDC.cpp	Mon Apr 28 12:15:41 2014 +0000
@@ -34,6 +34,10 @@
     USBDevice::connect(connect_blocking);
 }
 
+void USBCDC::USBCallback_busReset(void) {
+    terminal_connected = false;
+};
+
 bool USBCDC::USBCallback_request(void) {
     /* Called in ISR context */
 
diff -r 5b7d31d9d3f3 -r c7639faed2eb USBSerial/USBCDC.h
--- a/USBSerial/USBCDC.h	Wed Apr 02 21:00:41 2014 +0100
+++ b/USBSerial/USBCDC.h	Mon Apr 28 12:15:41 2014 +0000
@@ -116,6 +116,7 @@
     virtual bool USBCallback_request();
     virtual void USBCallback_requestCompleted(uint8_t *buf, uint32_t length);
     virtual bool USBCallback_setConfiguration(uint8_t configuration);
+    virtual void USBCallback_busReset(void);
     volatile bool terminal_connected;
 
 };
diff -r 5b7d31d9d3f3 -r c7639faed2eb USBSerial/USBSerial.cpp
--- a/USBSerial/USBSerial.cpp	Wed Apr 02 21:00:41 2014 +0100
+++ b/USBSerial/USBSerial.cpp	Mon Apr 28 12:15:41 2014 +0000
@@ -67,3 +67,7 @@
 uint8_t USBSerial::available() {
     return buf.available();
 }
+
+bool USBSerial::connected() {
+    return terminal_connected;
+}
diff -r 5b7d31d9d3f3 -r c7639faed2eb USBSerial/USBSerial.h
--- a/USBSerial/USBSerial.h	Wed Apr 02 21:00:41 2014 +0100
+++ b/USBSerial/USBSerial.h	Mon Apr 28 12:15:41 2014 +0000
@@ -83,6 +83,13 @@
     */
     uint8_t available(); 
 
+    /**
+    * Check if the terminal is connected.
+    *
+    * @returns connection status
+    */
+    bool connected(); 
+
     /** Determine if there is a character available to read
      *
      *  @returns