Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions variants/rak3401/RAK3401Board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ void RAK3401Board::initiateShutdown(uint8_t reason) {
configureVoltageWake(power_config.lpcomp_ain_channel, power_config.lpcomp_refsel);
}

#ifdef PIN_USER_BTN_ANA
// Configure AIN1 button as GPIO SENSE wake source (active LOW).
// Wait for button release first β€” SENSE is level-triggered, so if the user is
// still holding the button when we arm SENSE, the chip wakes immediately.
while (digitalRead(PIN_USER_BTN_ANA) == LOW) delay(10);
delay(50); // debounce

uint32_t pin = (uint32_t)PIN_USER_BTN_ANA;
NRF_GPIO->PIN_CNF[pin] = (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)
| (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
| (GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos)
| (GPIO_PIN_CNF_SENSE_Low << GPIO_PIN_CNF_SENSE_Pos);
#endif

enterSystemOff(reason);
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions variants/rak3401/RAK3401Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class RAK3401Board : public NRF52BoardDCDC {
RAK3401Board() : NRF52Board("RAK3401_OTA") {}
void begin();

#ifdef NRF52_POWER_MANAGEMENT
void powerOff() override { initiateShutdown(SHUTDOWN_REASON_USER); }
#endif

#define BATTERY_SAMPLES 8

uint16_t getBattMilliVolts() override {
Expand Down