Serial Passthporuogh

Dependencies:   mbed

main.cpp

Committer:
ARK4579
Date:
2015-12-29
Revision:
2:357688b9dfe9
Parent:
1:e9d1c42a73ae

File content as of revision 2:357688b9dfe9:

#include "mbed.h"

Serial pc(SERIAL_TX, SERIAL_RX);
Serial device(PA_9, PA_10);  // tx, rx

void callbackPC()
{
    while(pc.readable()) {
        device.putc(pc.getc());
    }
}

void callbackDEVICE()
{
    while(device.readable()) {
        pc.putc(device.getc());
    }
}

void setup()
{
    pc.printf("Setting up Setup...");
    pc.baud(115200);
    pc.attach(&callbackPC);
    device.baud(115200);
    device.attach(&callbackDEVICE);
}
DigitalIn btn1(PC_13);
DigitalOut myled(PA_5);
int main()
{
    setup();
    while(1) {
        if(btn1) {
            myled=1;
        } else {
            myled=0;
        }
    }
}