Deduplicate DC/DC regulator enable for NRF52 boards

Some NRF52 boards are able to use the internal power-efficient DC/DC
regulator. Add a new class that can be inherited by board classes to
enable this feature and reduce the power consumption.

Signed-off-by: Frieder Schrempf <frieder@fris.de>
This commit is contained in:
Frieder Schrempf 2025-12-09 17:05:33 +01:00
parent 93d1560d14
commit e3bb225efb
No known key found for this signature in database
GPG key ID: E7DD51F45F833802
12 changed files with 40 additions and 56 deletions

View file

@ -1,6 +1,23 @@
#if defined(NRF52_PLATFORM)
#include "NRF52Board.h"
void NRF52Board::begin() {
startup_reason = BD_STARTUP_NORMAL;
}
void NRF52BoardDCDC::begin() {
NRF52Board::begin();
// Enable DC/DC converter for improved power efficiency
uint8_t sd_enabled = 0;
sd_softdevice_is_enabled(&sd_enabled);
if (sd_enabled) {
sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
} else {
NRF_POWER->DCDCEN = 1;
}
}
// Temperature from NRF52 MCU
float NRF52Board::getMCUTemperature() {
NRF_TEMP->TASKS_START = 1; // Start temperature measurement

View file

@ -10,9 +10,21 @@ protected:
uint8_t startup_reason;
public:
virtual void begin() { startup_reason = BD_STARTUP_NORMAL; }
virtual void begin();
virtual uint8_t getStartupReason() const override { return startup_reason; }
float getMCUTemperature() override;
virtual void reboot() override { NVIC_SystemReset(); }
};
/*
* The NRF52 has an internal DC/DC regulator that allows increased efficiency
* compared to the LDO regulator. For being able to use it, the module/board
* needs to have the required inductors and and capacitors populated. If the
* hardware requirements are met, this subclass can be used to enable the DC/DC
* regulator.
*/
class NRF52BoardDCDC : virtual public NRF52Board {
public:
virtual void begin() override;
};
#endif