@@ -54,6 +54,11 @@ extern "C" {
54
54
55
55
#define MAX_FUNC_EXEC_TIME_US 20
56
56
#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
57
62
#define NUM_OF_CALLS 100
58
63
59
64
#define NUM_OF_CYCLES 100000
@@ -452,6 +457,7 @@ void ticker_increment_test(void)
452
457
}
453
458
454
459
/* Test that common ticker functions complete with the required amount of time. */
460
+ template <int extra_latency>
455
461
void ticker_speed_test (void )
456
462
{
457
463
int counter = NUM_OF_CALLS;
@@ -477,7 +483,7 @@ void ticker_speed_test(void)
477
483
}
478
484
stop = us_ticker_read ();
479
485
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 )));
481
487
482
488
/* ---- Test ticker_set_interrupt function. ---- */
483
489
counter = NUM_OF_CALLS;
@@ -510,7 +516,7 @@ void ticker_speed_test(void)
510
516
}
511
517
stop = us_ticker_read ();
512
518
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 )));
514
520
515
521
}
516
522
@@ -611,7 +617,7 @@ Case cases[] = {
611
617
Case (" Microsecond ticker fire interrupt" , us_ticker_setup, ticker_fire_now_test, us_ticker_teardown),
612
618
Case (" Microsecond ticker overflow test" , us_ticker_setup, ticker_overflow_test, us_ticker_teardown),
613
619
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),
615
621
#if DEVICE_LPTICKER
616
622
Case (" lp ticker init is safe to call repeatedly" , lp_ticker_setup, ticker_init_test, lp_ticker_teardown),
617
623
Case (" lp ticker info test" , lp_ticker_setup, ticker_info_test, lp_ticker_teardown),
@@ -621,7 +627,7 @@ Case cases[] = {
621
627
Case (" lp ticker fire interrupt" , lp_ticker_setup, ticker_fire_now_test, lp_ticker_teardown),
622
628
Case (" lp ticker overflow test" , lp_ticker_setup, ticker_overflow_test, lp_ticker_teardown),
623
629
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),
625
631
#endif
626
632
};
627
633
0 commit comments