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

Dependencies:   USBDevice max32630fthr

Fork of blinky_max32630fthr by Greg Steiert

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "max32630fthr.h"
00003 #include "USBSerial.h"
00004 
00005 MAX32630FTHR pegasus;
00006 
00007 // Hardware serial port over DAPLink
00008 Serial daplink(P2_1, P2_0);
00009 
00010 // Virtual serial port over USB
00011 USBSerial microUSB;
00012 
00013 DigitalOut rLED(LED1);
00014 DigitalOut gLED(LED2);
00015 DigitalOut bLED(LED3);
00016 
00017 // main() runs in its own thread in the OS
00018 // (note the calls to Thread::wait below for delays)
00019 int main()
00020 {
00021     int c;
00022 
00023     daplink.printf("daplink serial port\r\n");
00024     microUSB.printf("micro USB serial port\r\n");
00025     rLED = LED_ON;
00026     gLED = LED_ON;
00027     bLED = LED_OFF;
00028 
00029     pegasus.init(MAX32630FTHR::VIO_3V3);    
00030     rLED = LED_OFF;
00031 
00032     while(1) {
00033         c = microUSB.getc();
00034         microUSB.putc(c);
00035         daplink.putc(c);
00036         bLED = c & 1;
00037     }
00038 }
00039