File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
TESTS/mbed_drivers/wait_us Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -27,19 +27,20 @@ const int ONE_SECOND_US = 1000000;
27
27
const int total_ticks = 10 ;
28
28
29
29
void test_case_ticker () {
30
- int before_print_us ;
30
+ int start_time ;
31
31
int after_print_us;
32
32
int wait_time_us = ONE_SECOND_US;
33
33
34
34
timer.start ();
35
- for (int i = 0 ; i <= total_ticks; ++i) {
35
+ start_time = timer.read ();
36
+ int i = 0 ;
37
+ while (i <= total_ticks) {
36
38
wait_us (wait_time_us);
37
- before_print_us = timer.read ();
38
39
greentea_send_kv (" tick" , i);
39
40
after_print_us = timer.read ();
40
41
41
- // This won't be 100% exact, but it should be pretty close
42
- wait_time_us = ONE_SECOND_US - (after_print_us - before_print_us );
42
+ // This won't be 100% exact, but it should be very close
43
+ wait_time_us = after_print_us - start_time - ((++i) * ONE_SECOND_US );
43
44
}
44
45
timer.stop ();
45
46
}
You can’t perform that action at this time.
0 commit comments