|
1 | 1 | # STM32LowPower
|
2 | 2 | Arduino library to support Low Power
|
| 3 | + |
| 4 | +## API |
| 5 | + |
| 6 | +* **`void begin()`**: configure the Low Power |
| 7 | + |
| 8 | +* **`void idle(uint32_t millis)`**: enter in idle mode |
| 9 | +**param** millis (optional): number of milliseconds before to exit the mode. At least 1000 ms. The RTC is used in alarm mode to wakeup the chip in millis milliseconds. |
| 10 | + |
| 11 | +* **`void sleep(uint32_t millis)`**: enter in sleep mode |
| 12 | +**param** millis (optional): number of milliseconds before to exit the mode. At least 1000 ms. The RTC is used in alarm mode to wakeup the chip in millis milliseconds. |
| 13 | + |
| 14 | +* **`void deepSleep(uint32_t millis)`**: enter in deepSleep mode |
| 15 | +**param** millis (optional): number of milliseconds before to exit the mode. At least 1000 ms. The RTC is used in alarm mode to wakeup the chip in millis milliseconds. |
| 16 | + |
| 17 | +* **`void shutdown(uint32_t millis)`**: enter in shutdown mode |
| 18 | +**param** millis (optional): number of milliseconds before to exit the mode. At least 1000 ms. The RTC is used in alarm mode to wakeup the board in millis milliseconds. |
| 19 | + |
| 20 | +* **`void attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode)`**: Enable GPIO pin in interrupt mode. If the pin is a wakeup pin, it is configured as wakeup source (see board documentation). |
| 21 | +**param** pin: pin number |
| 22 | +**param** callback: pointer to callback |
| 23 | +**param** mode: interrupt mode (HIGH, LOW, RISING, FALLING or CHANGE) |
| 24 | + |
| 25 | +* **`void enableWakeupFrom(HardwareSerial *serial, voidFuncPtrVoid callback)`**: enable a UART peripheral in low power mode. See board documentation for low power mode compatibility. |
| 26 | +**param** serial: pointer to a UART |
| 27 | +**param** callback: pointer to a callback to call when the board is waked up. |
| 28 | + |
| 29 | +* **`void enableWakeupFrom(TwoWire *wire, voidFuncPtrVoid callback)`**: |
| 30 | +enable an I2C peripheral in low power mode. See board documentation for low power mode compatibility. |
| 31 | +**param** wire: pointer to I2C |
| 32 | +**param** callback: pointer to a callback to call when the board is waked up. |
| 33 | + |
| 34 | +* **`void enableWakeupFrom(STM32RTC *rtc, voidFuncPtr callback)`** |
| 35 | +attach a callback to the RTC peripheral. |
| 36 | +**param** rtc: pointer to RTC |
| 37 | +**param** callback: pointer to a callback to call when the board is waked up. |
| 38 | + |
| 39 | +`Begin()` function must be called at least once before `idle()`, `sleep()`, `deepSleep()` or `shutdown()` functions. |
| 40 | + |
| 41 | +`attachInterruptWakeup()` or `enableWakeupFrom()` functions should be called before `idle()`, `sleep()`, `deepSleep()` or `shutdown()` functions. |
| 42 | + |
| 43 | +The board will restart when exit the deepSleep or shutdown mode. |
| 44 | + |
| 45 | +## Hardware state |
| 46 | + |
| 47 | +* **Idle mode**: low wake-up latency (µs range) (e.g. ARM WFI). Memories and |
| 48 | +voltage supplies are retained. Minimal power saving mainly on the core itself. |
| 49 | + |
| 50 | +* **sleep mode**: low wake-up latency (µs range) (e.g. ARM WFI), Memories and |
| 51 | +voltage supplies are retained. Minimal power saving mainly on the core itself but |
| 52 | +higher than idle mode. |
| 53 | + |
| 54 | +* **deep sleep mode**: medium latency (ms range), clocks are gated to reduced. Memories |
| 55 | +and voltage supplies are retained. If supported, Peripherals wake-up is possible (UART, I2C ...). |
| 56 | + |
| 57 | +* **shutdown mode**: high wake-up latency (posible hundereds of ms or second |
| 58 | +timeframe), voltage supplies are cut except always-on domain, memory content |
| 59 | +are lost and system basically reboots. |
| 60 | + |
| 61 | +## Source |
| 62 | + |
| 63 | +You can find the source files at |
| 64 | +https://github.com/stm32duino/STM32LowPower |
0 commit comments