mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
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:
parent
93d1560d14
commit
e3bb225efb
12 changed files with 40 additions and 56 deletions
|
|
@ -19,16 +19,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
|
|||
}
|
||||
|
||||
void RAKWismeshTagBoard::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;
|
||||
}
|
||||
NRF52BoardDCDC::begin();
|
||||
|
||||
pinMode(PIN_VBAT_READ, INPUT);
|
||||
pinMode(PIN_USER_BTN, INPUT_PULLUP);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#define PIN_VBAT_READ 5
|
||||
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
|
||||
|
||||
class RAKWismeshTagBoard : public NRF52Board {
|
||||
class RAKWismeshTagBoard : public NRF52BoardDCDC {
|
||||
public:
|
||||
void begin();
|
||||
|
||||
|
|
|
|||
|
|
@ -5,18 +5,9 @@
|
|||
#include <bluefruit.h>
|
||||
|
||||
void T1000eBoard::begin() {
|
||||
NRF52Board::begin();
|
||||
NRF52BoardDCDC::begin();
|
||||
btn_prev_state = HIGH;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
#ifdef BUTTON_PIN
|
||||
pinMode(BATTERY_PIN, INPUT);
|
||||
pinMode(BUTTON_PIN, INPUT);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include <Arduino.h>
|
||||
#include <helpers/NRF52Board.h>
|
||||
|
||||
class T1000eBoard : public NRF52Board {
|
||||
class T1000eBoard : public NRF52BoardDCDC {
|
||||
protected:
|
||||
uint8_t btn_prev_state;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,18 +19,9 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
|
|||
}
|
||||
|
||||
void WioTrackerL1Board::begin() {
|
||||
NRF52Board::begin();
|
||||
NRF52BoardDCDC::begin();
|
||||
btn_prev_state = HIGH;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
pinMode(PIN_VBAT_READ, INPUT); // VBAT ADC input
|
||||
// Set all button pins to INPUT_PULLUP
|
||||
pinMode(PIN_BUTTON1, INPUT_PULLUP);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include <Arduino.h>
|
||||
#include <helpers/NRF52Board.h>
|
||||
|
||||
class WioTrackerL1Board : public NRF52Board {
|
||||
class WioTrackerL1Board : public NRF52BoardDCDC {
|
||||
protected:
|
||||
uint8_t btn_prev_state;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,16 +21,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
|
|||
}
|
||||
|
||||
void WioWM1110Board::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;
|
||||
}
|
||||
NRF52BoardDCDC::begin();
|
||||
|
||||
pinMode(BATTERY_PIN, INPUT);
|
||||
pinMode(LED_GREEN, OUTPUT);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#endif
|
||||
#define Serial Serial1
|
||||
|
||||
class WioWM1110Board : public NRF52Board {
|
||||
class WioWM1110Board : public NRF52BoardDCDC {
|
||||
public:
|
||||
void begin();
|
||||
|
||||
|
|
|
|||
|
|
@ -21,16 +21,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
|
|||
}
|
||||
|
||||
void XiaoNrf52Board::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;
|
||||
}
|
||||
NRF52BoardDCDC::begin();
|
||||
|
||||
pinMode(PIN_VBAT, INPUT);
|
||||
pinMode(VBAT_ENABLE, OUTPUT);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#ifdef XIAO_NRF52
|
||||
|
||||
class XiaoNrf52Board : public NRF52Board {
|
||||
class XiaoNrf52Board : public NRF52BoardDCDC {
|
||||
public:
|
||||
void begin();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue