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