1
0
mirror of https://github.com/arduino-libraries/ArduinoLowPower.git synced 2025-04-19 11:42:14 +03:00

Merge pull request #44 from arduino-libraries/karlsoderby/add-docs

Add documentation
This commit is contained in:
Karl Söderby 2021-09-21 14:54:02 +02:00 committed by GitHub
commit 4396dff1a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 146 additions and 0 deletions

129
docs/api.md Normal file
View File

@ -0,0 +1,129 @@
# Ardunio Low Power
## Methods
### `LowPower.idle()`
#### Description
Puts the MCU in IDLE mode. This mode allows power optimization with the fastest wake-up time. The CPU is stopped. To further reduce power consumption, the user can manually disable the clocking of modules and clock sources.
#### Syntax
```
LowPower.idle();
LowPower.idle(milliseconds);
```
#### Parameters
milliseconds: the number of milliseconds to put the board in idle mode. If void the idle mode is used till a wakeup event.
### `LowPower.sleep()`
#### Description
Puts the MCU in sleep mode. The sleep mode allows power optimization with a slower wakeup time. Only the chosen peripherals are on.
#### Syntax
```
LowPower.sleep();
LowPower.sleep(milliseconds);
```
#### Parameters
milliseconds: the number of milliseconds to put the board in sleep mode. If void the sleep mode is used till a wakeup event.
### `LowPower.deepSleep()`
#### Description
Puts the MCU in deep sleep mode. The deep sleep mode allows power optimization with the slowest wake-up time. All but the RTC peripherals are stopped. The CPU can be wakeup only using RTC or wakeup on interrupt capable pins.
#### Syntax
```
LowPower.deepSleep();
LowPower.deepSleep(milliseconds);
```
#### Parameters
milliseconds: the number of milliseconds to put the board in deep sleep mode. If void the deep sleep mode is used till a wakeup event.
### `LowPower.attachInterruptWakeup()`
#### Description
Indicates the function to call and the conditions for a wakeup event.
#### Syntax
```
LowPower.attachInterruptWakeup(pin, callback, mode);
```
#### Parameters
pin: the pin used as external wakeup
callback: the function to call on wakeup
mode: the transitions to sense on the indicated pin. Can be one between:
- FALLING
- RISING
- CHANGE
### `LowPower.CompanionLowPowerCallback()`
#### Description
Indicates the function that the on-boad co-processor (Tian only) has to call just before going to sleep.
#### Syntax
LowPower.CompanionLowPowerCallback(callback);
#### Parameters
callback: the function to call before going to sleep
### `LowPower.companionSleep()`
#### Description
Puts the on-board co-processor (Tian only) in sleep mode
#### Syntax
LowPower.companionSleep();
#### Parameters
None
### `LowPower.companionWakeup()`
#### Description
Forces the on board co-processor (Tian only) wakeup from sleep mode.
#### Syntax
```
LowPower.companionWakeup();
```
#### Parameters
None

17
docs/readme.md Normal file
View File

@ -0,0 +1,17 @@
# Arduino Low Power Library
This library allows you to use the low power features of the SAMD21 MCU, which is used for all [MKR family boards](https://store.arduino.cc/collections/mkr-family) and the [Nano 33 IoT board](https://store.arduino.cc/products/arduino-nano-33-iot).
In these pages, the term companion chip is used. This term refers to a board co-processor like the MIPS processor on the [Arduino Tian](https://docs.arduino.cc/retired/boards/arduino-tian).
To use this library:
```
#include "<ArduinoLowPower.h>"
```
Examples:
- [ExternalWakeup](https://github.com/arduino-libraries/ArduinoLowPower/blob/master/examples/ExternalWakeup/ExternalWakeup.ino) : Demonstrates how to wake your board from an external source like a button.
- [TianStandby](https://github.com/arduino-libraries/ArduinoLowPower/blob/master/examples/TianStandby/TianStandby.ino) : Demonstrates how to put a Tian in standby
- [TimedWakeup](https://github.com/arduino-libraries/ArduinoLowPower/blob/master/examples/TimedWakeup/TimedWakeup.ino) : Demonstrates how to put in sleep your board for a certain amount of time