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;
2727const int total_ticks = 10 ;
2828
2929void test_case_ticker () {
30- int before_print_us ;
30+ int start_time ;
3131 int after_print_us;
3232 int wait_time_us = ONE_SECOND_US;
3333
3434 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) {
3638 wait_us (wait_time_us);
37- before_print_us = timer.read ();
3839 greentea_send_kv (" tick" , i);
3940 after_print_us = timer.read ();
4041
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 );
4344 }
4445 timer.stop ();
4546}
You can’t perform that action at this time.
0 commit comments