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