Skip to content

Commit 783eb4c

Browse files
committed
Sleep handbook improvements
* Rename sleep page to power management * General text improvements
1 parent c2d89c8 commit 783eb4c

File tree

2 files changed

+65
-61
lines changed

2 files changed

+65
-61
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
## Power management
2+
3+
### Sleep manager
4+
5+
There is only one sleep function in Mbed OS:
6+
7+
```c++
8+
void sleep();
9+
```
10+
11+
This function will invoke sleep manager, which will select the most appropriate sleep mode.
12+
13+
<span class="notes">**Note:** In most cases you won't need to call `sleep()` directly. Mbed OS will enter 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>
14+
15+
#### Sleep modes
16+
17+
There are two available sleep modes:
18+
19+
1. Sleep mode
20+
21+
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.
22+
23+
You can wake up the processor by any internal peripheral interrupt or external pin interrupt.
24+
25+
2. Deep sleep mode
26+
27+
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.
28+
29+
#### Sleep manager
30+
31+
The sleep manager provides an API and logic to control device sleep mode selection. While standard sleep shouldn'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 will enter normal sleep instead. This mechanism is mostly invisible for the user, but you should be aware that it may affect the power consumption of your hardware.
32+
33+
These Mbed OS drivers can lock the deep sleep:
34+
35+
- `Ticker`.
36+
- `Timeout`.
37+
- `Timer`.
38+
- `SPI`.
39+
- `I2C`.
40+
- `CAN`.
41+
- `SerialBase`.
42+
43+
### Idle loop
44+
45+
Idle loop is a background system thread, which scheduler will execute when there's no other threads ready to run. That may happen when your application is waiting for some event to happen. By default the idle loop will invoke sleep manager to enter a sleep mode. You can overwrite this behavior by providing a different handler as demonstrated below.
46+
47+
```c++
48+
void new_idle_loop()
49+
{
50+
// do nothing
51+
}
52+
53+
void main()
54+
{
55+
rtos_attach_idle_hook(&new_idle_loop);
56+
}
57+
```
58+
59+
### Function reference
60+
61+
[![View code](https://www.mbed.com/embed/?type=library)](http://os-doc-builder.test.mbed.com/docs/v5.7/mbed-os-api-doxy/mbed__sleep_8h_source.html)
62+
63+
#### Example
64+
65+
[![View code](https://www.mbed.com/embed/?url=https://os.mbed.com/teams/mbed_example/code/SleepManager_Example_1/)](https://os.mbed.com/teams/mbed_example/code/SleepManager_Example_1/file/e85412b4147e/main.cpp)

docs/reference/api/platform/SleepManager.md

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)