File tree Expand file tree Collapse file tree 3 files changed +27
-7
lines changed Expand file tree Collapse file tree 3 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -177,22 +177,28 @@ static void default_idle_hook(void)
177
177
{
178
178
uint32_t elapsed_ticks = 0 ;
179
179
180
- core_util_critical_section_enter ();
181
- uint32_t ticks_to_sleep = svcRtxKernelSuspend ();
182
- MBED_ASSERT (os_timer->get_tick () == svcRtxKernelGetTickCount ());
180
+
181
+ uint32_t ticks_to_sleep = osKernelSuspend ();
182
+ MBED_ASSERT (os_timer->get_tick () == osKernelGetTickCount ());
183
183
if (ticks_to_sleep) {
184
+
184
185
os_timer->schedule_tick (ticks_to_sleep);
185
186
187
+ core_util_critical_section_enter ();
186
188
sleep_manager_lock_deep_sleep ();
187
- sleep ();
189
+ if (osKernelCanSleep ()) {
190
+ sleep ();
191
+ }
188
192
sleep_manager_unlock_deep_sleep ();
193
+ core_util_critical_section_exit ();
189
194
190
195
os_timer->cancel_tick ();
191
196
// calculate how long we slept
192
197
elapsed_ticks = os_timer->update_tick ();
198
+
193
199
}
194
- svcRtxKernelResume (elapsed_ticks);
195
- core_util_critical_section_exit ();
200
+ osKernelResume (elapsed_ticks);
201
+
196
202
}
197
203
198
204
#else
Original file line number Diff line number Diff line change @@ -350,7 +350,11 @@ uint32_t osKernelGetSysTimerCount (void);
350
350
/// Get the RTOS kernel system timer frequency.
351
351
/// \return frequency of the system timer.
352
352
uint32_t osKernelGetSysTimerFreq (void );
353
-
353
+
354
+ /// Check if it is safe to sleep.
355
+ /// \return osOK if it is safe to sleep, otherwise osErrorTimeout.
356
+ osStatus_t osKernelCanSleep (void );
357
+
354
358
355
359
// ==== Thread Management Functions ====
356
360
Original file line number Diff line number Diff line change @@ -641,3 +641,13 @@ uint32_t osKernelGetSysTimerFreq (void) {
641
641
return __svcKernelGetSysTimerFreq ();
642
642
}
643
643
}
644
+
645
+ /// Check if it is safe to sleep.
646
+ osStatus_t osKernelCanSleep (void ) {
647
+ if (osRtxInfo .kernel .pendSV ) {
648
+ return osErrorTimeout ;
649
+ } else {
650
+ return osOK ;
651
+ }
652
+ }
653
+
You can’t perform that action at this time.
0 commit comments