From da850dae5cf8f207303d74e21c175cc8e9a57b8c Mon Sep 17 00:00:00 2001 From: Andy Shinn Date: Sun, 30 Aug 2026 19:34:11 -0500 Subject: [PATCH 1/2] allow using AIN1 for VBAT on RAK19007 boards --- variants/rak4631/RAK4631Board.h | 8 ++++++-- variants/rak4631/variant.h | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/variants/rak4631/RAK4631Board.h b/variants/rak4631/RAK4631Board.h index 7e67165b19..fb13c21bea 100644 --- a/variants/rak4631/RAK4631Board.h +++ b/variants/rak4631/RAK4631Board.h @@ -5,8 +5,12 @@ #include // built-ins -#define PIN_VBAT_READ 5 -#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000) +#ifndef PIN_VBAT_READ + #define PIN_VBAT_READ 5 +#endif +#ifndef ADC_MULTIPLIER + #define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000) +#endif class RAK4631Board : public NRF52BoardDCDC { protected: diff --git a/variants/rak4631/variant.h b/variants/rak4631/variant.h index 38cc88685c..48bf3390eb 100644 --- a/variants/rak4631/variant.h +++ b/variants/rak4631/variant.h @@ -109,8 +109,12 @@ extern "C" #define PWRMGT_VOLTAGE_BOOTLOCK 3300 // Won't boot below this voltage (mV) // LPCOMP wake configuration (voltage recovery from SYSTEMOFF) // AIN3 = P0.05 = PIN_A0 / PIN_VBAT_READ -#define PWRMGT_LPCOMP_AIN 3 -#define PWRMGT_LPCOMP_REFSEL 4 // 5/8 VDD (~3.13-3.44V) +#ifndef PWRMGT_LPCOMP_AIN + #define PWRMGT_LPCOMP_AIN 3 +#endif +#ifndef PWRMGT_LPCOMP_REFSEL + #define PWRMGT_LPCOMP_REFSEL 4 // 5/8 VDD (~3.13-3.44V) +#endif // Other pins #define PIN_AREF (2) From adb60dfc661262e9ebc4b1f992efdb19e2171eb9 Mon Sep 17 00:00:00 2001 From: Andy Shinn Date: Sat, 5 Sep 2026 16:13:10 -0500 Subject: [PATCH 2/2] document that PWRMGT_LPCOMP_AIN default is overrideable The comment still described AIN3 as the pin, which is misleading now that the define is guarded. Say it is the default and note it must track PIN_VBAT_READ. Co-Authored-By: Claude Opus 5 (1M context) --- variants/rak4631/variant.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/variants/rak4631/variant.h b/variants/rak4631/variant.h index 48bf3390eb..701c736806 100644 --- a/variants/rak4631/variant.h +++ b/variants/rak4631/variant.h @@ -108,7 +108,9 @@ extern "C" // Set to 0 to disable boot protection #define PWRMGT_VOLTAGE_BOOTLOCK 3300 // Won't boot below this voltage (mV) // LPCOMP wake configuration (voltage recovery from SYSTEMOFF) -// AIN3 = P0.05 = PIN_A0 / PIN_VBAT_READ +// Defaults to AIN3 = P0.05 = PIN_A0 = the default PIN_VBAT_READ. Boards that +// sense VBAT elsewhere (e.g. a RAK19007 fed from J11 AIN1 = P0.03) can override +// this; keep it on the same pin as PIN_VBAT_READ. #ifndef PWRMGT_LPCOMP_AIN #define PWRMGT_LPCOMP_AIN 3 #endif