This program is serial communication using printf and scanf.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
TetsuyaKonno
Date:
Fri Sep 02 07:10:14 2016 +0000
Commit message:
First program

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Sep 02 07:10:14 2016 +0000
@@ -0,0 +1,44 @@
+//------------------------------------------------------------------//
+//Supported MCU:   RZ/A1H
+//File Contents:   Serial Communication (GR-PEACH version)
+//Version number:  Ver.1.00
+//Date:            2016.01.18
+//Copyright:       Renesas Electronics Corporation
+//------------------------------------------------------------------//
+
+//Include
+//------------------------------------------------------------------//
+#include "mbed.h"
+
+//Constructor
+//------------------------------------------------------------------//
+Serial      pc(USBTX, USBRX);
+DigitalOut  LED_G(LED2);
+
+//Main
+//------------------------------------------------------------------//
+int main( void )
+{
+    int     i, ret;
+
+    /* Initialize MCU functions */
+    pc.baud(9600);
+
+    pc.printf( "Hello World!\n" );
+
+    while(1) {
+        pc.printf( "Input data : " );
+        ret = pc.scanf( "%d", &i );
+        if( ret == 1 ) {
+            pc.printf( "Get data : %d\n", i );
+            LED_G = 1;
+        } else {
+            pc.printf( "Data Error!!\n" );
+            pc.scanf( "%*[^\n]" );
+        }
+    }
+}
+
+//------------------------------------------------------------------//
+// End of file
+//------------------------------------------------------------------//
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Sep 02 07:10:14 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/2241e3a39974
\ No newline at end of file