![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Rtos API example
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "test_env.h" 00003 00004 Ticker tick; 00005 DigitalOut led(LED1); 00006 00007 namespace { 00008 const int MS_INTERVALS = 1000; 00009 } 00010 00011 void print_char(char c = '*') 00012 { 00013 printf("%c", c); 00014 fflush(stdout); 00015 } 00016 00017 void togglePin(void) 00018 { 00019 static int ticker_count = 0; 00020 if (ticker_count >= MS_INTERVALS) { 00021 print_char(); 00022 ticker_count = 0; 00023 led = !led; // Blink 00024 } 00025 ticker_count++; 00026 } 00027 00028 int main() 00029 { 00030 MBED_HOSTTEST_TIMEOUT(15); 00031 MBED_HOSTTEST_SELECT(wait_us_auto); 00032 MBED_HOSTTEST_DESCRIPTION(Ticker Int us); 00033 MBED_HOSTTEST_START("MBED_23"); 00034 00035 tick.attach_us(togglePin, 1000); 00036 00037 while (1); 00038 }
Generated on Sun Jul 17 2022 08:25:26 by
![doxygen](doxygen.png)