Skip to content

Commit 46d4d6d

Browse files
committed
lp_us_tickers test - add tolerance to interrupt time.
On some platforms (e.g. K64F) different counters are used for time measurement and interrupt generation. Because of that we should relax interrupt test case and give additional time before checking if interrupt handler has been executed.
1 parent 97069a8 commit 46d4d6d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

TESTS/mbed_hal/lp_us_tickers/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#define FORCE_OVERFLOW_TEST (false)
2929
#define TICKER_INT_VAL 500
30-
#define TICKER_DELTA 50
30+
#define TICKER_DELTA 10
3131

3232
#define LP_TICKER_OVERFLOW_DELTA 0 // this will allow to detect that ticker counter rollovers to 0
3333
#define HF_TICKER_OVERFLOW_DELTA 50
@@ -147,17 +147,17 @@ void ticker_interrupt_test(void)
147147
TEST_ASSERT_EQUAL_INT_MESSAGE(0, intFlag, "Interrupt fired too early");
148148
}
149149

150-
/* Wait until ticker count reach value: tick_count + ticker_timeout[i].
150+
/* Wait until ticker count reach value: tick_count + ticker_timeout[i] + TICKER_DELTA.
151151
* Interrupt should be fired after this time. */
152-
while (intf->read() < (tick_count + ticker_timeout[i])) {
152+
while (intf->read() < (tick_count + ticker_timeout[i] + TICKER_DELTA)) {
153153
/* Just wait. */
154154
}
155155

156156
TEST_ASSERT_EQUAL(1, intFlag);
157157

158-
/* Wait until ticker count reach value: tick_count + 3 * ticker_timeout[i].
158+
/* Wait until ticker count reach value: tick_count + 2 * ticker_timeout[i] + TICKER_DELTA.
159159
* Interrupt should not be triggered again. */
160-
while (intf->read() < (tick_count + 3 * ticker_timeout[i])) {
160+
while (intf->read() < (tick_count + 2 * ticker_timeout[i] + TICKER_DELTA)) {
161161
/* Just wait. */
162162
}
163163

0 commit comments

Comments
 (0)