Skip to content

Commit fccf649

Browse files
committed
Add the extra us delta latency on lp ticker speed test
on clear_interrupt and disable_interrupt APIs test case.
1 parent c904e22 commit fccf649

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

TESTS/mbed_hal/common_tickers/main.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ extern "C" {
5454

5555
#define MAX_FUNC_EXEC_TIME_US 20
5656
#define DELTA_FUNC_EXEC_TIME_US 5
57+
#if defined(__MICROLIB)
58+
#define ADD_EXTRA_DELTA_FUNC_EXEC_TIME_US 25
59+
#else
60+
#define ADD_EXTRA_DELTA_FUNC_EXEC_TIME_US 0
61+
#endif
5762
#define NUM_OF_CALLS 100
5863

5964
#define NUM_OF_CYCLES 100000
@@ -452,6 +457,7 @@ void ticker_increment_test(void)
452457
}
453458

454459
/* Test that common ticker functions complete with the required amount of time. */
460+
template<int extra_latency>
455461
void ticker_speed_test(void)
456462
{
457463
int counter = NUM_OF_CALLS;
@@ -477,7 +483,7 @@ void ticker_speed_test(void)
477483
}
478484
stop = us_ticker_read();
479485

480-
TEST_ASSERT(diff_us(start, stop, us_ticker_info) < (NUM_OF_CALLS * (MAX_FUNC_EXEC_TIME_US + DELTA_FUNC_EXEC_TIME_US)));
486+
TEST_ASSERT(diff_us(start, stop, us_ticker_info) < (NUM_OF_CALLS * (MAX_FUNC_EXEC_TIME_US + DELTA_FUNC_EXEC_TIME_US + extra_latency)));
481487

482488
/* ---- Test ticker_set_interrupt function. ---- */
483489
counter = NUM_OF_CALLS;
@@ -510,7 +516,7 @@ void ticker_speed_test(void)
510516
}
511517
stop = us_ticker_read();
512518

513-
TEST_ASSERT(diff_us(start, stop, us_ticker_info) < (NUM_OF_CALLS * (MAX_FUNC_EXEC_TIME_US + DELTA_FUNC_EXEC_TIME_US)));
519+
TEST_ASSERT(diff_us(start, stop, us_ticker_info) < (NUM_OF_CALLS * (MAX_FUNC_EXEC_TIME_US + DELTA_FUNC_EXEC_TIME_US + extra_latency)));
514520

515521
}
516522

@@ -611,7 +617,7 @@ Case cases[] = {
611617
Case("Microsecond ticker fire interrupt", us_ticker_setup, ticker_fire_now_test, us_ticker_teardown),
612618
Case("Microsecond ticker overflow test", us_ticker_setup, ticker_overflow_test, us_ticker_teardown),
613619
Case("Microsecond ticker increment test", us_ticker_setup, ticker_increment_test, us_ticker_teardown),
614-
Case("Microsecond ticker speed test", us_ticker_setup, ticker_speed_test, us_ticker_teardown),
620+
Case("Microsecond ticker speed test", us_ticker_setup, ticker_speed_test<0>, us_ticker_teardown),
615621
#if DEVICE_LPTICKER
616622
Case("lp ticker init is safe to call repeatedly", lp_ticker_setup, ticker_init_test, lp_ticker_teardown),
617623
Case("lp ticker info test", lp_ticker_setup, ticker_info_test, lp_ticker_teardown),
@@ -621,7 +627,7 @@ Case cases[] = {
621627
Case("lp ticker fire interrupt", lp_ticker_setup, ticker_fire_now_test, lp_ticker_teardown),
622628
Case("lp ticker overflow test", lp_ticker_setup, ticker_overflow_test, lp_ticker_teardown),
623629
Case("lp ticker increment test", lp_ticker_setup, ticker_increment_test, lp_ticker_teardown),
624-
Case("lp ticker speed test", lp_ticker_setup, ticker_speed_test, lp_ticker_teardown),
630+
Case("lp ticker speed test", lp_ticker_setup, ticker_speed_test<ADD_EXTRA_DELTA_FUNC_EXEC_TIME_US>, lp_ticker_teardown),
625631
#endif
626632
};
627633

0 commit comments

Comments
 (0)