This program is serial communication using printf and scanf.
Dependencies: mbed
Revision 0:9c7b9c8c700f, committed 2016-09-02
- 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 |
diff -r 000000000000 -r 9c7b9c8c700f main.cpp --- /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
diff -r 000000000000 -r 9c7b9c8c700f mbed.bld --- /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