István Cserny
/
Lab07_STM32_RTOS
RTOS example - blinking two LEDs on a NUCLEO-F446RE board
main.cpp@0:a57cf939cc01, 2022-02-24 (annotated)
- Committer:
- cspista
- Date:
- Thu Feb 24 07:44:32 2022 +0000
- Revision:
- 0:a57cf939cc01
Final version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cspista | 0:a57cf939cc01 | 1 | #include "mbed.h" |
cspista | 0:a57cf939cc01 | 2 | #include "rtos.h" |
cspista | 0:a57cf939cc01 | 3 | |
cspista | 0:a57cf939cc01 | 4 | DigitalOut led1(D13); |
cspista | 0:a57cf939cc01 | 5 | DigitalOut led2(D12); |
cspista | 0:a57cf939cc01 | 6 | Thread thread; |
cspista | 0:a57cf939cc01 | 7 | |
cspista | 0:a57cf939cc01 | 8 | void led2_thread() { |
cspista | 0:a57cf939cc01 | 9 | while (true) { |
cspista | 0:a57cf939cc01 | 10 | led2 = !led2; |
cspista | 0:a57cf939cc01 | 11 | Thread::wait(1000); |
cspista | 0:a57cf939cc01 | 12 | } |
cspista | 0:a57cf939cc01 | 13 | } |
cspista | 0:a57cf939cc01 | 14 | |
cspista | 0:a57cf939cc01 | 15 | int main() { |
cspista | 0:a57cf939cc01 | 16 | thread.start(led2_thread); |
cspista | 0:a57cf939cc01 | 17 | |
cspista | 0:a57cf939cc01 | 18 | while (true) { |
cspista | 0:a57cf939cc01 | 19 | led1 = !led1; |
cspista | 0:a57cf939cc01 | 20 | Thread::wait(500); |
cspista | 0:a57cf939cc01 | 21 | } |
cspista | 0:a57cf939cc01 | 22 | } |