Kiyoshi Hayakawa
/
rtos_signals
KEIS
Fork of rtos_signals by
main.cpp@1:6a8fcc666593, 2012-07-13 (annotated)
- Committer:
- emilmont
- Date:
- Fri Jul 13 10:58:06 2012 +0000
- Revision:
- 1:6a8fcc666593
- Parent:
- 0:19f3d184e2ea
- Child:
- 4:ad6be128bc77
First implementation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 1:6a8fcc666593 | 1 | #include "mbed.h" |
emilmont | 1:6a8fcc666593 | 2 | #include "rtos.h" |
emilmont | 1:6a8fcc666593 | 3 | |
emilmont | 1:6a8fcc666593 | 4 | DigitalOut led(LED1); |
emilmont | 1:6a8fcc666593 | 5 | |
emilmont | 1:6a8fcc666593 | 6 | void led_thread(void const *argument) { |
emilmont | 1:6a8fcc666593 | 7 | while (true) { |
emilmont | 1:6a8fcc666593 | 8 | // Signal flags that are reported as event are automatically cleared. |
emilmont | 1:6a8fcc666593 | 9 | Thread::signal_wait(0x1); |
emilmont | 1:6a8fcc666593 | 10 | led = !led; |
emilmont | 1:6a8fcc666593 | 11 | } |
emilmont | 1:6a8fcc666593 | 12 | } |
emilmont | 1:6a8fcc666593 | 13 | |
emilmont | 1:6a8fcc666593 | 14 | int main (void) { |
emilmont | 1:6a8fcc666593 | 15 | Thread thread(led_thread); |
emilmont | 1:6a8fcc666593 | 16 | |
emilmont | 1:6a8fcc666593 | 17 | while (true) { |
emilmont | 1:6a8fcc666593 | 18 | Thread::wait(1000); |
emilmont | 1:6a8fcc666593 | 19 | thread.signal_set(0x1); |
emilmont | 1:6a8fcc666593 | 20 | } |
emilmont | 1:6a8fcc666593 | 21 | } |