Skip to content

Commit 0ed26e5

Browse files
HAL sleep test fix
Prevents ticker upper layer initialization during test execution
1 parent 80dde0b commit 0ed26e5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

TESTS/mbed_hal/sleep/main.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ void sleep_usticker_test()
105105

106106
const ticker_irq_handler_type us_ticker_irq_handler_org = set_us_ticker_irq_handler(us_ticker_isr);
107107

108+
// call ticker_read_us to initialize ticker upper layer
109+
// prevents subsequent scheduling of max_delta interrupt during ticker initialization while test execution
110+
// (e.g when ticker_read_us is called)
111+
ticker_read_us(ticker);
112+
108113
/* Test only sleep functionality. */
109114
sleep_manager_lock_deep_sleep();
110115
TEST_ASSERT_FALSE_MESSAGE(sleep_manager_can_deep_sleep(), "deep sleep should be locked");
@@ -143,6 +148,11 @@ void deepsleep_lpticker_test()
143148
const unsigned int ticker_freq = ticker->interface->get_info()->frequency;
144149
const unsigned int ticker_width = ticker->interface->get_info()->bits;
145150

151+
// call ticker_read_us to initialize ticker upper layer
152+
// prevents subsequent scheduling of max_delta interrupt during ticker initialization while test execution
153+
// (e.g when ticker_read_us is called)
154+
ticker_read_us(ticker);
155+
146156
const ticker_irq_handler_type lp_ticker_irq_handler_org = set_lp_ticker_irq_handler(lp_ticker_isr);
147157

148158
/* Give some time Green Tea to finish UART transmission before entering

0 commit comments

Comments
 (0)