From 39f31c319551e44eb73c2c3fbf76612daf6434f5 Mon Sep 17 00:00:00 2001 From: Martin Kojtal <0xc0170@gmail.com> Date: Wed, 30 Aug 2017 12:51:50 +0100 Subject: [PATCH] idle loop: add deepsleep locks For backward compability, we invoke just sleep mode. Adding critical section to complete lock/unlock deepsleep section. --- rtos/rtos_idle.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rtos/rtos_idle.c b/rtos/rtos_idle.c index b13a6a670a..5f77406572 100644 --- a/rtos/rtos_idle.c +++ b/rtos/rtos_idle.c @@ -22,14 +22,16 @@ #include "rtos/rtos_idle.h" #include "platform/mbed_sleep.h" +#include "mbed_critical.h" static void default_idle_hook(void) { - /* Sleep: ideally, we should put the chip to sleep. - Unfortunately, this usually requires disconnecting the interface chip (debugger). - This can be done, but it would break the local file system. - */ + // critical section to complete sleep with locked deepsleep + core_util_critical_section_enter(); + sleep_manager_lock_deep_sleep(); sleep(); + sleep_manager_unlock_deep_sleep(); + core_util_critical_section_exit(); } static void (*idle_hook_fptr)(void) = &default_idle_hook;