Nathan Yonkee
/
Nucleo_rtos_basic
copy of mbed-rtos example
main.cpp@0:fc3f87b1b901, 2017-04-21 (annotated)
- Committer:
- tulanthoar
- Date:
- Fri Apr 21 19:46:15 2017 +0000
- Revision:
- 0:fc3f87b1b901
copy of mbed-rtos example
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tulanthoar | 0:fc3f87b1b901 | 1 | #include "mbed.h" |
tulanthoar | 0:fc3f87b1b901 | 2 | #include "rtos.h" |
tulanthoar | 0:fc3f87b1b901 | 3 | |
tulanthoar | 0:fc3f87b1b901 | 4 | void print_char(char c = '*') |
tulanthoar | 0:fc3f87b1b901 | 5 | { |
tulanthoar | 0:fc3f87b1b901 | 6 | printf("%c", c); |
tulanthoar | 0:fc3f87b1b901 | 7 | fflush(stdout); |
tulanthoar | 0:fc3f87b1b901 | 8 | } |
tulanthoar | 0:fc3f87b1b901 | 9 | |
tulanthoar | 0:fc3f87b1b901 | 10 | DigitalOut led1(LED1); |
tulanthoar | 0:fc3f87b1b901 | 11 | |
tulanthoar | 0:fc3f87b1b901 | 12 | void print_thread(void const *argument) |
tulanthoar | 0:fc3f87b1b901 | 13 | { |
tulanthoar | 0:fc3f87b1b901 | 14 | while (true) { |
tulanthoar | 0:fc3f87b1b901 | 15 | Thread::wait(1000); |
tulanthoar | 0:fc3f87b1b901 | 16 | print_char(); |
tulanthoar | 0:fc3f87b1b901 | 17 | } |
tulanthoar | 0:fc3f87b1b901 | 18 | } |
tulanthoar | 0:fc3f87b1b901 | 19 | |
tulanthoar | 0:fc3f87b1b901 | 20 | int main() |
tulanthoar | 0:fc3f87b1b901 | 21 | { |
tulanthoar | 0:fc3f87b1b901 | 22 | printf("\n\n*** RTOS basic example ***\n"); |
tulanthoar | 0:fc3f87b1b901 | 23 | Thread thread(print_thread, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); |
tulanthoar | 0:fc3f87b1b901 | 24 | while (true) { |
tulanthoar | 0:fc3f87b1b901 | 25 | led1 = !led1; |
tulanthoar | 0:fc3f87b1b901 | 26 | Thread::wait(500); |
tulanthoar | 0:fc3f87b1b901 | 27 | } |
tulanthoar | 0:fc3f87b1b901 | 28 | } |