23
23
#ifndef MBED_POWER_MGMT_H
24
24
#define MBED_POWER_MGMT_H
25
25
26
- #include "hal/ sleep_api.h"
26
+ #include "sleep_api.h"
27
27
#include "mbed_toolchain.h"
28
28
#include <stdbool.h>
29
29
@@ -63,6 +63,34 @@ extern "C" {
63
63
* }
64
64
* @endcode
65
65
*/
66
+ #ifdef SLEEP_PROFILING_ENABLED
67
+
68
+ #define sleep_manager_lock_deep_sleep () \
69
+ do \
70
+ { \
71
+ sleep_manager_lock_deep_sleep_internal(); \
72
+ sleep_tracker_lock(__FILE__, __LINE__); \
73
+ } while (0);
74
+
75
+ #define sleep_manager_unlock_deep_sleep () \
76
+ do \
77
+ { \
78
+ sleep_manager_unlock_deep_sleep_internal(); \
79
+ sleep_tracker_unlock(__FILE__, __LINE__); \
80
+ } while (0);
81
+
82
+ void sleep_tracker_lock (const char * const filename , int line );
83
+ void sleep_tracker_unlock (const char * const filename , int line );
84
+
85
+ #else
86
+
87
+ #define sleep_manager_lock_deep_sleep () \
88
+ sleep_manager_lock_deep_sleep_internal()
89
+
90
+ #define sleep_manager_unlock_deep_sleep () \
91
+ sleep_manager_lock_deep_sleep_internal()
92
+
93
+ #endif // SLEEP_PROFILING_ENABLED
66
94
67
95
/** Lock the deep sleep mode
68
96
*
@@ -76,7 +104,7 @@ extern "C" {
76
104
* The lock is a counter, can be locked up to USHRT_MAX
77
105
* This function is IRQ and thread safe
78
106
*/
79
- void sleep_manager_lock_deep_sleep (void );
107
+ void sleep_manager_lock_deep_sleep_internal (void );
80
108
81
109
/** Unlock the deep sleep mode
82
110
*
@@ -85,96 +113,13 @@ void sleep_manager_lock_deep_sleep(void);
85
113
* The lock is a counter, should be equally unlocked as locked
86
114
* This function is IRQ and thread safe
87
115
*/
88
- void sleep_manager_unlock_deep_sleep (void );
116
+ void sleep_manager_unlock_deep_sleep_internal (void );
89
117
90
118
/** Get the status of deep sleep allowance for a target
91
119
*
92
120
* @return true if a target can go to deepsleep, false otherwise
93
121
*/
94
122
bool sleep_manager_can_deep_sleep (void );
95
-
96
- /** Enter auto selected sleep mode. It chooses the sleep or deeepsleep modes based
97
- * on the deepsleep locking counter
98
- *
99
- * This function is IRQ and thread safe
100
- *
101
- * @note
102
- * If MBED_DEBUG is defined, only hal_sleep is allowed. This ensures the debugger
103
- * to be active for debug modes.
104
- *
105
- */
106
- void sleep_manager_sleep_auto (void );
107
-
108
- /** Send the microcontroller to sleep
109
- *
110
- * @note This function can be a noop if not implemented by the platform.
111
- * @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined).
112
- * @note This function will be a noop while uVisor is in use.
113
- * @note This function will be a noop if the following conditions are met:
114
- * - The RTOS is present
115
- * - The processor turn off the Systick clock during sleep
116
- * - The target does not implement tickless mode
117
- *
118
- * The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the
119
- * system clock to the core is stopped until a reset or an interrupt occurs. This eliminates
120
- * dynamic power used by the processor, memory systems and buses. The processor, peripheral and
121
- * memory state are maintained, and the peripherals continue to work and can generate interrupts.
122
- *
123
- * The processor can be woken up by any internal peripheral interrupt or external pin interrupt.
124
- *
125
- * @note
126
- * The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
127
- * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
128
- * able to access the LocalFileSystem
129
- */
130
- static inline void sleep (void )
131
- {
132
- #if !(defined(FEATURE_UVISOR ) && defined(TARGET_UVISOR_SUPPORTED ))
133
- #if DEVICE_SLEEP
134
- #if (MBED_CONF_RTOS_PRESENT == 0 ) || (DEVICE_STCLK_OFF_DURING_SLEEP == 0 ) || defined(MBED_TICKLESS )
135
- sleep_manager_sleep_auto ();
136
- #endif /* (MBED_CONF_RTOS_PRESENT == 0) || (DEVICE_STCLK_OFF_DURING_SLEEP == 0) || defined(MBED_TICKLESS) */
137
- #endif /* DEVICE_SLEEP */
138
- #endif /* !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) */
139
- }
140
-
141
- /** Send the microcontroller to deep sleep
142
- *
143
- * @note This function can be a noop if not implemented by the platform.
144
- * @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined)
145
- * @note This function will be a noop while uVisor is in use.
146
- *
147
- * This processor is setup ready for deep sleep, and sent to sleep. This mode
148
- * has the same sleep features as sleep plus it powers down peripherals and clocks. All state
149
- * is still maintained.
150
- *
151
- * The processor can only be woken up by an external interrupt on a pin or a watchdog timer.
152
- *
153
- * @note
154
- * The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
155
- * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
156
- * able to access the LocalFileSystem
157
- */
158
-
159
- MBED_DEPRECATED_SINCE ("mbed-os-5.6" , "One entry point for an application, use sleep()" )
160
- static inline void deepsleep (void )
161
- {
162
- #if !(defined(FEATURE_UVISOR ) && defined(TARGET_UVISOR_SUPPORTED ))
163
- #if DEVICE_SLEEP
164
- sleep_manager_sleep_auto ();
165
- #endif /* DEVICE_SLEEP */
166
- #endif /* !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) */
167
- }
168
-
169
- /** Resets the processor and most of the sub-system
170
- *
171
- * @note Does not affect the debug sub-system
172
- */
173
- static inline void system_reset (void )
174
- {
175
- NVIC_SystemReset ();
176
- }
177
-
178
123
#ifdef __cplusplus
179
124
}
180
125
#endif
0 commit comments