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