Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 //--- Includes 00002 #include "mbed.h" 00003 00004 //--- Defines 00005 #define USB_UART 1 00006 #define ON 1 00007 #define OFF 0 00008 #define BAUDRATE0 19200 00009 #define BAUDRATE1 115200 00010 #define K_BACKSPACE 8 00011 #define K_RETURN 13 00012 00013 //--- Objects 00014 DigitalOut myled (LED1); 00015 #if USB_UART 00016 Serial myUART ( USBTX, USBRX ); 00017 #else 00018 Serial myUART ( p13, p14 ); //--- TX RX 00019 #endif 00020 Serial loopUART ( p28, p27 ); //--- TX RX 00021 00022 int main() { 00023 char character; 00024 00025 //--- init 00026 myled = ON; 00027 wait(0.2); 00028 myUART.baud( BAUDRATE1 ); 00029 loopUART.baud( BAUDRATE1 ); 00030 myled = OFF; 00031 00032 while(1) { 00033 //--- Read myUART and print to loopUART 00034 if( myUART.readable() ) { 00035 character = myUART.getc(); 00036 loopUART.printf( "%c", character ); 00037 } 00038 00039 //--- Read loopUART and print to myUART 00040 if( loopUART.readable() ) { 00041 character = loopUART.getc(); 00042 00043 //--- Return Key: new line on the console 00044 if( character == K_RETURN ) { 00045 myUART.printf("\n\r"); 00046 } else if( character == K_BACKSPACE ) { 00047 myUART.printf("\b \b"); 00048 } else { 00049 myUART.printf( "%c", character ); 00050 } 00051 } 00052 00053 /* 00054 //--- Loopback the UART 00055 if( myUART.readable() ) { 00056 myUART.putc( myUART.getc() ); 00057 } 00058 */ 00059 00060 /* 00061 //--- Hello World on the UART 00062 myUART.printf( "Hello, world!\n\r" ); 00063 */ 00064 } 00065 }
Generated on Tue Jul 12 2022 17:30:54 by
1.7.2