Skip to content

Commit eae736e

Browse files
author
Amanda Butler
authored
Merge pull request #390 from bulislaw/sleep_template
Use template for sleep PG
2 parents 1594f3c + 3456cac commit eae736e

File tree

1 file changed

+29
-26
lines changed
  • docs/reference/contributing/target

1 file changed

+29
-26
lines changed
Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,49 @@
1-
### Sleep and deep sleep
1+
### Sleep
22

3-
Mbed OS defines two sleep modes for HAL:
3+
<span class="warnings">**Warning:** We are changing the Sleep HAL API in an upcoming release of Mbed OS. You can find details on how it may affect you in the [Implementing the Sleep API](#implementing-the-sleep-api) section.
44

5-
- Sleep.
6-
- Deep sleep.
5+
Implement the Sleep HAL API to enable your device to go into a low power state when you are not actively using it.
76

8-
Each target should document in their implementation:
7+
#### Assumptions
98

10-
- The target's mode description for each mode (how the target's mode maps to the Mbed OS sleep modes).
11-
- Wake-up latency for each mode.
12-
- Wake-up sources for each mode.
9+
##### Defined behavior
1310

14-
#### Sleep
11+
There are two power saving modes available in Mbed OS:
1512

16-
The core system clock is disabled, both the low and high precision clocks are enabled and RAM is retained.
13+
###### Sleep
1714

18-
1. Wake-up sources - any interrupt source can wake up the MCU.
19-
1. Latency - can wake up within 10 us.
15+
The core system clock is disabled. You can use both the low- and high-frequency clocks and retain RAM.
2016

21-
#### Deep sleep
17+
1. Wake-up sources - Any interrupt must wake up the MCU.
18+
1. Latency - The MCU must wake up within 10 us.
2219

23-
The core system clock is disabled. The low precision clocks are enabled, and RAM is retained.
20+
###### Deep sleep
2421

25-
1. Wake-up sources - RTC, low power ticker and GPIO can wake up the MCU.
26-
1. Latency - can wake up within 10 ms.
22+
The core system clock is disabled. You can only enable the low-frequency clocks and retain RAM.
2723

28-
The deep sleep latency (10 ms) is the higher limit of the boards we support. Most of targets have wake-up latency for deep sleep within a few microseconds, but often, reinitializing clocks and other configurations require additional time to restore previous state.
24+
1. Wake-up sources - RTC, low power ticker or GPIO must wake up the MCU.
25+
1. Latency - The MCU must wake up within 10 ms.
2926

3027
#### Implementing the Sleep API
3128

32-
There are two functions that the target needs to implement to support sleep, Their prototypes are in [hal/sleep_api.h](/docs/v5.7/mbed-os-api-doxy/sleep__api_8h_source.html):
29+
We are working on the new HAL Sleep API, which will replace the current version in an upcoming release of Mbed OS. You need to implement the Sleep API in both variants. First, you need to implement the current API. You can find it on master branch:
3330

34-
- Sleep.
31+
[![View code](https://www.mbed.com/embed/?type=library)](https://os-doc-builder.test.mbed.com/docs/v5.7/mbed-os-api-doxy/sleep__api_8h_source.html)
3532

36-
```c++
37-
void hal_sleep(void);
38-
```
33+
To make sure your platform is ready for the upcoming changes, you need to implement the future API and submit it in a separate pull request against `feature-hal-spec-sleep` branch. You can find the API and specification for the new Sleep API in the following header file:
34+
35+
[![View code](https://www.mbed.com/embed/?type=library)](https://os.mbed.com/docs/v5.7/feature-hal-spec-sleep-doxy/group__hal__sleep.html)
36+
37+
To enable sleep support in Mbed OS, you need to add the `SLEEP` label in the `device_has` option of the target's section in the `targets.json` file.
3938

40-
- Deep sleep.
39+
#### Testing
4140

42-
```c++
43-
void hal_deepsleep(void);
41+
The Mbed OS HAL provides a set of conformance tests for Sleep. You can use these tests to validate the correctness of your implementation. To run the Sleep HAL tests, use the following command:
42+
43+
```
44+
mbed test -t <toolchain> -m <target> -n "tests-mbed_hal-sleep*"
4445
```
4546

46-
To enable sleep support in Mbed OS, you need to add the `SLEEP` label in the `device_has` option of the target's section in the `targets.json` file.
47+
You can read more about the test cases:
48+
49+
[![View code](https://www.mbed.com/embed/?type=library)](https://os.mbed.com/docs/v5.7/feature-hal-spec-sleep-doxy/group__hal__sleep__tests.html)

0 commit comments

Comments
 (0)