2013-02-18 15:32:11 +00:00
|
|
|
#include "mbed.h"
|
2015-01-27 12:10:16 +00:00
|
|
|
#include "test_env.h"
|
2013-02-18 15:32:11 +00:00
|
|
|
|
2018-01-24 13:45:18 +00:00
|
|
|
RawSerial pc(USBTX, USBRX);
|
2014-03-20 11:44:31 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
Ticker flipper_1;
|
|
|
|
DigitalOut led1(LED1);
|
2014-03-20 11:34:47 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
void flip_1() {
|
2014-03-20 11:34:47 +00:00
|
|
|
static int led1_state = 0;
|
2013-02-18 15:32:11 +00:00
|
|
|
if (led1_state) {
|
|
|
|
led1 = 0; led1_state = 0;
|
|
|
|
} else {
|
|
|
|
led1 = 1; led1_state = 1;
|
|
|
|
}
|
2018-01-24 13:45:18 +00:00
|
|
|
pc.putc('*');
|
2013-02-18 15:32:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Ticker flipper_2;
|
2014-03-20 11:34:47 +00:00
|
|
|
DigitalOut led2(LED2);
|
2013-02-18 15:32:11 +00:00
|
|
|
|
|
|
|
void flip_2() {
|
2014-03-20 11:34:47 +00:00
|
|
|
static int led2_state = 0;
|
2013-02-18 15:32:11 +00:00
|
|
|
if (led2_state) {
|
|
|
|
led2 = 0; led2_state = 0;
|
|
|
|
} else {
|
|
|
|
led2 = 1; led2_state = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
2015-02-11 10:37:03 +00:00
|
|
|
MBED_HOSTTEST_TIMEOUT(15);
|
|
|
|
MBED_HOSTTEST_SELECT(wait_us_auto);
|
|
|
|
MBED_HOSTTEST_DESCRIPTION(Ticker Int);
|
|
|
|
MBED_HOSTTEST_START("MBED_11");
|
2015-01-27 12:10:16 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
led1 = 0;
|
|
|
|
led2 = 0;
|
|
|
|
flipper_1.attach(&flip_1, 1.0); // the address of the function to be attached (flip) and the interval (1 second)
|
|
|
|
flipper_2.attach(&flip_2, 2.0); // the address of the function to be attached (flip) and the interval (2 seconds)
|
2013-06-27 21:20:47 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
while (true) {
|
|
|
|
wait(1.0);
|
|
|
|
}
|
|
|
|
}
|