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
3046void 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}
0 commit comments