-
Notifications
You must be signed in to change notification settings - Fork 178
System reset docs #424
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
System reset docs #424
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
840a25d
Sleep handbook improvements
bulislaw 4ca3495
Copy edit PowerManagement.md
50d8931
Fix reported issues
bulislaw 7b43f83
Link idle loop doxygen
bulislaw 26f3bc8
Update doxygen link to point to Power Management group
bulislaw 629f1b5
Sleep handbook improvements
bulislaw 715fe0a
Add description of system_reset to power management page
bulislaw 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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
## Power management | ||
|
||
### Sleep | ||
|
||
There is only one sleep function in Mbed OS: | ||
|
||
```c++ | ||
void sleep(); | ||
``` | ||
|
||
This function invokes sleep manager, which selects the most appropriate sleep mode. | ||
|
||
<span class="notes">**Note:** In most cases, you don't need to call `sleep()` directly. Mbed OS enters sleep mode automatically any time the system is idle. That is when all your threads are in a waiting state, for example waiting for an event or a timeout.</span> | ||
|
||
#### Sleep modes | ||
|
||
There are two available sleep modes: | ||
|
||
1. Sleep mode | ||
|
||
The system clock to the core stops until a reset or an interrupt occurs. This eliminates dynamic power that the processor, memory systems and buses use. This mode maintains the processor, peripheral and memory state, and the peripherals continue to work and can generate interrupts. | ||
|
||
You can wake up the processor by any internal peripheral interrupt or external pin interrupt. | ||
|
||
2. Deep sleep mode | ||
|
||
This mode is similar to sleep but saves more power and has a longer wakeup time. It saves additional power by turning off the high-speed clocks. Because of this, you can only enter this mode when peripherals relying on high-speed clocks are not in use. Peripherals that do not rely on high-speed clocks include the LowPowerTicker, RTC and InterruptIn APIs. This mode maintains all state. | ||
|
||
#### Sleep manager | ||
|
||
The sleep manager provides an API and logic to control device sleep mode selection. Although standard sleep doesn't affect application execution, deep sleep might introduce some additional power savings that can affect the application, for instance high-speed clock-dependent drivers. To ensure correct operation of your application, sleep manager may disable deep sleep, in which case your board enters normal sleep, instead. This mechanism is mostly invisible to the user, but you should be aware that it may affect the power consumption of your hardware. | ||
|
||
These Mbed OS drivers can lock the deep sleep: | ||
|
||
- `Ticker`. | ||
- `Timeout`. | ||
- `Timer`. | ||
- `SPI`. | ||
- `I2C`. | ||
- `CAN`. | ||
- `SerialBase`. | ||
|
||
#### Example | ||
|
||
[](https://os.mbed.com/teams/mbed_example/code/SleepManager_Example_1/file/e85412b4147e/main.cpp) | ||
|
||
### System reset | ||
|
||
Mbed OS provides a standardized call to power cycle the system: | ||
|
||
```c++ | ||
void system_reset(); | ||
``` | ||
|
||
After the call the processor and most components will reset, but it will not affect the debug subsystem. | ||
|
||
### Function reference | ||
|
||
[](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/group__platform__power__mgmt.html) | ||
|
||
### Idle loop | ||
|
||
Idle loop is a background system thread, which scheduler executes when no other threads are ready to run. That may happen when your application is waiting for an event to happen. By default, the idle loop invokes sleep manager to enter a sleep mode. You can overwrite this behavior by providing a different handler: | ||
|
||
```c++ | ||
void new_idle_loop() | ||
{ | ||
// do nothing | ||
} | ||
|
||
void main() | ||
{ | ||
rtos_attach_idle_hook(&new_idle_loop); | ||
} | ||
``` | ||
|
||
#### Function reference | ||
|
||
[](https://os.mbed.com/docs/v5.7/mbed-os-api-doxy/group__rtos___idle.html) | ||
|
||
### Example | ||
|
||
[](https://os.mbed.com/teams/mbed_example/code/SleepManager_Example_1/file/e85412b4147e/main.cpp) |
This file was deleted.
Oops, something went wrong.
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.
Should system reset be the same level as sleep, or is it part of sleep? If the former, it feels out of place to me that it would be between the sleep description and class reference.
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.
It's at the same level and the function reference will point to the shared doxygen group "Power management" once doxygen is regenerated.