-
Notifications
You must be signed in to change notification settings - Fork 178
Porting guide: Add Sleep API pg page #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,52 @@ | ||
### Sleep and deep sleep | ||
## Sleep HAL API | ||
|
||
[A document explaining sleep and deep sleep] | ||
Mbed OS defines two sleep modes for HAL: | ||
|
||
- Sleep. | ||
- Deep sleep. | ||
|
||
Each target should document in their implementation: | ||
|
||
- The target's mode description for each mode (how the target's mode maps to the Mbed OS sleep modes). | ||
- Wake-up latency for each mode. | ||
- Wake-up sources for each mode. | ||
|
||
### Sleep | ||
|
||
The core system clock is disabled, both the low and high precision clocks are enabled and RAM is retained. | ||
|
||
1. Wake-up sources - any interrupt source can wake up the MCU. | ||
1. Latency - can wake up within 10 us. | ||
|
||
### Deep sleep | ||
|
||
The core system clock is disabled. The low precision clocks are enabled, and RAM is retained. | ||
|
||
1. Wake-up sources - RTC, low power ticker and GPIO can wake up the MCU. | ||
1. Latency - can wake up within 10 ms. | ||
|
||
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. | ||
|
||
### Implementing the Sleep API | ||
|
||
There are two functions that the target needs to implement to support sleep, Their prototypes are in [hal/sleep_api.h](/docs/v5.4/mbed-os-api-doxy/sleep__api_8h_source.html): | ||
|
||
- Sleep. | ||
|
||
```c++ | ||
void hal_sleep(void); | ||
``` | ||
|
||
- Deep sleep. | ||
|
||
```c++ | ||
void hal_deepsleep(void); | ||
``` | ||
|
||
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. | ||
|
||
### Testing | ||
|
||
The [sleep HAL API test suite]() validates: | ||
- Sleep wake-up sources. | ||
- Sleep wake-up latency. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Query: Where should this link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@0xc0170 Do you know where this should link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@c1728p9 Do you know where this should link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets remove the testing for now and add it in a seperate PR once there is a link.