USB serial demo passes data from virtual serial port to debug serial port

Dependencies:   max32630fthr USBDevice

Fork of FTHR_USB_serial by Greg Steiert

This program receives characters from the virtual USBSerial UART and sends them back out over the virtual USBSerial UART and the DapLink UART. It will also change the status of LED 1 based on the least significant bit of the character received.

The default baud rate for the DapLink UART is 9600, the baud rate does not affect the virtual USBSerial UART.

To Build using mbed CLI and GCC ARM:

mbed compile -m MAX32630FTHR -t GCC_ARM

Committer:
h_keyur
Date:
Thu Nov 16 21:27:19 2017 +0000
Revision:
8:d2b660bf5f94
Parent:
6:684c51f32c1d
Child:
9:02c5adb483c8
Updated all the libraries to latest revision

Who changed what in which revision?

UserRevisionLine numberNew contents of line
switches 0:60a522ae2e35 1 #include "mbed.h"
switches 2:57500e991166 2 #include "max32630fthr.h"
switches 1:6923b075c8d7 3 #include "USBSerial.h"
switches 0:60a522ae2e35 4
switches 6:684c51f32c1d 5 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
switches 0:60a522ae2e35 6
switches 1:6923b075c8d7 7 // Hardware serial port over DAPLink
switches 2:57500e991166 8 Serial daplink(P2_1, P2_0);
switches 1:6923b075c8d7 9
switches 3:601c11238ccb 10 // Virtual serial port over USB
h_keyur 8:d2b660bf5f94 11 USBSerial microUSB;
switches 3:601c11238ccb 12
switches 2:57500e991166 13 DigitalOut rLED(LED1);
switches 2:57500e991166 14 DigitalOut gLED(LED2);
switches 2:57500e991166 15 DigitalOut bLED(LED3);
switches 0:60a522ae2e35 16
switches 0:60a522ae2e35 17 // main() runs in its own thread in the OS
switches 0:60a522ae2e35 18 // (note the calls to Thread::wait below for delays)
switches 0:60a522ae2e35 19 int main()
switches 0:60a522ae2e35 20 {
switches 1:6923b075c8d7 21 int c;
switches 2:57500e991166 22
switches 2:57500e991166 23 daplink.printf("daplink serial port\r\n");
switches 3:601c11238ccb 24 microUSB.printf("micro USB serial port\r\n");
switches 2:57500e991166 25 rLED = LED_ON;
switches 2:57500e991166 26 gLED = LED_ON;
switches 2:57500e991166 27 bLED = LED_OFF;
switches 0:60a522ae2e35 28
switches 2:57500e991166 29 rLED = LED_OFF;
switches 1:6923b075c8d7 30
switches 1:6923b075c8d7 31 while(1) {
switches 2:57500e991166 32 c = microUSB.getc();
switches 2:57500e991166 33 microUSB.putc(c);
switches 2:57500e991166 34 daplink.putc(c);
switches 2:57500e991166 35 bLED = c & 1;
switches 0:60a522ae2e35 36 }
switches 0:60a522ae2e35 37 }
switches 0:60a522ae2e35 38