Squashed 'tmk_core/' changes from 7967731..b9e0ea0
b9e0ea0 Merge commit '7fa9d8bdea3773d1195b04d98fcf27cf48ddd81d' as 'tool/mbed/mbed-sdk' 7fa9d8b Squashed 'tool/mbed/mbed-sdk/' content from commit 7c21ce5 git-subtree-dir: tmk_core git-subtree-split: b9e0ea08cb940de20b3610ecdda18e9d8cd7c552
This commit is contained in:
42
tool/mbed/mbed-sdk/libraries/tests/mbed/timeout/main.cpp
Normal file
42
tool/mbed/mbed-sdk/libraries/tests/mbed/timeout/main.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "mbed.h"
|
||||
#include "test_env.h"
|
||||
|
||||
Timeout timer;
|
||||
DigitalOut led(LED1);
|
||||
|
||||
namespace {
|
||||
const int MS_INTERVALS = 1000;
|
||||
}
|
||||
|
||||
void print_char(char c = '*') {
|
||||
printf("%c", c);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void toggleOff(void);
|
||||
|
||||
void toggleOn(void) {
|
||||
static int toggle_counter = 0;
|
||||
if (toggle_counter == MS_INTERVALS) {
|
||||
led = !led;
|
||||
print_char();
|
||||
toggle_counter = 0;
|
||||
}
|
||||
toggle_counter++;
|
||||
timer.attach_us(toggleOff, 500);
|
||||
}
|
||||
|
||||
void toggleOff(void) {
|
||||
timer.attach_us(toggleOn, 500);
|
||||
}
|
||||
|
||||
int main() {
|
||||
MBED_HOSTTEST_TIMEOUT(15);
|
||||
MBED_HOSTTEST_SELECT(wait_us_auto);
|
||||
MBED_HOSTTEST_DESCRIPTION(Timeout Int us);
|
||||
MBED_HOSTTEST_START("MBED_24");
|
||||
|
||||
toggleOn();
|
||||
|
||||
while (1);
|
||||
}
|
||||
Reference in New Issue
Block a user