File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,16 @@ using namespace utest::v1;
34
34
// (for more details about EVENTS_EVENT_SIZE see EventQueue constructor)
35
35
#define TEST_EQUEUE_SIZE (18 *EVENTS_EVENT_SIZE)
36
36
37
+ // By empirical, we take 80MHz CPU/2ms delay as base tolerance for time left test.
38
+ // For higher CPU frequency, tolerance is fixed to 2ms.
39
+ // For lower CPU frequency, tolerance is inversely proportional to CPU frequency.
40
+ // E.g.:
41
+ // 100MHz: 2ms
42
+ // 80MHz: 2ms
43
+ // 64MHz: 3ms
44
+ // 48MHz: 4ms
45
+ #define ALLOWED_TIME_LEFT_TOLERANCE_MS ((SystemCoreClock >= 80000000 ) ? 2 : ((80000000 * 2 + SystemCoreClock - 1 ) / SystemCoreClock))
46
+
37
47
// flag for called
38
48
volatile bool touched = false ;
39
49
@@ -283,7 +293,7 @@ int timeleft_events[2];
283
293
void check_time_left (EventQueue *queue, int index, int expected)
284
294
{
285
295
const int event_id = timeleft_events[index];
286
- TEST_ASSERT_INT_WITHIN (2 , expected, queue->time_left (event_id));
296
+ TEST_ASSERT_INT_WITHIN (ALLOWED_TIME_LEFT_TOLERANCE_MS , expected, queue->time_left (event_id));
287
297
touched = true ;
288
298
}
289
299
You can’t perform that action at this time.
0 commit comments