Very simple cooperative round-robin task scheduler. See examples.
Diff: Examples/example3.h
- Revision:
- 4:49652acb6806
- Parent:
- 1:f043501c4bed
--- a/Examples/example3.h Fri Mar 04 13:10:39 2011 +0000 +++ b/Examples/example3.h Fri Mar 04 13:55:15 2011 +0000 @@ -58,9 +58,14 @@ DigitalOut led4(LED4); void f1(SimpleTask *task) { - // wait(1); - t1 = Ton::On; + // wait(1); + if (!t1.isRunning()) { + t1 = Ton::On; + // Code that should execute once before the wait() goes here. + // ... + } if (t1) { + // This code will be executed once the timer times out. led1 = !led1; t1.reset(); }