Skip to content

Commit 74bdf1c

Browse files
author
Steven Cartmell
committed
Rename SLEEP_PROFILING_ENABLED to MBED_SLEEP_STATS_ENABLED
1 parent 0f6b73a commit 74bdf1c

File tree

2 files changed

+99
-2
lines changed

2 files changed

+99
-2
lines changed

hal/mbed_sleep_manager.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
// deep sleep locking counter. A target is allowed to deep sleep if counter == 0
2828
static uint16_t deep_sleep_lock = 0U;
2929

30-
#ifdef SLEEP_PROFILING_ENABLED
30+
#ifdef MBED_SLEEP_STATS_ENABLED
3131

3232
// Length of the identifier extracted from the driver name to store for logging.
3333
#define IDENTIFIER_WIDTH 7
@@ -128,7 +128,7 @@ void sleep_tracker_unlock(const char* const filename, int line)
128128
printf("\r\n");
129129
}
130130

131-
#endif // SLEEP_PROFILING_ENABLED
131+
#endif // MBED_SLEEP_STATS_ENABLED
132132

133133
void sleep_manager_lock_deep_sleep_internal(void)
134134
{

platform/mbed_sleep.h

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,103 @@
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_STATS_ENABLED
63+
64+
#define sleep_manager_lock_deep_sleep() \
65+
do \
66+
{ \
67+
sleep_manager_lock_deep_sleep_internal(); \
68+
sleep_tracker_lock(__FILE__, __LINE__); \
69+
} while (0);
70+
71+
#define sleep_manager_unlock_deep_sleep() \
72+
do \
73+
{ \
74+
sleep_manager_unlock_deep_sleep_internal(); \
75+
sleep_tracker_unlock(__FILE__, __LINE__); \
76+
} while (0);
77+
78+
void sleep_tracker_lock(const char *const filename, int line);
79+
void sleep_tracker_unlock(const char *const filename, int line);
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_STATS_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
17114

18115
#ifndef MBED_MBED_SLEEP_H
19116
#define MBED_MBED_SLEEP_H

0 commit comments

Comments
 (0)