@@ -120,6 +120,90 @@ void sleep_manager_unlock_deep_sleep_internal(void);
120120 * @return true if a target can go to deepsleep, false otherwise
121121 */
122122bool sleep_manager_can_deep_sleep (void );
123+
124+
125+ /** Enter auto selected sleep mode. It chooses the sleep or deeepsleep modes based
126+ * on the deepsleep locking counter
127+ *
128+ * This function is IRQ and thread safe
129+ *
130+ * @note
131+ * If MBED_DEBUG is defined, only hal_sleep is allowed. This ensures the debugger
132+ * to be active for debug modes.
133+ *
134+ */
135+ void sleep_manager_sleep_auto (void );
136+
137+ /** Send the microcontroller to sleep
138+ *
139+ * @note This function can be a noop if not implemented by the platform.
140+ * @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined).
141+ * @note This function will be a noop while uVisor is in use.
142+ * @note This function will be a noop if the following conditions are met:
143+ * - The RTOS is present
144+ * - The processor turn off the Systick clock during sleep
145+ * - The target does not implement tickless mode
146+ *
147+ * The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the
148+ * system clock to the core is stopped until a reset or an interrupt occurs. This eliminates
149+ * dynamic power used by the processor, memory systems and buses. The processor, peripheral and
150+ * memory state are maintained, and the peripherals continue to work and can generate interrupts.
151+ *
152+ * The processor can be woken up by any internal peripheral interrupt or external pin interrupt.
153+ *
154+ * @note
155+ * The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
156+ * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
157+ * able to access the LocalFileSystem
158+ */
159+ static inline void sleep (void )
160+ {
161+ #if !(defined(FEATURE_UVISOR ) && defined(TARGET_UVISOR_SUPPORTED ))
162+ #if DEVICE_SLEEP
163+ #if (MBED_CONF_RTOS_PRESENT == 0 ) || (DEVICE_STCLK_OFF_DURING_SLEEP == 0 ) || defined(MBED_TICKLESS )
164+ sleep_manager_sleep_auto ();
165+ #endif /* (MBED_CONF_RTOS_PRESENT == 0) || (DEVICE_STCLK_OFF_DURING_SLEEP == 0) || defined(MBED_TICKLESS) */
166+ #endif /* DEVICE_SLEEP */
167+ #endif /* !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) */
168+ }
169+
170+ /** Send the microcontroller to deep sleep
171+ *
172+ * @note This function can be a noop if not implemented by the platform.
173+ * @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined)
174+ * @note This function will be a noop while uVisor is in use.
175+ *
176+ * This processor is setup ready for deep sleep, and sent to sleep. This mode
177+ * has the same sleep features as sleep plus it powers down peripherals and clocks. All state
178+ * is still maintained.
179+ *
180+ * The processor can only be woken up by an external interrupt on a pin or a watchdog timer.
181+ *
182+ * @note
183+ * The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
184+ * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
185+ * able to access the LocalFileSystem
186+ */
187+
188+ MBED_DEPRECATED_SINCE ("mbed-os-5.6" , "One entry point for an application, use sleep()" )
189+ static inline void deepsleep (void )
190+ {
191+ #if !(defined(FEATURE_UVISOR ) && defined(TARGET_UVISOR_SUPPORTED ))
192+ #if DEVICE_SLEEP
193+ sleep_manager_sleep_auto ();
194+ #endif /* DEVICE_SLEEP */
195+ #endif /* !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) */
196+ }
197+
198+ /** Resets the processor and most of the sub-system
199+ *
200+ * @note Does not affect the debug sub-system
201+ */
202+ static inline void system_reset (void )
203+ {
204+ NVIC_SystemReset ();
205+ }
206+
123207#ifdef __cplusplus
124208}
125209#endif
0 commit comments