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