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:
switches
Date:
Thu Dec 08 00:06:59 2016 +0000
Revision:
2:57500e991166
Parent:
1:6923b075c8d7
Child:
3:601c11238ccb
Added max32630fthr library to replace PMIC initialization code.; Renamed serial ports to be more clear.

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 2:57500e991166 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 2:57500e991166 10 DigitalOut rLED(LED1);
switches 2:57500e991166 11 DigitalOut gLED(LED2);
switches 2:57500e991166 12 DigitalOut bLED(LED3);
switches 0:60a522ae2e35 13
switches 0:60a522ae2e35 14 // main() runs in its own thread in the OS
switches 0:60a522ae2e35 15 // (note the calls to Thread::wait below for delays)
switches 0:60a522ae2e35 16 int main()
switches 0:60a522ae2e35 17 {
switches 1:6923b075c8d7 18 int c;
switches 2:57500e991166 19
switches 2:57500e991166 20 daplink.printf("daplink serial port\r\n");
switches 2:57500e991166 21 rLED = LED_ON;
switches 2:57500e991166 22 gLED = LED_ON;
switches 2:57500e991166 23 bLED = LED_OFF;
switches 2:57500e991166 24 pegasus.init();
switches 0:60a522ae2e35 25
switches 1:6923b075c8d7 26 // Virtual serial port over USB
switches 2:57500e991166 27 USBSerial microUSB;
switches 2:57500e991166 28 microUSB.printf("micro USB serial port\r\n");
switches 2:57500e991166 29
switches 2:57500e991166 30
switches 2:57500e991166 31 rLED = LED_OFF;
switches 1:6923b075c8d7 32
switches 1:6923b075c8d7 33 while(1) {
switches 2:57500e991166 34 c = microUSB.getc();
switches 2:57500e991166 35 microUSB.putc(c);
switches 2:57500e991166 36 daplink.putc(c);
switches 2:57500e991166 37 bLED = c & 1;
switches 0:60a522ae2e35 38 }
switches 0:60a522ae2e35 39 }
switches 0:60a522ae2e35 40