This library allows the use of the low power features of the EFR32 MCU. This means your battery powered projects will have a longer battery life.
Read more about the EFR32 energy modes here: https://www.silabs.com/mcu/32-bit-microcontrollers/efm32-energy-modes
When in deep sleep the devices will turn off most of their peripherals - including their debug/flashing interfaces.
This means that when the device is deep sleeping it's not possible to flash or erase them.
On Silicon Labs boards the board controller will take care of this by issuing a reset after the first failed communication attempt.
On the Nano Matter an escape method is utilized when using this library to force and hold the device in an awake state before any user code can run.
To enter this escape mode on your Nano Matter do the following:
- Press and hold the user button
- Press and release the reset button
- Wait for the onboard LED to be continuously lit
- Release the user button
- Your board will now stay awake and can be reflashed
Requests EM1/EM2 mode for the specified amount of time. The device is not guaranteed to be in the requested energy mode during for the entire specified period - as the radio stacks and other peripherals can and will periodically wake the device to perform their necessary tasks - then put the device back to sleep.
LowPower.idle(milliseconds);
milliseconds: the number of milliseconds to put the board in idle mode.
Requests EM1/EM2 mode for the specified amount of time. The device is not guaranteed to be in the requested energy mode during for the entire specified period - as the radio stacks and other peripherals can and will periodically wake the device to perform their necessary tasks - then put the device back to sleep.
LowPower.sleep(milliseconds);
milliseconds: the number of milliseconds to put the board in sleep mode.
Puts the MCU in deep sleep mode. The deep sleep mode allows the device to an enter extremely low power consumption state (EM4). Every peripheral is stopped except for a few - like the back-up RTC and back-up RAM. The CPU can only wake up using the RTC or a pulse on a wake-up interrupt capable pin. In this mode the CPU is completely halted and RAM contents are lost. Upon waking up the device starts from the beginning of the sketch.
LowPower.deepSleep();
LowPower.deepSleep(milliseconds);
milliseconds: the number of milliseconds to put the board in deep sleep mode. If void the deep sleep mode is used till a wake-up event.
Configures whether GPIO states should be held while the MCU is in deep sleep.
When enabled, pins keep their state during deep sleep but return to their reset state after wake-up.
Use LowPower.deepSleepRetainPin() to keep selected pins in a configured state after wake-up.
If pin retention is configured with LowPower.deepSleepRetainPin(), it takes precedence over LowPower.deepSleepHoldPins() and this setting is ignored.
LowPower.deepSleepHoldPins(hold);
hold: true to hold GPIO states during deep sleep, false to disable GPIO hold.
Configures an output pin to keep the specified state during deep sleep and after wake-up.
Only OUTPUT pins with a LOW or HIGH state can be retained.
Up to 3 pins can be configured for retention.
The function returns true if the pin retention configuration was stored successfully and false otherwise.
Pin retention takes precedence over LowPower.deepSleepHoldPins(), so the GPIO hold setting is ignored once a retained pin is configured.
If the same pin is configured as a deep sleep wake-up pin with LowPower.attachInterruptWakeup(), the wake-up pin configuration takes precedence while entering deep sleep and the retained output state won't take effect while the MCU is sleeping.
The deep sleep escape pin always takes precedence over pin retention and is configured as INPUT_PULLUP after wake-up before the sketch starts.
Using this feature reserves the last 10 writeable addresses of the Back-up RAM (40 bytes).
While pin retention is enabled, writes to those addresses with LowPower.deepSleepMemoryWrite() are ignored and reads with LowPower.deepSleepMemoryRead() return 0.
LowPower.deepSleepRetainPin(pin, mode, status);
pin: the pin to retain during and after deep sleep.
mode: the retained pin mode. Only OUTPUT is supported.
status: the retained pin state. Can be LOW or HIGH.
Clears the stored deep sleep pin retention configuration.
After calling this function, subsequent deep sleep calls won't retain pins after wake-up unless LowPower.deepSleepRetainPin() is called again.
LowPower.deepSleepClearRetainedPins();
None
Attaches a function to call on wake-up and sets the deep sleep wake-up pins.
LowPower.attachInterruptWakeup(pin, callback, mode);
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
Returns 'true' if the MCU has woken up after a deep sleep.
Returns 'false' if the MCU was reset by another cause.
LowPower.wokeUpFromDeepSleep();
None
Writes 4 bytes (uint32_t) to the deep sleep memory (Back-up RAM) to the specified address.
Contents of the deep sleep memory are retained during deep sleep.
Using LowPower.deepSleepRetainPin() reserves the last 10 writeable addresses of the Back-up RAM (40 bytes).
While pin retention is enabled, writes to those addresses are ignored.
LowPower.deepSleepMemoryWrite(address, data);
address: address to write
data: data to write
Reads 4 bytes (uint32_t) from the deep sleep memory (Back-up RAM) from the specified address.
Using LowPower.deepSleepRetainPin() reserves the last 10 writeable addresses of the Back-up RAM (40 bytes).
While pin retention is enabled, reads from those addresses return 0.
uint32_t data_read = LowPower.deepSleepMemoryRead(address);
None
Reads the size of the deep sleep memory (in writeable addresses). To get the size in bytes multiply the return value by 4.
uint32_t deep_sleep_memory_size = LowPower.deepSleepMemorySize();
None