LPC1768 with mbed (2) and RawSerial test

Dependencies:   mbed

Committer:
tbotsQ
Date:
Mon Jan 23 09:45:15 2017 +0000
Revision:
0:3a22a1cf02f6
Echo Test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tbotsQ 0:3a22a1cf02f6 1 #include "mbed.h"
tbotsQ 0:3a22a1cf02f6 2
tbotsQ 0:3a22a1cf02f6 3 DigitalOut led1(LED1);
tbotsQ 0:3a22a1cf02f6 4 DigitalOut led2(LED2);
tbotsQ 0:3a22a1cf02f6 5
tbotsQ 0:3a22a1cf02f6 6 RawSerial pc(USBTX, USBRX);
tbotsQ 0:3a22a1cf02f6 7
tbotsQ 0:3a22a1cf02f6 8 void callback() {
tbotsQ 0:3a22a1cf02f6 9 // Note: you need to actually read from the serial to clear the RX interrupt
tbotsQ 0:3a22a1cf02f6 10 printf("%c\n", pc.getc());
tbotsQ 0:3a22a1cf02f6 11 led2 = !led2;
tbotsQ 0:3a22a1cf02f6 12 }
tbotsQ 0:3a22a1cf02f6 13
tbotsQ 0:3a22a1cf02f6 14 int main() {
tbotsQ 0:3a22a1cf02f6 15 pc.attach(&callback);
tbotsQ 0:3a22a1cf02f6 16
tbotsQ 0:3a22a1cf02f6 17 while (1) {
tbotsQ 0:3a22a1cf02f6 18 led1 = !led1;
tbotsQ 0:3a22a1cf02f6 19 wait(0.5);
tbotsQ 0:3a22a1cf02f6 20 }
tbotsQ 0:3a22a1cf02f6 21 }