This program is blinking the LED by interrupt timer.
Dependencies: mbed
Revision 0:5a2587aa8b79, committed 2016-09-02
- Comitter:
- TetsuyaKonno
- Date:
- Fri Sep 02 06:35:04 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 5a2587aa8b79 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Sep 02 06:35:04 2016 +0000 @@ -0,0 +1,61 @@ +//------------------------------------------------------------------// +//Supported MCU: RZ/A1H +//File Contents: Interrupt Timer LED (GR-PEACH version) +//Version number: Ver.1.00 +//Date: 2016.01.18 +//Copyright: Renesas Electronics Corporation +//------------------------------------------------------------------// + +//Include +//------------------------------------------------------------------// +#include "mbed.h" + +//Constructor +//------------------------------------------------------------------// +Ticker interrput; +DigitalOut LED_R(LED1); +DigitalOut LED_G(LED2); +DigitalOut LED_B(LED3); + +//Prototype +//------------------------------------------------------------------// +void intTimer( void ); /* Interrupt fanction */ +void timer( unsigned long timer_set ); + +//Globle +//------------------------------------------------------------------// +volatile unsigned long cnt_timer; /* Used by timer function */ + +//Main +//------------------------------------------------------------------// +int main( void ) +{ + /* Initialize MCU functions */ + interrput.attach(&intTimer, 0.001); + + while(1) { + LED_R = 1; + timer( 1000 ); + LED_R = 0; + timer( 1000 ); + } +} + +//Interrupt Timer +//------------------------------------------------------------------// +void intTimer( void ) +{ + cnt_timer++; +} + +//Timer fanction +//------------------------------------------------------------------// +void timer( unsigned long timer_set ) +{ + cnt_timer = 0; + while( cnt_timer < timer_set ); +} + +//------------------------------------------------------------------// +// End of file +//------------------------------------------------------------------// \ No newline at end of file
diff -r 000000000000 -r 5a2587aa8b79 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Sep 02 06:35:04 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/2241e3a39974 \ No newline at end of file