shibata 芝田
/
mbed_blinky
シリアル通信成功サンプル
Diff: main.cpp
- Revision:
- 1:7732cf688029
- Parent:
- 0:1fce8daac823
diff -r 1fce8daac823 -r 7732cf688029 main.cpp --- a/main.cpp Sat Mar 14 12:34:03 2015 +0000 +++ b/main.cpp Sun Mar 15 05:14:17 2015 +0000 @@ -4,15 +4,24 @@ DigitalOut led2(LED2); Serial pc(USBTX, USBRX); +Serial tocos(p13, p14); // TOCOS TWE-Lite (Serial) +char tweLiteBuffer[128]; + void callback() { - // Note: you need to actually read from the serial to clear the RX interrupt - printf("%c\n", pc.getc()); + int i=0; + while(tocos.readable()){ + tweLiteBuffer[i] = tocos.getc(); + i++; + } led2 = !led2; + pc.printf(tweLiteBuffer); } int main() { - pc.attach(&callback); + pc.baud( 115200 ); + tocos.baud( 115200 ); + tocos.attach(&callback); while (1) { led1 = !led1;