Skip to content

Commit 92af202

Browse files
committed
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 <[email protected]>
1 parent 7b7458e commit 92af202

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

variants/xiao_nrf52/XiaoNrf52Board.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,24 @@ class XiaoNrf52Board : public mesh::MainBoard {
4646
NVIC_SystemReset();
4747
}
4848

49+
void powerOff() override {
50+
// set led on and wait for button release before poweroff
51+
digitalWrite(PIN_LED, LOW);
52+
#ifdef PIN_USER_BTN
53+
while(digitalRead(PIN_USER_BTN) == LOW);
54+
#endif
55+
digitalWrite(LED_GREEN, HIGH);
56+
digitalWrite(LED_BLUE, HIGH);
57+
digitalWrite(PIN_LED, HIGH);
58+
59+
#ifdef PIN_USER_BTN
60+
// configure button press to wake up when in powered off state
61+
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(g_ADigitalPinMap[PIN_USER_BTN]), NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
62+
#endif
63+
64+
sd_power_system_off();
65+
}
66+
4967
bool startOTAUpdate(const char* id, char reply[]) override;
5068
};
5169

0 commit comments

Comments
 (0)