This program is serial communication using printf and scanf.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:9c7b9c8c700f
--- /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