Modified USBDevice mainly for debug of serial port communications. It is unfinished and should not be used - use the main branch.

Dependents:   FinalProject

Fork of USBDevice by mbed official

Files at this revision

API Documentation at this revision

Comitter:
groletter
Date:
Sun Sep 01 23:34:33 2013 +0000
Parent:
8:335f2506f422
Commit message:
I'm trying to commit this project for school. I made minor mods to USBDevice for debugging mostly. I hope it doesn't get mixed with the "real" USBDevice code. If so I'll figure out how to un-do (this is my first time with mbed revsion control).

Changed in this revision

USBDevice/USBDevice.cpp Show annotated file Show diff for this revision Revisions of this file
USBDevice/USBDevice.h Show annotated file Show diff for this revision Revisions of this file
USBDevice/USBDevice_Types.h 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
--- a/USBDevice/USBDevice.cpp	Fri Mar 01 13:10:29 2013 +0000
+++ b/USBDevice/USBDevice.cpp	Sun Sep 01 23:34:33 2013 +0000
@@ -703,6 +703,10 @@
     return (device.state == CONFIGURED);
 }
 
+DEVICE_STATE USBDevice::getDeviceState() {
+    return device.state;
+}
+
 void USBDevice::connect(void)
 {
     /* Connect device */
@@ -715,6 +719,7 @@
 {
     /* Disconnect device */
     USBHAL::disconnect();
+    device.state = DEFAULT;
 }
 
 CONTROL_TRANSFER * USBDevice::getTransferPtr(void)
@@ -926,7 +931,7 @@
     static uint8_t stringLangidDescriptor[] = {
         0x04,               /*bLength*/
         STRING_DESCRIPTOR,  /*bDescriptorType 0x03*/
-        0x09,0x00,          /*bString Lang ID - 0x009 - English*/
+        0x09,0x04,          /*bString Lang ID - 0x409 - English*/
     };
     return stringLangidDescriptor;
 }
--- a/USBDevice/USBDevice.h	Fri Mar 01 13:10:29 2013 +0000
+++ b/USBDevice/USBDevice.h	Sun Sep 01 23:34:33 2013 +0000
@@ -39,6 +39,7 @@
     * Connect a device
     */
     void connect(void);
+    DEVICE_STATE getDeviceState();
     
     /*
     * Disconnect a device
--- a/USBDevice/USBDevice_Types.h	Fri Mar 01 13:10:29 2013 +0000
+++ b/USBDevice/USBDevice_Types.h	Sun Sep 01 23:34:33 2013 +0000
@@ -51,6 +51,8 @@
 #define DESCRIPTOR_TYPE(wValue)  (wValue >> 8)
 #define DESCRIPTOR_INDEX(wValue) (wValue & 0xf)
 
+#include <stdint.h>
+
 typedef struct {
     struct {
         uint8_t dataTransferDirection;
--- a/USBSerial/USBCDC.cpp	Fri Mar 01 13:10:29 2013 +0000
+++ b/USBSerial/USBCDC.cpp	Sun Sep 01 23:34:33 2013 +0000
@@ -90,6 +90,10 @@
     return USBDevice::write(EPBULK_IN, buffer, size, MAX_CDC_REPORT_SIZE);
 }
 
+bool USBCDC::sendNB(uint8_t * buffer, uint32_t size) {
+    return USBDevice::writeNB(EPBULK_IN, buffer, size, MAX_CDC_REPORT_SIZE);
+}
+
 bool USBCDC::readEP(uint8_t * buffer, uint32_t * size) {
     if (!USBDevice::readEP(EPBULK_OUT, buffer, size, MAX_CDC_REPORT_SIZE))
         return false;
--- a/USBSerial/USBCDC.h	Fri Mar 01 13:10:29 2013 +0000
+++ b/USBSerial/USBCDC.h	Sun Sep 01 23:34:33 2013 +0000
@@ -78,6 +78,8 @@
     */
     bool send(uint8_t * buffer, uint32_t size);
     
+    bool sendNB(uint8_t * buffer, uint32_t size);
+    
     /*
     * Read a buffer from a certain endpoint. Warning: blocking
     *
--- a/USBSerial/USBSerial.cpp	Fri Mar 01 13:10:29 2013 +0000
+++ b/USBSerial/USBSerial.cpp	Sun Sep 01 23:34:33 2013 +0000
@@ -26,6 +26,17 @@
     return 1;
 }
 
+int USBSerial::_putcNB(int c) {
+    if (!terminal_connected)
+        return 0;
+    if (!sendNB((uint8_t *)&c, 1)) {
+        return 0;
+    }
+    else {
+        return 1;
+    }
+}
+
 int USBSerial::_getc() {
     uint8_t c;
     while (buf.isEmpty());
@@ -64,6 +75,15 @@
     return true;
 }
 
+bool USBSerial::deviceAttached(void) {
+    if (terminal_connected) {
+        return true;
+    }
+    else {
+        return false;
+    }
+}
+
 uint8_t USBSerial::available() {
     return buf.available();
 }
--- a/USBSerial/USBSerial.h	Fri Mar 01 13:10:29 2013 +0000
+++ b/USBSerial/USBSerial.h	Sun Sep 01 23:34:33 2013 +0000
@@ -66,6 +66,8 @@
     */
     virtual int _putc(int c);
     
+    virtual int _putcNB(int c);
+    
     /**
     * Read a character: blocking
     *
@@ -80,6 +82,8 @@
     */
     uint8_t available(); 
     
+    bool deviceAttached(void);
+    
     /**
     * Write a block of data. 
     *