Jack Occleshaw
/
w2-timers2
w2timers
Revision 0:efb656120fe7, committed 2017-01-12
- Comitter:
- occle
- Date:
- Thu Jan 12 15:43:54 2017 +0000
- Commit message:
- w2timers
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 efb656120fe7 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jan 12 15:43:54 2017 +0000 @@ -0,0 +1,30 @@ +#include "mbed.h" +Timer timer_fast; // define Timer with name "timer_fast" +Timer timer_slow; // define Timer with name "timer_slow" +DigitalOut ledA(LED1); +DigitalOut ledB(LED2); +void task_fast(void); //function prototypes +void task_slow(void); + + +int main() { + timer_fast.start(); //start the Timers + timer_slow.start(); + while (1){ + if (timer_fast.read()>0.2){ //test Timer value + task_fast(); //call the task if trigger time is reached + timer_fast.reset(); //and reset the Timer + } + if (timer_slow.read()>1){ //test Timer value + task_slow(); + timer_slow.reset(); + } + } +} +void task_fast(void){ //”Fast” Task + ledA = !ledA; + } +void task_slow(void){ //”Slow” Task + ledB = !ledB; + } +
diff -r 000000000000 -r efb656120fe7 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Jan 12 15:43:54 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/25aea2a3f4e3 \ No newline at end of file