
BlinkThreadCallback2LED
Revision 0:7ede95000001, committed 2018-11-15
- Comitter:
- redona
- Date:
- Thu Nov 15 16:59:01 2018 +0000
- Commit message:
- BlinkThreadCallback2LED
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed-os.lib | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 15 16:59:01 2018 +0000 @@ -0,0 +1,23 @@ +#include "mbed.h" + +DigitalOut led1(LED1); +DigitalOut led2(LED2); + +// Blink function toggles the led in a long running loop +void blink(DigitalOut *led) { + *led = !*led; + wait(1); + *led = !*led; +} +int main() { + while(1){ + + Thread thread1; + Thread thread2; + + thread1.start(callback(blink, &led1)); + thread1.join(); + thread2.start(callback(blink, &led2)); + thread2.join(); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Thu Nov 15 16:59:01 2018 +0000 @@ -0,0 +1,1 @@ +https://github.com/armmbed/mbed-os/#bf6f2c3c6434a6de9eb9511feffa5948b3d1f20f