]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/tests/mbed/timeout/main.cpp
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / tests / mbed / timeout / main.cpp
1 #include "mbed.h"
2 #include "test_env.h"
3
4 Timeout timer;
5 DigitalOut led(LED1);
6
7 namespace {
8 const int MS_INTERVALS = 1000;
9 }
10
11 void print_char(char c = '*') {
12 printf("%c", c);
13 fflush(stdout);
14 }
15
16 void toggleOff(void);
17
18 void toggleOn(void) {
19 static int toggle_counter = 0;
20 if (toggle_counter == MS_INTERVALS) {
21 led = !led;
22 print_char();
23 toggle_counter = 0;
24 }
25 toggle_counter++;
26 timer.attach_us(toggleOff, 500);
27 }
28
29 void toggleOff(void) {
30 timer.attach_us(toggleOn, 500);
31 }
32
33 int main() {
34 MBED_HOSTTEST_TIMEOUT(15);
35 MBED_HOSTTEST_SELECT(wait_us_auto);
36 MBED_HOSTTEST_DESCRIPTION(Timeout Int us);
37 MBED_HOSTTEST_START("MBED_24");
38
39 toggleOn();
40
41 while (1);
42 }
Imprint / Impressum