István Cserny / Mbed 2 deprecated Lab09_rtos_timer

Dependencies:   mbed mbed-rtos

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "rtos.h"
00003 
00004 DigitalOut LEDs[4] = {DigitalOut(D13), DigitalOut(D12), DigitalOut(D11), DigitalOut(D10)};
00005  
00006 void blink(void const *n) {
00007     LEDs[(int)n] = !LEDs[(int)n];
00008 }
00009  
00010 int main(void) {            
00011     RtosTimer led_1_timer(blink, osTimerPeriodic, (void *)0);
00012     RtosTimer led_2_timer(blink, osTimerPeriodic, (void *)1);
00013     RtosTimer led_3_timer(blink, osTimerPeriodic, (void *)2);
00014     RtosTimer led_4_timer(blink, osTimerPeriodic, (void *)3);
00015     
00016     led_1_timer.start(2000);
00017     led_2_timer.start(1000);
00018     led_3_timer.start(500);
00019     led_4_timer.start(250);
00020     
00021     Thread::wait(osWaitForever);
00022 }