Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-os by
main.cpp
00001 #include "mbed.h" 00002 #include "greentea-client/test_env.h" 00003 #include "rtos.h" 00004 00005 #if defined(MBED_RTOS_SINGLE_THREAD) 00006 #error [NOT_SUPPORTED] test not supported 00007 #endif 00008 00009 int total_ticks = 10; 00010 volatile int current_tick = 0; 00011 00012 DigitalOut LEDs[4] = { 00013 DigitalOut(LED1), DigitalOut(LED2), DigitalOut(LED3), DigitalOut(LED4) 00014 }; 00015 00016 void blink(void const *n) { 00017 static int blink_counter = 0; 00018 const int led_id = int(n); 00019 LEDs[led_id] = !LEDs[led_id]; 00020 if (++blink_counter == 75 && current_tick <= total_ticks) { 00021 greentea_send_kv("tick", current_tick++); 00022 blink_counter = 0; 00023 } 00024 } 00025 00026 int main(void) { 00027 GREENTEA_SETUP(total_ticks + 5, "timing_drift_auto"); 00028 00029 RtosTimer led_1_timer(blink, osTimerPeriodic, (void *)0); 00030 RtosTimer led_2_timer(blink, osTimerPeriodic, (void *)1); 00031 RtosTimer led_3_timer(blink, osTimerPeriodic, (void *)2); 00032 RtosTimer led_4_timer(blink, osTimerPeriodic, (void *)3); 00033 00034 led_1_timer.start(200); 00035 led_2_timer.start(100); 00036 led_3_timer.start(50); 00037 led_4_timer.start(25); 00038 00039 while(current_tick <= total_ticks) { 00040 Thread::wait(10); 00041 } 00042 00043 led_4_timer.stop(); 00044 led_3_timer.stop(); 00045 led_2_timer.stop(); 00046 led_1_timer.stop(); 00047 00048 GREENTEA_TESTSUITE_RESULT(1); 00049 00050 Thread::wait(osWaitForever); 00051 }
Generated on Tue Jul 12 2022 13:15:58 by
