Skip to content

Commit 804e9b0

Browse files
Bartek Szatkowskibulislaw
authored andcommitted
Add Sleep API pg page
1 parent c445ee1 commit 804e9b0

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

docs/contributing/sleep_deep_sleep.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,52 @@
1-
### Sleep and deep sleep
1+
# Sleep HAL API
22

3-
[A document explaining sleep and deep sleep]
3+
mbed OS defines two sleep modes for HAL:
4+
5+
- Sleep
6+
- Deep sleep
7+
8+
Each target should document in their implementation:
9+
10+
- The target's mode description for each mode (how target's mode map to mbed OS sleep modes)
11+
- Wake-up latency for each mode
12+
- Wake-up sources for each mode
13+
14+
## Sleep
15+
16+
The core system clock is disabled, both the low and high precision clocks are enabled, RAM is retained.
17+
18+
1. Wake-up sources - any interrupt source should be able to wake-up the MCU
19+
1. Latency - should wake-up within 10 us
20+
21+
## Deep sleep
22+
23+
The core system clock is disabled. The low precision clocks are enabled, RAM is retained.
24+
25+
1. Wake-up sources - RTC, low power ticker or GPIO should be able to wake-up the MCU
26+
1. Latency - should wake-up within 10 ms
27+
28+
The deep sleep latency (10 ms) was chosen as the higher limit of the boards we support. Most of targets have wake-up latency for deep sleep within few microseconds, but often additional time is needed for reinitializing clocks or other configuration necessary to restore previous state.
29+
30+
## Implementing the Sleep API
31+
32+
There are two functions that target needs to implement to support sleep, their prototypes are located in [hal/sleep_api.h]():
33+
34+
- Sleep
35+
36+
```c++
37+
void hal_sleep(void);
38+
```
39+
40+
- Deep sleep
41+
42+
```c++
43+
void hal_deepsleep(void);
44+
```
45+
46+
To enable sleep support in mbed OS `SLEEP` label needs to be added in `device_has` option of target's section in `targets.json` file.
47+
48+
## Testing
49+
50+
The [sleep HAL API test suite]() validates:
51+
- Sleep wake-up sources
52+
- Sleep wake-up latency

0 commit comments

Comments
 (0)