Carl - SolderSplash Labs / USBDevice

Dependents:   DipCortex-ADC-USB DipCortex-USB-CDC DipCortex-USB-EEProm WiFiDip-UsbKitchenSink ... more

Revision:
15:01040319e35c
Parent:
11:eeb3cbbaa996
Child:
17:722133315bbb
--- a/USBSerial/USBCDC.cpp	Thu Sep 12 14:45:27 2013 +0100
+++ b/USBSerial/USBCDC.cpp	Wed Oct 30 02:00:08 2013 +0000
@@ -52,6 +52,7 @@
                 break;
             case CDC_SET_LINE_CODING:
                 transfer->remaining = 7;
+                transfer->notify = true;
                 success = true;
                 terminal_connected = true;
                 break;
@@ -67,6 +68,31 @@
     return success;
 }
 
+void USBCDC::USBCallback_requestCompleted(uint8_t *buf, uint32_t length)
+{
+    if (length != 7) {
+        return;
+    }
+    
+    CONTROL_TRANSFER * transfer = getTransferPtr();
+
+    /* Process class-specific requests */
+    if (transfer->setup.bmRequestType.Type == CLASS_TYPE) {
+       if (transfer->setup.bRequest == CDC_SET_LINE_CODING) {
+           if (memcmp(cdc_line_coding, buf, 7)) {
+               memcpy(cdc_line_coding, buf, 7); 
+
+               int baud = buf[0] + (buf[1] << 8)
+                        + (buf[2] << 16) + (buf[3] << 24);
+               int bits = buf[6];
+               int parity = buf[5];
+               int stop = buf[4];
+               
+               lineCodingChanged(baud, bits, parity, stop);
+           }
+       }
+    }
+}
 
 // Called in ISR context
 // Set configuration. Return false if the