Device sends a byte Coordinator reads a byte uart communication

Dependencies:   mbed

main.cpp

Committer:
giuseppe_guida
Date:
2019-05-28
Revision:
0:094ab48dcd74

File content as of revision 0:094ab48dcd74:

#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
   
   
}