Skip to content

Commit 53548e2

Browse files
fix and enable sleep_usticker_test
Increases tolerance value for sleep_usticker_test to cover extra time needed for cpu stats computation (for more details see MBED_CPU_STATS_ENABLED). Prevent scheduling interrupt during ticker initialization (in lp_ticker_init) while test execution.
1 parent fb28c41 commit 53548e2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

TESTS/mbed_hal/sleep/main.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ using namespace utest::v1;
3737

3838
/* Used for regular sleep mode, a target should be awake within 10 us. Define us delta value as follows:
3939
* delta = default 10 us + worst ticker resolution + extra time for code execution */
40+
#if defined(MBED_CPU_STATS_ENABLED)
41+
/* extra 25us for stats computation (for more details see MBED_CPU_STATS_ENABLED) */
42+
static const uint32_t sleep_mode_delta_us = (10 + 4 + 5 + 25);
43+
#else
4044
static const uint32_t sleep_mode_delta_us = (10 + 4 + 5);
45+
#endif
4146

4247
/* Used for deep-sleep mode, a target should be awake within 10 ms. Define us delta value as follows:
4348
* delta = default 10 ms + worst ticker resolution + extra time for code execution */
@@ -98,7 +103,6 @@ void lp_ticker_isr(const ticker_data_t *const ticker_data)
98103
* high frequency ticker interrupt can wake-up target from sleep. */
99104
void sleep_usticker_test()
100105
{
101-
#if 0
102106
const ticker_data_t * ticker = get_us_ticker_data();
103107
const unsigned int ticker_freq = ticker->interface->get_info()->frequency;
104108
const unsigned int ticker_width = ticker->interface->get_info()->bits;
@@ -109,6 +113,12 @@ void sleep_usticker_test()
109113
// prevents subsequent scheduling of max_delta interrupt during ticker initialization while test execution
110114
// (e.g when ticker_read_us is called)
111115
ticker_read_us(ticker);
116+
#ifdef DEVICE_LPTICKER
117+
// call ticker_read_us to initialize lp_ticker
118+
// prevents scheduling interrupt during ticker initialization (in lp_ticker_init) while test execution
119+
// (e.g when ticker_read_us is called for lp_ticker, see MBED_CPU_STATS_ENABLED)
120+
ticker_read_us(get_lp_ticker_data());
121+
#endif
112122

113123
/* Test only sleep functionality. */
114124
sleep_manager_lock_deep_sleep();
@@ -135,7 +145,6 @@ void sleep_usticker_test()
135145

136146
sleep_manager_unlock_deep_sleep();
137147
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep());
138-
#endif
139148
}
140149

141150
#ifdef DEVICE_LPTICKER

0 commit comments

Comments
 (0)