Additional RawSerial example

main.cpp

Committer:
Jennifer Plunkett
Date:
15 months ago
Revision:
4:3ad999bfc3c4
Parent:
2:4ab47f33a1ae

File content as of revision 4:3ad999bfc3c4:

#include "mbed.h"

DigitalOut led1(LED1);
DigitalOut led2(LED2);

RawSerial pc(USBTX, USBRX);

void callback_ex() {
    // Note: you need to actually read from the serial to clear the RX interrupt
    pc.putc(pc.getc());
    led2 = !led2;
}

int main() {
    pc.attach(&callback_ex);

    while (1) {
        led1 = !led1;
        wait(0.5);
    }
}