Skip to content

Commit 88fa03a

Browse files
committed
Added RTOS_7 timer automated test to host test suite
1 parent 3690bdd commit 88fa03a

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

libraries/tests/rtos/mbed/timer/main.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,32 @@ DigitalOut LEDs[4] = {
55
DigitalOut(LED1), DigitalOut(LED2), DigitalOut(LED3), DigitalOut(LED4)
66
};
77

8+
void print_char(char c = '*')
9+
{
10+
printf("%c", c);
11+
fflush(stdout);
12+
}
13+
814
void blink(void const *n) {
9-
LEDs[(int)n] = !LEDs[(int)n];
15+
static int counter = 0;
16+
const int led_id = int(n);
17+
LEDs[led_id] = !LEDs[led_id];
18+
if (++counter == 75) {
19+
print_char();
20+
counter = 0;
21+
}
1022
}
1123

1224
int main(void) {
1325
RtosTimer led_1_timer(blink, osTimerPeriodic, (void *)0);
1426
RtosTimer led_2_timer(blink, osTimerPeriodic, (void *)1);
1527
RtosTimer led_3_timer(blink, osTimerPeriodic, (void *)2);
1628
RtosTimer led_4_timer(blink, osTimerPeriodic, (void *)3);
17-
18-
led_1_timer.start(2000);
19-
led_2_timer.start(1000);
20-
led_3_timer.start(500);
21-
led_4_timer.start(250);
22-
29+
30+
led_1_timer.start(200);
31+
led_2_timer.start(100);
32+
led_3_timer.start(50);
33+
led_4_timer.start(25);
34+
2335
Thread::wait(osWaitForever);
2436
}

workspace_tools/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,9 @@
536536
"id": "RTOS_7", "description": "Timer",
537537
"source_dir": join(TEST_DIR, "rtos", "mbed", "timer"),
538538
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES],
539+
"duration": 15,
540+
"automated": True,
541+
"host_test": "wait_us_auto"
539542
},
540543
{
541544
"id": "RTOS_8", "description": "ISR",

0 commit comments

Comments
 (0)