KEIS
Dependencies: C12832_lcd mbed-rtos mbed
Fork of rtos_queue by
main.cpp@5:2ac137a5448d, 2013-09-25 (annotated)
- Committer:
- khayakawa
- Date:
- Wed Sep 25 05:09:24 2013 +0000
- Revision:
- 5:2ac137a5448d
- Parent:
- 3:c490e2d69dd8
KEIS;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 1:d2ba5afbf91f | 1 | #include "mbed.h" |
emilmont | 1:d2ba5afbf91f | 2 | #include "rtos.h" |
khayakawa | 5:2ac137a5448d | 3 | #include "C12832_lcd.h" |
emilmont | 1:d2ba5afbf91f | 4 | |
khayakawa | 5:2ac137a5448d | 5 | C12832_LCD lcd; |
emilmont | 1:d2ba5afbf91f | 6 | |
khayakawa | 5:2ac137a5448d | 7 | /* send int by queue */ |
khayakawa | 5:2ac137a5448d | 8 | |
khayakawa | 5:2ac137a5448d | 9 | Queue<int, 16> queue; |
emilmont | 1:d2ba5afbf91f | 10 | |
emilmont | 1:d2ba5afbf91f | 11 | /* Send Thread */ |
emilmont | 3:c490e2d69dd8 | 12 | void send_thread (void const *args) { |
khayakawa | 5:2ac137a5448d | 13 | int message_s = 0 ; |
emilmont | 1:d2ba5afbf91f | 14 | while (true) { |
khayakawa | 5:2ac137a5448d | 15 | message_s++; |
khayakawa | 5:2ac137a5448d | 16 | queue.put(&message_s); |
emilmont | 1:d2ba5afbf91f | 17 | Thread::wait(1000); |
emilmont | 1:d2ba5afbf91f | 18 | } |
emilmont | 1:d2ba5afbf91f | 19 | } |
emilmont | 1:d2ba5afbf91f | 20 | |
emilmont | 1:d2ba5afbf91f | 21 | int main (void) { |
khayakawa | 5:2ac137a5448d | 22 | int *message_r; |
khayakawa | 5:2ac137a5448d | 23 | |
emilmont | 1:d2ba5afbf91f | 24 | Thread thread(send_thread); |
emilmont | 1:d2ba5afbf91f | 25 | |
emilmont | 1:d2ba5afbf91f | 26 | while (true) { |
emilmont | 1:d2ba5afbf91f | 27 | osEvent evt = queue.get(); |
emilmont | 1:d2ba5afbf91f | 28 | if (evt.status == osEventMessage) { |
khayakawa | 5:2ac137a5448d | 29 | message_r = (int*)evt.value.p; |
khayakawa | 5:2ac137a5448d | 30 | lcd.printf("%d ", *message_r); |
emilmont | 1:d2ba5afbf91f | 31 | } |
emilmont | 1:d2ba5afbf91f | 32 | } |
emilmont | 1:d2ba5afbf91f | 33 | } |