14
14
* limitations under the License.
15
15
*/
16
16
17
- #if 1 || !DEVICE_SLEEP
17
+ #if !DEVICE_SLEEP
18
18
#error [NOT_SUPPORTED] sleep not supported for this target
19
19
#endif
20
20
@@ -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,13 +103,23 @@ 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 ;
105
109
106
110
const ticker_irq_handler_type us_ticker_irq_handler_org = set_us_ticker_irq_handler (us_ticker_isr);
107
111
112
+ // call ticker_read_us to initialize ticker upper layer
113
+ // prevents subsequent scheduling of max_delta interrupt during ticker initialization while test execution
114
+ // (e.g when ticker_read_us is called)
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
122
+
108
123
/* Test only sleep functionality. */
109
124
sleep_manager_lock_deep_sleep ();
110
125
TEST_ASSERT_FALSE_MESSAGE (sleep_manager_can_deep_sleep (), " deep sleep should be locked" );
@@ -130,7 +145,6 @@ void sleep_usticker_test()
130
145
131
146
sleep_manager_unlock_deep_sleep ();
132
147
TEST_ASSERT_TRUE (sleep_manager_can_deep_sleep ());
133
- #endif
134
148
}
135
149
136
150
#ifdef DEVICE_LPTICKER
@@ -143,6 +157,11 @@ void deepsleep_lpticker_test()
143
157
const unsigned int ticker_freq = ticker->interface ->get_info ()->frequency ;
144
158
const unsigned int ticker_width = ticker->interface ->get_info ()->bits ;
145
159
160
+ // call ticker_read_us to initialize ticker upper layer
161
+ // prevents subsequent scheduling of max_delta interrupt during ticker initialization while test execution
162
+ // (e.g when ticker_read_us is called)
163
+ ticker_read_us (ticker);
164
+
146
165
const ticker_irq_handler_type lp_ticker_irq_handler_org = set_lp_ticker_irq_handler (lp_ticker_isr);
147
166
148
167
/* Give some time Green Tea to finish UART transmission before entering
0 commit comments