Repeater, room server, sensor, companion: fix nRF52 sleep wake-up loop and keep DC/DC enabled after BLE init

This commit is contained in:
tth committed 2026-11-24 19:38:41 +01:00
1 parent be46cfa5fb
commit 86e2a16703
3 files changed
+40 -4

No files matched your search

+24 -4
View File
@@ -288,10 +288,7 @@ void NRF52Board::pwrmgtWakeArmVbus() {
}
#endif
void NRF52BoardDCDC::begin() {
NRF52Board::begin();
// Enable DC/DC converter for improved power efficiency
static void enableNrf52Dcdc() {
uint8_t sd_enabled = 0;
sd_softdevice_is_enabled(&sd_enabled);
if (sd_enabled) {
@@ -301,6 +298,21 @@ void NRF52BoardDCDC::begin() {
}
}
void NRF52BoardDCDC::begin() {
NRF52Board::begin();
// Enable DC/DC converter for improved power efficiency
enableNrf52Dcdc();
}
void NRF52BoardDCDC::onBootComplete() {
NRF52Board::onBootComplete();
// SoftDevice (Bluefruit.begin()) starts after board.begin() and defaults
// NRF_POWER to LDO mode; re-enable DC/DC once SoftDevice owns NRF_POWER.
enableNrf52Dcdc();
}
bool NRF52Board::isExternalPowered() {
// Check if SoftDevice is enabled before using its API
uint8_t sd_enabled = 0;
@@ -324,6 +336,14 @@ void NRF52Board::sleep(uint32_t secs) {
NVIC_ClearPendingIRQ(FPU_IRQn);
#endif
// Clear pending CRYPTOCELL interrupt to avoid WFE/sd_app_evt_wait() insomnia.
// Adafruit_nRFCrypto polls CC310 with CRYPTOCELL_IRQn disabled in NVIC, so
// completed crypto/TRNG calls leave it pending (same workaround as Adafruit
// core wiring.c / port_cmsis_systick.c).
#ifdef NRF_CRYPTOCELL
NVIC_ClearPendingIRQ(CRYPTOCELL_IRQn);
#endif
// On nRF52, we use event-driven sleep instead of timed sleep
// The 'secs' parameter is ignored - we wake on any interrupt
uint8_t sd_enabled = 0;
+1
View File
@@ -93,5 +93,6 @@ class NRF52BoardDCDC : virtual public NRF52Board {
public:
NRF52BoardDCDC() {}
virtual void begin() override;
virtual void onBootComplete() override;
};
#endif