Initialize DC/DC on nine circuit-verified nRF52 boards
This commit is contained in:
1 parent
364e3cabd5
commit
dcabcb8cb2
11 files changed
+97
-18
No files matched your search
@@ -11,16 +11,41 @@ from cpp_source import body
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
# Each target has manufacturer/board-designer circuit evidence recorded in
|
||||
# docs/power_saving_diagnostics.md. Do not infer eligibility from inheritance.
|
||||
VERIFIED_BOARDS = (
|
||||
('heltec_t1/T1Board.cpp', 'T1Board', True),
|
||||
('heltec_mesh_solar/MeshSolarBoard.cpp', 'MeshSolarBoard', False),
|
||||
('heltec_tower_v2/HeltecTowerV2Board.cpp', 'HeltecTowerV2Board', True),
|
||||
('mesh_pocket/MeshPocket.cpp', 'HeltecMeshPocket', False),
|
||||
('lilygo_techo/TechoBoard.cpp', 'TechoBoard', False),
|
||||
('ikoka_handheld_nrf/IkokaNrf52Board.cpp', 'IkokaNrf52Board', False),
|
||||
('ikoka_nano_nrf/IkokaNanoNRFBoard.cpp', 'IkokaNanoNRFBoard', False),
|
||||
('ikoka_stick_nrf/IkokaStickNRFBoard.cpp', 'IkokaStickNRFBoard', False),
|
||||
('minewsemi_me25ls01/MinewsemiME25LS01Board.cpp', 'MinewsemiME25LS01Board', False),
|
||||
)
|
||||
|
||||
HARNESS = r'''
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#define NRF52_POWER_MANAGEMENT 1
|
||||
#define PIN_BOARD_SDA 1
|
||||
#define PIN_BOARD_SCL 2
|
||||
#define PIN_USER_BTN 9
|
||||
#define PIN_USER_BTN_ANA 31
|
||||
#define PIN_WIRE_SDA 1
|
||||
#define PIN_WIRE_SCL 2
|
||||
#define P_LORA_TX_LED 28
|
||||
#define BUTTON_PIN 9
|
||||
#define DISPLAY_CLASS TestDisplay
|
||||
#define DISPLAY_ROTATION 0
|
||||
constexpr int INPUT = 0, OUTPUT = 1, INPUT_PULLUP = 2, LOW = 0, HIGH = 1;
|
||||
constexpr int PIN_VBAT_READ = 5, WB_IO2 = 34, SX126X_POWER_EN = 37;
|
||||
constexpr int PIN_VBAT = 5, VBAT_ENABLE = 14, PIN_BAT_CTL = 15, LED_PIN = 28;
|
||||
constexpr int PIN_GPS_EN = 10, PIN_GPS_RESET = 11, PIN_GPS_STANDBY = 12;
|
||||
constexpr int PIN_SENSOR_EN = 13, PIN_BUZZER = 16;
|
||||
constexpr int PIN_BUZZER_VOLTAGE_MULTIPLIER_1 = 17, PIN_BUZZER_VOLTAGE_MULTIPLIER_2 = 18;
|
||||
constexpr int LED_STATE_ON = 1, PIN_GPS_EN_ACTIVE = 1, PIN_SENSOR_EN_ACTIVE = 1;
|
||||
constexpr int GPS_RESET_MODE = 0;
|
||||
constexpr int NRF_POWER_DCDC_ENABLE = 1, NRF_POWER_DCDC_DISABLE = 0;
|
||||
static unsigned base_calls, sdk_calls, voltage_checks;
|
||||
static uint8_t softdevice;
|
||||
@@ -33,19 +58,33 @@ void sd_power_dcdc_mode_set(int mode) {
|
||||
assert(base_calls == 1 && softdevice && mode == NRF_POWER_DCDC_ENABLE);
|
||||
++sdk_calls;
|
||||
}
|
||||
void pinMode(int, int) {}
|
||||
void digitalWrite(int, int) {}
|
||||
void requireDcdc() {
|
||||
assert(base_calls == 1);
|
||||
assert(softdevice ? sdk_calls == 1 : power.DCDCEN == 1);
|
||||
}
|
||||
void pinMode(int, int) { requireDcdc(); }
|
||||
void digitalWrite(int, int) { requireDcdc(); }
|
||||
void delay(unsigned) {}
|
||||
struct Bus { void setPins(int, int) {} void begin() {} } Wire;
|
||||
void meshSolarStart() { requireDcdc(); }
|
||||
struct Bus {
|
||||
void setPins(int, int) { requireDcdc(); }
|
||||
void begin() { requireDcdc(); }
|
||||
} Wire;
|
||||
struct Uart { void begin(unsigned) { requireDcdc(); } } Serial;
|
||||
struct Peripheral {
|
||||
void begin() { requireDcdc(); }
|
||||
void init() { requireDcdc(); }
|
||||
};
|
||||
struct Config {} power_config;
|
||||
struct NRF52Board { void begin() { ++base_calls; } };
|
||||
struct NRF52BoardDCDC : NRF52Board { void begin(); };
|
||||
struct @BOARD@ : NRF52BoardDCDC {
|
||||
Peripheral periph_power, loRaFEMControl;
|
||||
unsigned btn_prev_state = 0;
|
||||
void begin();
|
||||
void checkBootVoltage(const Config*) {
|
||||
++voltage_checks;
|
||||
assert(base_calls == 1);
|
||||
assert(softdevice ? sdk_calls == 1 : power.DCDCEN == 1);
|
||||
requireDcdc();
|
||||
}
|
||||
};
|
||||
@METHODS@
|
||||
@@ -54,7 +93,7 @@ int main() {
|
||||
power.DCDCEN = base_calls = sdk_calls = voltage_checks = 0;
|
||||
@BOARD@ board;
|
||||
board.begin();
|
||||
assert(base_calls == 1 && voltage_checks == 1);
|
||||
assert(base_calls == 1 && voltage_checks == @VOLTAGE_CHECKS@);
|
||||
assert(sdk_calls == softdevice);
|
||||
assert(power.DCDCEN == (softdevice ? 0U : 1U));
|
||||
}
|
||||
@@ -63,11 +102,15 @@ int main() {
|
||||
|
||||
|
||||
class Nrf52BoardRegulatorTests(unittest.TestCase):
|
||||
def run_startup(self, filename, board, flags=()):
|
||||
def run_startup(self, filename, board, flags=(), power_management=True,
|
||||
has_voltage_check=True):
|
||||
methods = body((ROOT / 'src/helpers/NRF52Board.cpp').read_text(),
|
||||
'void NRF52BoardDCDC::begin()')
|
||||
methods += body((ROOT / filename).read_text(), f'void {board}::begin()')
|
||||
source = HARNESS.replace('@BOARD@', board).replace('@METHODS@', methods)
|
||||
source = source.replace('@VOLTAGE_CHECKS@', str(int(power_management and has_voltage_check)))
|
||||
if power_management:
|
||||
flags = (*flags, '-DNRF52_POWER_MANAGEMENT=1')
|
||||
with tempfile.TemporaryDirectory(prefix='meshcore-board-regulator-') as tmp:
|
||||
cpp, binary = Path(tmp) / 'test.cpp', Path(tmp) / 'test'
|
||||
cpp.write_text(source, encoding='ascii')
|
||||
@@ -86,6 +129,14 @@ class Nrf52BoardRegulatorTests(unittest.TestCase):
|
||||
with self.subTest(flags=flags):
|
||||
self.run_startup('variants/rak4631/RAK4631Board.cpp', 'RAK4631Board', flags)
|
||||
|
||||
def test_verified_boards_initialize_dcdc_before_peripherals(self):
|
||||
for filename, board, has_voltage_check in VERIFIED_BOARDS:
|
||||
for power_management in (False, True):
|
||||
with self.subTest(board=board, power_management=power_management):
|
||||
self.run_startup('variants/' + filename, board,
|
||||
power_management=power_management,
|
||||
has_voltage_check=has_voltage_check)
|
||||
|
||||
def test_rak_companion_profiles_do_not_force_ldo(self):
|
||||
config = configparser.ConfigParser(interpolation=None)
|
||||
config.read(ROOT / 'variants/rak4631/platformio.ini')
|
||||
|
||||
Reference in new issue
Block a user