@@ -37,7 +37,12 @@ using namespace utest::v1;
37
37
38
38
/* Used for regular sleep mode, a target should be awake within 10 us. Define us delta value as follows:
39
39
* 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
40
44
static const uint32_t sleep_mode_delta_us = (10 + 4 + 5 );
45
+ #endif
41
46
42
47
/* Used for deep-sleep mode, a target should be awake within 10 ms. Define us delta value as follows:
43
48
* 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)
98
103
* high frequency ticker interrupt can wake-up target from sleep. */
99
104
void sleep_usticker_test ()
100
105
{
101
- #if 0
102
106
const ticker_data_t * ticker = get_us_ticker_data ();
103
107
const unsigned int ticker_freq = ticker->interface ->get_info ()->frequency ;
104
108
const unsigned int ticker_width = ticker->interface ->get_info ()->bits ;
@@ -109,6 +113,12 @@ void sleep_usticker_test()
109
113
// prevents subsequent scheduling of max_delta interrupt during ticker initialization while test execution
110
114
// (e.g when ticker_read_us is called)
111
115
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
112
122
113
123
/* Test only sleep functionality. */
114
124
sleep_manager_lock_deep_sleep ();
@@ -135,7 +145,6 @@ void sleep_usticker_test()
135
145
136
146
sleep_manager_unlock_deep_sleep ();
137
147
TEST_ASSERT_TRUE (sleep_manager_can_deep_sleep ());
138
- #endif
139
148
}
140
149
141
150
#ifdef DEVICE_LPTICKER
0 commit comments