Skip to content

Commit 890b7b7

Browse files
mprsecmonr
authored andcommitted
Provide fix to the implementation of ticker_overflow_test test case.
The intention was to use ticker_overflow_delta equal to 0 for low power ticker tests and ticker_overflow_delta equal to 50 for high frequency ticker tests. Current implementation is invalid since for devices which provide LOW_POWER_TIMER feature delta is equal to 0 and for devices without this feature delta is equal 50.
1 parent 060b883 commit 890b7b7

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

TESTS/mbed_hal/lp_us_tickers/main.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,8 @@
2929
#define TICKER_INT_VAL 2000
3030
#define TICKER_DELTA 50
3131

32-
#if DEVICE_LOWPOWERTIMER
33-
#define TICKER_OVERFLOW_DELTA 0 // this will allow to detect that ticker counter rollovers to 0
34-
#else
35-
#define TICKER_OVERFLOW_DELTA 50
36-
#endif
32+
#define LP_TICKER_OVERFLOW_DELTA 0 // this will allow to detect that ticker counter rollovers to 0
33+
#define HF_TICKER_OVERFLOW_DELTA 50
3734

3835
#define TICKER_100_TICKS 100
3936

@@ -47,6 +44,8 @@ using namespace utest::v1;
4744

4845
volatile int intFlag = 0;
4946
const ticker_interface_t* intf;
47+
unsigned int ticker_overflow_delta;
48+
5049

5150
/* Auxiliary function to count ticker ticks elapsed during execution of N cycles of empty while loop.
5251
* Parameter <step> is used to disable compiler optimisation. */
@@ -260,12 +259,12 @@ void ticker_overflow_test(void)
260259
intf->init();
261260

262261
/* Wait for max count. */
263-
while (intf->read() != (max_count - TICKER_OVERFLOW_DELTA)) {
262+
while (intf->read() != (max_count - ticker_overflow_delta)) {
264263
/* Just wait. */
265264
}
266265

267266
/* Now we are near/at the overflow point. Detect rollover. */
268-
while (intf->read() > TICKER_OVERFLOW_DELTA);
267+
while (intf->read() > ticker_overflow_delta);
269268

270269
const uint32_t after_overflow = intf->read();
271270

@@ -277,7 +276,7 @@ void ticker_overflow_test(void)
277276
const uint32_t next_after_overflow = intf->read();
278277

279278
/* Check that after the overflow ticker continue count. */
280-
TEST_ASSERT(after_overflow <= TICKER_OVERFLOW_DELTA);
279+
TEST_ASSERT(after_overflow <= ticker_overflow_delta);
281280
TEST_ASSERT(next_after_overflow >= TICKER_100_TICKS);
282281
TEST_ASSERT_EQUAL(0, intFlag);
283282

@@ -399,6 +398,8 @@ utest::v1::status_t hf_ticker_setup(const Case *const source, const size_t index
399398

400399
set_us_ticker_irq_handler(ticker_event_handler_stub);
401400

401+
ticker_overflow_delta = HF_TICKER_OVERFLOW_DELTA;
402+
402403
return greentea_case_setup_handler(source, index_of_case);
403404
}
404405

@@ -409,6 +410,8 @@ utest::v1::status_t lp_ticker_setup(const Case *const source, const size_t index
409410

410411
set_lp_ticker_irq_handler(ticker_event_handler_stub);
411412

413+
ticker_overflow_delta = LP_TICKER_OVERFLOW_DELTA;
414+
412415
return greentea_case_setup_handler(source, index_of_case);
413416
}
414417
#endif

0 commit comments

Comments
 (0)