Giuseppe Guida
/
PROVA_1
Device sends a byte Coordinator reads a byte uart communication
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 //#define DEVICE 00003 #define COORDINATOR 00004 00005 #ifdef COORDINATOR 00006 Serial pc(USBTX, USBRX); 00007 #endif 00008 00009 RawSerial uart(PB_6,PB_7,9600); 00010 int msg; 00011 00012 int main() 00013 { 00014 #ifdef DEVICE 00015 int msg = 0x0F; 00016 while(1) { 00017 uart.putc(msg); 00018 } 00019 #endif 00020 00021 #ifdef COORDINATOR 00022 while(1) { 00023 msg = uart.getc(); 00024 wait(0.1); 00025 pc.printf("Messaggio letto: %d\n\r",msg); 00026 } 00027 #endif 00028 00029 00030 }
Generated on Tue Jul 26 2022 22:00:13 by 1.7.2