avnish aggarwal
/
RTOS_TIMER
ok
Fork of rtos_timer by
main.cpp@1:c27c61c0a1e0, 2012-07-13 (annotated)
- Committer:
- emilmont
- Date:
- Fri Jul 13 11:39:26 2012 +0000
- Revision:
- 1:c27c61c0a1e0
- Parent:
- 0:2f5503566475
First implementation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 1:c27c61c0a1e0 | 1 | #include "mbed.h" |
emilmont | 1:c27c61c0a1e0 | 2 | #include "rtos.h" |
emilmont | 1:c27c61c0a1e0 | 3 | |
emilmont | 1:c27c61c0a1e0 | 4 | DigitalOut LEDs[4] = { |
emilmont | 1:c27c61c0a1e0 | 5 | DigitalOut(LED1), DigitalOut(LED2), DigitalOut(LED3), DigitalOut(LED4) |
emilmont | 1:c27c61c0a1e0 | 6 | }; |
emilmont | 1:c27c61c0a1e0 | 7 | |
emilmont | 1:c27c61c0a1e0 | 8 | void blink(void const *n) { |
emilmont | 1:c27c61c0a1e0 | 9 | LEDs[(int)n] = !LEDs[(int)n]; |
emilmont | 1:c27c61c0a1e0 | 10 | } |
emilmont | 1:c27c61c0a1e0 | 11 | |
emilmont | 1:c27c61c0a1e0 | 12 | int main(void) { |
emilmont | 1:c27c61c0a1e0 | 13 | RtosTimer led_1_timer(blink, osTimerPeriodic, (void *)0); |
emilmont | 1:c27c61c0a1e0 | 14 | RtosTimer led_2_timer(blink, osTimerPeriodic, (void *)1); |
emilmont | 1:c27c61c0a1e0 | 15 | RtosTimer led_3_timer(blink, osTimerPeriodic, (void *)2); |
emilmont | 1:c27c61c0a1e0 | 16 | RtosTimer led_4_timer(blink, osTimerPeriodic, (void *)3); |
emilmont | 1:c27c61c0a1e0 | 17 | |
emilmont | 1:c27c61c0a1e0 | 18 | led_1_timer.start(2000); |
emilmont | 1:c27c61c0a1e0 | 19 | led_2_timer.start(1000); |
emilmont | 1:c27c61c0a1e0 | 20 | led_3_timer.start(500); |
emilmont | 1:c27c61c0a1e0 | 21 | led_4_timer.start(250); |
emilmont | 1:c27c61c0a1e0 | 22 | |
emilmont | 1:c27c61c0a1e0 | 23 | Thread::wait(osWaitForever); |
emilmont | 1:c27c61c0a1e0 | 24 | } |