Skip to content

Commit 206cc29

Browse files
author
Steven Cartmell
committed
Fix merge conflict mishap
1 parent fed5115 commit 206cc29

File tree

3 files changed

+84
-102
lines changed

3 files changed

+84
-102
lines changed

hal/mbed_sleep_manager.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
<<<<<<< HEAD
1817
#include "mbed_assert.h"
1918
#include "mbed_power_mgmt.h"
20-
=======
21-
#include "mbed_sleep.h"
22-
>>>>>>> Rename SLEEP_STATS_ENABLED to SLEEP_TRACING_ENABLED
2319
#include "mbed_critical.h"
2420
#include "sleep_api.h"
2521
#include "mbed_error.h"

platform/mbed_power_mgmt.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
122122
bool 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

platform/mbed_sleep.h

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -14,104 +14,6 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
<<<<<<< HEAD
18-
=======
19-
#ifndef MBED_SLEEP_H
20-
#define MBED_SLEEP_H
21-
22-
#include "sleep_api.h"
23-
#include "mbed_toolchain.h"
24-
#include <stdbool.h>
25-
26-
#ifdef __cplusplus
27-
extern "C" {
28-
#endif
29-
30-
/** Sleep manager API
31-
* The sleep manager provides API to automatically select sleep mode.
32-
*
33-
* There are two sleep modes:
34-
* - sleep
35-
* - deepsleep
36-
*
37-
* Use locking/unlocking deepsleep for drivers that depend on features that
38-
* are not allowed (=disabled) during the deepsleep. For instance, high frequency
39-
* clocks.
40-
*
41-
* Example:
42-
* @code
43-
*
44-
* void driver::handler()
45-
* {
46-
* if (_sensor.get_event()) {
47-
* // any event - we are finished, unlock the deepsleep
48-
* sleep_manager_unlock_deep_sleep();
49-
* _callback();
50-
* }
51-
* }
52-
*
53-
* int driver::measure(event_t event, callback_t& callback)
54-
* {
55-
* _callback = callback;
56-
* sleep_manager_lock_deep_sleep();
57-
* // start async transaction, we are waiting for an event
58-
* return _sensor.start(event, callback);
59-
* }
60-
* @endcode
61-
*/
62-
#ifdef MBED_SLEEP_TRACING_ENABLED
63-
64-
void sleep_tracker_lock(const char *const filename, int line);
65-
void sleep_tracker_unlock(const char *const filename, int line);
66-
67-
#define sleep_manager_lock_deep_sleep() \
68-
do \
69-
{ \
70-
sleep_manager_lock_deep_sleep_internal(); \
71-
sleep_tracker_lock(__FILE__, __LINE__); \
72-
} while (0);
73-
74-
#define sleep_manager_unlock_deep_sleep() \
75-
do \
76-
{ \
77-
sleep_manager_unlock_deep_sleep_internal(); \
78-
sleep_tracker_unlock(__FILE__, __LINE__); \
79-
} while (0);
80-
81-
#else
82-
83-
#define sleep_manager_lock_deep_sleep() \
84-
sleep_manager_lock_deep_sleep_internal()
85-
86-
#define sleep_manager_unlock_deep_sleep() \
87-
sleep_manager_lock_deep_sleep_internal()
88-
89-
#endif // MBED_SLEEP_TRACING_ENABLED
90-
91-
/** Lock the deep sleep mode
92-
*
93-
* This locks the automatic deep mode selection.
94-
* sleep_manager_sleep_auto() will ignore deepsleep mode if
95-
* this function is invoked at least once (the internal counter is non-zero)
96-
*
97-
* Use this locking mechanism for interrupt driven API that are
98-
* running in the background and deepsleep could affect their functionality
99-
*
100-
* The lock is a counter, can be locked up to USHRT_MAX
101-
* This function is IRQ and thread safe
102-
*/
103-
void sleep_manager_lock_deep_sleep_internal(void);
104-
105-
/** Unlock the deep sleep mode
106-
*
107-
* Use unlocking in pair with sleep_manager_lock_deep_sleep().
108-
*
109-
* The lock is a counter, should be equally unlocked as locked
110-
* This function is IRQ and thread safe
111-
*/
112-
void sleep_manager_unlock_deep_sleep_internal(void);
113-
>>>>>>> Rename SLEEP_PROFILING_ENABLED to MBED_SLEEP_STATS_ENABLED
114-
11517
#ifndef MBED_MBED_SLEEP_H
11618
#define MBED_MBED_SLEEP_H
11719

0 commit comments

Comments
 (0)