Test
Dependencies: X_NUCLEO_IHM01A1
main.cpp@2:35f13b7f3659, 2017-11-23 (annotated)
- Committer:
- bcostm
- Date:
- Thu Nov 23 13:09:25 2017 +0000
- Revision:
- 2:35f13b7f3659
- Parent:
- 0:5701b41769fd
- Child:
- 3:24ab1c8fefef
- replace mbed-rtos and mbed libraries with mbed-os library; - update example with latest thread syntax
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bcostm | 0:5701b41769fd | 1 | #include "mbed.h" |
bcostm | 0:5701b41769fd | 2 | |
bcostm | 0:5701b41769fd | 3 | void print_char(char c = '*') |
bcostm | 0:5701b41769fd | 4 | { |
bcostm | 0:5701b41769fd | 5 | printf("%c", c); |
bcostm | 0:5701b41769fd | 6 | fflush(stdout); |
bcostm | 0:5701b41769fd | 7 | } |
bcostm | 0:5701b41769fd | 8 | |
bcostm | 2:35f13b7f3659 | 9 | Thread thread; |
bcostm | 2:35f13b7f3659 | 10 | |
bcostm | 0:5701b41769fd | 11 | DigitalOut led1(LED1); |
bcostm | 0:5701b41769fd | 12 | |
bcostm | 2:35f13b7f3659 | 13 | void print_thread() |
bcostm | 0:5701b41769fd | 14 | { |
bcostm | 0:5701b41769fd | 15 | while (true) { |
bcostm | 2:35f13b7f3659 | 16 | wait(1); |
bcostm | 0:5701b41769fd | 17 | print_char(); |
bcostm | 0:5701b41769fd | 18 | } |
bcostm | 0:5701b41769fd | 19 | } |
bcostm | 0:5701b41769fd | 20 | |
bcostm | 0:5701b41769fd | 21 | int main() |
bcostm | 0:5701b41769fd | 22 | { |
bcostm | 0:5701b41769fd | 23 | printf("\n\n*** RTOS basic example ***\n"); |
bcostm | 2:35f13b7f3659 | 24 | |
bcostm | 2:35f13b7f3659 | 25 | thread.start(print_thread); |
bcostm | 2:35f13b7f3659 | 26 | |
bcostm | 0:5701b41769fd | 27 | while (true) { |
bcostm | 0:5701b41769fd | 28 | led1 = !led1; |
bcostm | 2:35f13b7f3659 | 29 | wait(0.5); |
bcostm | 0:5701b41769fd | 30 | } |
bcostm | 0:5701b41769fd | 31 | } |