@@ -53,7 +53,7 @@ extern "C" {
53
53
#define TICKER_100_TICKS 100
54
54
#define TICKER_500_TICKS 500
55
55
56
- #define MAX_FUNC_EXEC_TIME_US 30
56
+ #define MAX_FUNC_EXEC_TIME_US 20
57
57
#define DELTA_FUNC_EXEC_TIME_US 5
58
58
#define NUM_OF_CALLS 100
59
59
@@ -62,6 +62,8 @@ extern "C" {
62
62
#define US_TICKER_OV_LIMIT 35000
63
63
#define LP_TICKER_OV_LIMIT 4000
64
64
65
+ #define TICKS_TO_US (ticks, freq ) ((uint32_t ) ((uint64_t )ticks * US_PER_S /freq))
66
+
65
67
using namespace utest ::v1;
66
68
67
69
volatile int intFlag = 0 ;
@@ -216,11 +218,20 @@ void ticker_info_test(void)
216
218
/* Test that ticker interrupt fires only when the ticker counter increments to the value set by ticker_set_interrupt. */
217
219
void ticker_interrupt_test (void )
218
220
{
219
- uint32_t ticker_timeout[] = { 100 , 200 , 300 , 500 };
221
+ uint32_t ticker_timeout[] = { 100 , 200 , 300 , 400 , 500 , 600 , 700 , 800 , 900 , 1000 , 1100 , 1200 };
222
+ uint8_t run_count = 0 ;
223
+ const ticker_info_t *p_ticker_info = intf->get_info ();
220
224
221
225
overflow_protect ();
222
226
223
227
for (uint32_t i = 0 ; i < (sizeof (ticker_timeout) / sizeof (uint32_t )); i++) {
228
+
229
+ /* Skip timeout if less than max allowed execution time of set_interrupt() - 20 us */
230
+ if (TICKS_TO_US (ticker_timeout[i], p_ticker_info->frequency ) < (MAX_FUNC_EXEC_TIME_US + DELTA_FUNC_EXEC_TIME_US)) {
231
+ continue ;
232
+ }
233
+
234
+ run_count++;
224
235
intFlag = 0 ;
225
236
const uint32_t tick_count = intf->read ();
226
237
@@ -251,6 +262,9 @@ void ticker_interrupt_test(void)
251
262
252
263
TEST_ASSERT_EQUAL (1 , intFlag);
253
264
}
265
+
266
+ /* At least 3 sub test cases must be executed. */
267
+ TEST_ASSERT_MESSAGE (run_count >= 3 , " At least 3 sub test cases must be executed" );
254
268
}
255
269
256
270
/* Test that ticker interrupt is not triggered when ticker_set_interrupt */
0 commit comments