File tree Expand file tree Collapse file tree 1 file changed +4
-24
lines changed
TESTS/mbed_drivers/timeout Expand file tree Collapse file tree 1 file changed +4
-24
lines changed Original file line number Diff line number Diff line change 20
20
21
21
using namespace utest ::v1;
22
22
23
- Timeout timer ;
23
+ Timeout timeout ;
24
24
DigitalOut led (LED1);
25
25
volatile int ticker_count = 0 ;
26
26
volatile bool print_tick = false ;
27
27
static const int total_ticks = 10 ;
28
-
29
- namespace {
30
- const int MS_INTERVALS = 1000 ;
31
- }
28
+ const int ONE_SECOND_US = 1000000 ;
32
29
33
30
void send_kv_tick () {
34
31
if (ticker_count <= total_ticks) {
32
+ timeout.attach_us (send_kv_tick, ONE_SECOND_US);
35
33
print_tick = true ;
36
34
}
37
35
}
38
36
39
- void toggleOff (void );
40
-
41
- void toggleOn (void ) {
42
- static int toggle_counter = 0 ;
43
- timer.attach_us (toggleOff, 500 );
44
-
45
- if (toggle_counter == MS_INTERVALS) {
46
- send_kv_tick ();
47
- toggle_counter = 0 ;
48
- } else {
49
- toggle_counter++;
50
- }
51
- }
52
-
53
- void toggleOff (void ) {
54
- timer.attach_us (toggleOn, 500 );
55
- }
56
-
57
37
void wait_and_print () {
58
38
while (ticker_count <= total_ticks) {
59
39
if (print_tick) {
@@ -65,7 +45,7 @@ void wait_and_print() {
65
45
}
66
46
67
47
void test_case_ticker () {
68
- toggleOn ( );
48
+ timeout. attach_us (send_kv_tick, ONE_SECOND_US );
69
49
wait_and_print ();
70
50
}
71
51
You can’t perform that action at this time.
0 commit comments