first try on RTOS mbed OS, Blinking LED
Dependencies: mbed-dev mbed-rtos
Fork of rtos_basic by
main.cpp@11:4fbd6b12906e, 2017-03-19 (annotated)
- Committer:
- rtandil
- Date:
- Sun Mar 19 17:16:46 2017 +0000
- Revision:
- 11:4fbd6b12906e
- Parent:
- 10:dc33cd3f4eb9
First Try
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 1:491820ee784d | 1 | #include "mbed.h" |
rtandil | 11:4fbd6b12906e | 2 | #include "Thread.h" |
emilmont | 1:491820ee784d | 3 | |
emilmont | 1:491820ee784d | 4 | DigitalOut led1(LED1); |
emilmont | 1:491820ee784d | 5 | DigitalOut led2(LED2); |
rtandil | 11:4fbd6b12906e | 6 | using namespace rtos; |
geky | 7:8d9919175929 | 7 | Thread thread; |
rtandil | 11:4fbd6b12906e | 8 | |
geky | 7:8d9919175929 | 9 | void led2_thread() { |
emilmont | 1:491820ee784d | 10 | while (true) { |
emilmont | 1:491820ee784d | 11 | led2 = !led2; |
mab5449 | 10:dc33cd3f4eb9 | 12 | wait(1); |
emilmont | 1:491820ee784d | 13 | } |
emilmont | 1:491820ee784d | 14 | } |
emilmont | 1:491820ee784d | 15 | |
emilmont | 1:491820ee784d | 16 | int main() { |
geky | 7:8d9919175929 | 17 | thread.start(led2_thread); |
emilmont | 1:491820ee784d | 18 | |
emilmont | 1:491820ee784d | 19 | while (true) { |
emilmont | 1:491820ee784d | 20 | led1 = !led1; |
mab5449 | 10:dc33cd3f4eb9 | 21 | wait(0.5); |
emilmont | 1:491820ee784d | 22 | } |
emilmont | 1:491820ee784d | 23 | } |