transmit what you receive in both directions
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 void recieve_this(void); 00004 void recieve_that(void); 00005 00006 DigitalOut led1(LED1); 00007 DigitalOut led2(LED2); 00008 00009 RawSerial this_way(USBTX,USBRX); 00010 RawSerial that_way(D1,D0); 00011 00012 // main() runs in its own thread in the OS 00013 // (note the calls to Thread::wait below for delays) 00014 int main() { 00015 00016 00017 this_way.baud(115200); 00018 /** attach the callback function to be called whenever a character is received */ 00019 this_way.attach(&recieve_this, Serial::RxIrq); 00020 ///set the baud rate 00021 that_way.baud(115200); 00022 /** attach the callback function to be called whenever a character is received */ 00023 that_way.attach(&recieve_that, Serial::RxIrq); 00024 00025 00026 while (true) { 00027 Thread::wait(1000); 00028 } 00029 } 00030 00031 00032 void recieve_this(void) 00033 { 00034 ///blink an led for fun 00035 led1 = !led1; 00036 /** get a character, then put it back on the other interface */ 00037 that_way.putc(this_way.getc()); 00038 00039 } 00040 /** get incoming data from second serial interface and put to other 00041 * @param none 00042 * @returns none 00043 */ 00044 void recieve_that(void) 00045 { 00046 ///blink an led for fun 00047 led2 = !led2; 00048 /** get a character, then put it back on the other interface */ 00049 this_way.putc(that_way.getc()); 00050 }
Generated on Thu Jul 14 2022 02:32:07 by
1.7.2