mbed official
/
rtos_timer
Basic example showing the RTOS Timer API
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "rtos.h" 00003 00004 DigitalOut LEDs[4] = { 00005 DigitalOut(LED1), DigitalOut(LED2), DigitalOut(LED3), DigitalOut(LED4) 00006 }; 00007 00008 void blink(void const *n) { 00009 LEDs[(int)n] = !LEDs[(int)n]; 00010 } 00011 00012 int main(void) { 00013 RtosTimer led_1_timer(blink, osTimerPeriodic, (void *)0); 00014 RtosTimer led_2_timer(blink, osTimerPeriodic, (void *)1); 00015 RtosTimer led_3_timer(blink, osTimerPeriodic, (void *)2); 00016 RtosTimer led_4_timer(blink, osTimerPeriodic, (void *)3); 00017 00018 led_1_timer.start(2000); 00019 led_2_timer.start(1000); 00020 led_3_timer.start(500); 00021 led_4_timer.start(250); 00022 00023 Thread::wait(osWaitForever); 00024 }
Generated on Tue Jul 12 2022 11:27:40 by 1.7.2