シリアル通信成功サンプル

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
c_bata
Date:
Sun Mar 15 05:14:17 2015 +0000
Parent:
0:1fce8daac823
Commit message:
????????????

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- 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;