Skip to content

Commit 215403e

Browse files
committed
diag build
1 parent 89a8ac8 commit 215403e

2 files changed

Lines changed: 50 additions & 1 deletion

File tree

variants/rak4631/RAK4631Board.cpp

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33

44
#include "RAK4631Board.h"
55

6+
#ifdef BOOT_DIAG
7+
// Diagnostic LED blink: N short blinks on green LED to indicate boot stage
8+
static void diag_blink(uint8_t count) {
9+
pinMode(PIN_LED1, OUTPUT);
10+
for (uint8_t i = 0; i < count; i++) {
11+
digitalWrite(PIN_LED1, HIGH);
12+
delay(100);
13+
digitalWrite(PIN_LED1, LOW);
14+
delay(150);
15+
}
16+
delay(300);
17+
}
18+
#else
19+
#define diag_blink(n) ((void)0)
20+
#endif
21+
622
#ifdef NRF52_POWER_MANAGEMENT
723
// Static configuration for power management
824
// Values set in variant.h defines
@@ -28,7 +44,16 @@ void RAK4631Board::initiateShutdown(uint8_t reason) {
2844
#endif // NRF52_POWER_MANAGEMENT
2945

3046
void RAK4631Board::begin() {
47+
diag_blink(1); // Stage 1: entering begin()
48+
49+
#ifdef DISABLE_DCDC
50+
NRF52Board::begin();
51+
#else
3152
NRF52BoardDCDC::begin();
53+
#endif
54+
55+
diag_blink(2); // Stage 2: board base init done
56+
3257
pinMode(PIN_VBAT_READ, INPUT);
3358
#ifdef PIN_USER_BTN
3459
pinMode(PIN_USER_BTN, INPUT_PULLUP);
@@ -44,12 +69,19 @@ void RAK4631Board::begin() {
4469

4570
Wire.begin();
4671

72+
diag_blink(3); // Stage 3: I2C done, about to configure LoRa power
73+
4774
pinMode(SX126X_POWER_EN, OUTPUT);
48-
#ifdef NRF52_POWER_MANAGEMENT
75+
#if defined(NRF52_POWER_MANAGEMENT) && !defined(DISABLE_BOOT_PROTECTION)
4976
// Boot voltage protection check (may not return if voltage too low)
5077
// We need to call this after we configure SX126X_POWER_EN as output but before we pull high
5178
checkBootVoltage(&power_config);
5279
#endif
80+
81+
diag_blink(4); // Stage 4: power check passed
82+
5383
digitalWrite(SX126X_POWER_EN, HIGH);
5484
delay(10); // give sx1262 some time to power up
85+
86+
diag_blink(5); // Stage 5: board.begin() complete
5587
}

variants/rak4631/platformio.ini

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,23 @@ build_src_filter = ${rak4631.build_src_filter}
4848
+<helpers/ui/SSD1306Display.cpp>
4949
+<../examples/simple_repeater>
5050

51+
; Diagnostic build: LED blinks at boot stages + boot protection disabled
52+
[env:RAK_4631_repeater_diag]
53+
extends = env:RAK_4631_repeater
54+
build_flags =
55+
${env:RAK_4631_repeater.build_flags}
56+
-D BOOT_DIAG
57+
-D DISABLE_BOOT_PROTECTION
58+
59+
; Diagnostic build: LED blinks + boot protection disabled + DC/DC disabled
60+
[env:RAK_4631_repeater_diag_no_dcdc]
61+
extends = env:RAK_4631_repeater
62+
build_flags =
63+
${env:RAK_4631_repeater.build_flags}
64+
-D BOOT_DIAG
65+
-D DISABLE_BOOT_PROTECTION
66+
-D DISABLE_DCDC
67+
5168
[env:RAK_4631_repeater_bridge_rs232_serial1]
5269
extends = rak4631
5370
build_flags =

0 commit comments

Comments
 (0)