]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/tests/mbed/ticker/main.cpp
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / tests / mbed / ticker / main.cpp
1 #include "mbed.h"
2 #include "test_env.h"
3
4 void print_char(char c = '*')
5 {
6     printf("%c", c);
7     fflush(stdout);
8 }
9
10 Ticker flipper_1;
11 DigitalOut led1(LED1);
12
13 void flip_1() {
14     static int led1_state = 0;
15     if (led1_state) {
16         led1 = 0; led1_state = 0;
17     } else {
18         led1 = 1; led1_state = 1;
19     }
20     print_char();
21 }
22
23 Ticker flipper_2;
24 DigitalOut led2(LED2);
25
26 void flip_2() {
27     static int led2_state = 0;
28     if (led2_state) {
29         led2 = 0; led2_state = 0;
30     } else {
31         led2 = 1; led2_state = 1;
32     }
33 }
34
35 int main() {
36     MBED_HOSTTEST_TIMEOUT(15);
37     MBED_HOSTTEST_SELECT(wait_us_auto);
38     MBED_HOSTTEST_DESCRIPTION(Ticker Int);
39     MBED_HOSTTEST_START("MBED_11");
40
41     led1 = 0;
42     led2 = 0;
43     flipper_1.attach(&flip_1, 1.0); // the address of the function to be attached (flip) and the interval (1 second)
44     flipper_2.attach(&flip_2, 2.0); // the address of the function to be attached (flip) and the interval (2 seconds)
45
46     while (true) {
47         wait(1.0);
48     }
49 }