mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-03-30 19:15:49 +00:00
variants: XIAO NRF52: Support power-off via user button
Add the necessary code to properly power-off the Xiao + Wio companions. This way we can achieve around 15 microamps of power consumption in the off state. Signed-off-by: Frieder Schrempf <frieder@fris.de>
This commit is contained in:
@@ -46,6 +46,24 @@ public:
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
// set led on and wait for button release before poweroff
|
||||
digitalWrite(PIN_LED, LOW);
|
||||
#ifdef PIN_USER_BTN
|
||||
while(digitalRead(PIN_USER_BTN) == LOW);
|
||||
#endif
|
||||
digitalWrite(LED_GREEN, HIGH);
|
||||
digitalWrite(LED_BLUE, HIGH);
|
||||
digitalWrite(PIN_LED, HIGH);
|
||||
|
||||
#ifdef PIN_USER_BTN
|
||||
// configure button press to wake up when in powered off state
|
||||
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(g_ADigitalPinMap[PIN_USER_BTN]), NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
|
||||
#endif
|
||||
|
||||
sd_power_system_off();
|
||||
}
|
||||
|
||||
bool startOTAUpdate(const char* id, char reply[]) override;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user