Giuseppe Guida
/
PROVA_1
Device sends a byte Coordinator reads a byte uart communication
Diff: main.cpp
- Revision:
- 0:094ab48dcd74
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue May 28 13:23:33 2019 +0000 @@ -0,0 +1,30 @@ +#include "mbed.h" +//#define DEVICE +#define COORDINATOR + +#ifdef COORDINATOR +Serial pc(USBTX, USBRX); +#endif + +RawSerial uart(PB_6,PB_7,9600); +int msg; + +int main() +{ + #ifdef DEVICE + int msg = 0x0F; + while(1) { + uart.putc(msg); + } + #endif + + #ifdef COORDINATOR + while(1) { + msg = uart.getc(); + wait(0.1); + pc.printf("Messaggio letto: %d\n\r",msg); + } + #endif + + +}