Flying Silicon Sensor
deepSleep.cpp
Go to the documentation of this file.
1
23#ifdef ARDUINO_ARCH_NRF52
24
25#include <Arduino.h>
26#include "deepSleep.h"
27
28// TODO check how to put sensors in low power mode
29
34int setLowPowerMode(void) {
35 return (sd_power_mode_set(NRF_POWER_MODE_LOWPWR) == NRF_SUCCESS ) ? 1 : 0;
36}
37
42void enterDeepSleep(void) {
43
44 // sd_power_system_off() works only when no 'EasyDMA' transfer is active
45 // this is achieved by disabling all peripherals that might use it
46 NRF_UARTE0->ENABLE = UARTE_ENABLE_ENABLE_Disabled; // disable UART
47 NRF_SAADC ->ENABLE = (SAADC_ENABLE_ENABLE_Disabled << SAADC_ENABLE_ENABLE_Pos); // disable ADC
48 NRF_PWM0 ->ENABLE = (PWM_ENABLE_ENABLE_Disabled << PWM_ENABLE_ENABLE_Pos); // disable all pwm instances
49 NRF_PWM1 ->ENABLE = (PWM_ENABLE_ENABLE_Disabled << PWM_ENABLE_ENABLE_Pos);
50 NRF_PWM2 ->ENABLE = (PWM_ENABLE_ENABLE_Disabled << PWM_ENABLE_ENABLE_Pos);
51 NRF_TWIM1 ->ENABLE = (TWIM_ENABLE_ENABLE_Disabled << TWIM_ENABLE_ENABLE_Pos); // disable TWI Master
52 NRF_TWIS1 ->ENABLE = (TWIS_ENABLE_ENABLE_Disabled << TWIS_ENABLE_ENABLE_Pos); // disable TWI Slave
53
54 sd_power_system_off();
55 // should not be reached in deep sleep
56}
57
58#endif // ARDUINO_ARCH_NRF52
Support for nrf52 deep sleep / low power modes.
void enterDeepSleep(void)
int setLowPowerMode(void)