Skip to content

Commit 8560df5

Browse files
committed
Add SleepManager page
Add a page for the SleepManager API. This contains general sleep information, along with the sleep manager API and an example which uses it.
1 parent 9e04c88 commit 8560df5

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## Sleep manager
2+
3+
There is only one sleep function in Mbed OS 5.6:
4+
5+
```c++
6+
void sleep();
7+
```
8+
9+
This function invokes sleep manager, which we introduce below.
10+
11+
The idle loop invokes sleep manager by default. You can overwrite this default behavior by attaching a different idle hook function pointer.
12+
13+
```c++
14+
void new_idle_loop()
15+
{
16+
// do nothing
17+
}
18+
19+
void main()
20+
{
21+
rtos_attach_idle_hook(&new_idle_loop);
22+
}
23+
```
24+
25+
### Sleep modes
26+
27+
There are two available sleep modes:
28+
29+
1. Sleep mode
30+
31+
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.
32+
33+
You can wake up the processor by any internal peripheral interrupt or external pin interrupt.
34+
35+
2. Deep sleep mode
36+
37+
This mode is similar to sleep but saves more power and has a longer wakeup time. It saves 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 lp ticker, RTC and external interrupt on a pin. This mode maintains all state.
38+
39+
### Sleep manager
40+
41+
The sleep manager provides an API to control sleep modes. Deep sleep might introduce some power savings that can affect an application, for instance high speed clock dependent drivers.
42+
43+
These Mbed OS drivers contain locking deep sleep:
44+
45+
- `Ticker`.
46+
- `Timeout`.
47+
- `Timer`.
48+
- `SPI`.
49+
- `I2C`.
50+
- `CAN`.
51+
- `SerialBase`.
52+
53+
### Sleep manager function reference
54+
55+
[https://github.com/ARMmbed/mbed-os/blob/master/platform/mbed_sleep.h](https://github.com/ARMmbed/mbed-os/blob/master/platform/mbed_sleep.h)
56+
57+
### Example
58+
59+
[![View code](https://os.mbed.com/users/c1728p9/code/SleepManager_Example_1/)](https://os.mbed.com/users/c1728p9/code/SleepManager_Example_1/file/e85412b4147e/main.cpp)

0 commit comments

Comments
 (0)