Allow NRF52 ADC overrides; begin simplifying analog battery logic (#3134)

* Isolate esp32 adc logic gymnastics, try simplifying getBattVoltage

* Set sense resolution for pico platforms

* try silencing cppcheck when variant has no battery pin

* ADC channel for esp-idf calibration

* Missed an rp2040 device

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
code8buster
2024-01-29 06:14:21 -06:00
committed by GitHub
co-authored by GitHub Ben Meadors
parent af52dcecdf
commit d1ea589757
12 changed files with 67 additions and 53 deletions
+1
View File
@@ -80,6 +80,7 @@ static const uint8_t A5 = PIN_A5;
// Other pins
#define PIN_AREF PIN_A5
#define PIN_VBAT PIN_A4
#define BATTERY_PIN PIN_VBAT
#define PIN_NFC1 (33)
#define PIN_NFC2 (2)
#define PIN_PIEZO (37)
+1
View File
@@ -100,6 +100,7 @@ static const uint8_t A5 = PIN_A5;
// Other pins
#define PIN_AREF PIN_A5
#define PIN_VBAT PIN_A4
#define BATTERY_PIN PIN_VBAT
#define PIN_NFC1 (33)
#define PIN_NFC2 (2)
#define PIN_PIEZO (37)
+1 -1
View File
@@ -170,7 +170,7 @@ External serial flash W25Q16JV_IQ
// Voltage divider value => 100K + 100K voltage divider on VBAT = (100K / (100K + 100K))
#define VBAT_DIVIDER (0.5F)
// Compensation factor for the VBAT divider
#define VBAT_DIVIDER_COMP (2.0)
#define VBAT_DIVIDER_COMP (2.0F)
// Fixed calculation of milliVolt from compensation value
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
#undef AREF_VOLTAGE
+2
View File
@@ -56,6 +56,8 @@ static const uint8_t SCK = 33;
#define LED_PIN LED_BLUE
#define PIN_VBAT WB_A0
#define BATTERY_PIN PIN_VBAT
#define ADC_CHANNEL ADC1_GPIO36_CHANNEL
// https://docs.rakwireless.com/Product-Categories/WisBlock/RAK13300/
+1
View File
@@ -12,6 +12,7 @@
// #define EXT_NOTIFY_OUT 4
#define BATTERY_PIN 26
#define BATTERY_SENSE_RESOLUTION_BITS ADC_RESOLUTION
// ratio of voltage divider = 3.0 (R17=200k, R18=100k)
#define ADC_MULTIPLIER 3.1 // 3.0 + a bit for being optimistic
+1 -1
View File
@@ -254,7 +254,7 @@ SO GPIO 39/TXEN MAY NOT BE DEFINED FOR SUCCESSFUL OPERATION OF THE SX1262 - TG
// Voltage divider value => 1.5M + 1M voltage divider on VBAT = (1.5M / (1M + 1.5M))
#define VBAT_DIVIDER (0.4F)
// Compensation factor for the VBAT divider
#define VBAT_DIVIDER_COMP (1.73)
#define VBAT_DIVIDER_COMP (1.73F)
// Fixed calculation of milliVolt from compensation value
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
#undef AREF_VOLTAGE
+1 -1
View File
@@ -223,7 +223,7 @@ static const uint8_t SCK = PIN_SPI_SCK;
// Voltage divider value => 1.5M + 1M voltage divider on VBAT = (1.5M / (1M + 1.5M))
#define VBAT_DIVIDER (0.4F)
// Compensation factor for the VBAT divider
#define VBAT_DIVIDER_COMP (1.73)
#define VBAT_DIVIDER_COMP (1.73F)
// Fixed calculation of milliVolt from compensation value
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
#undef AREF_VOLTAGE
+1
View File
@@ -22,6 +22,7 @@
#define BATTERY_PIN 26
// ratio of voltage divider = 3.0 (R17=200k, R18=100k)
#define ADC_MULTIPLIER 3.1 // 3.0 + a bit for being optimistic
#define BATTERY_SENSE_RESOLUTION_BITS ADC_RESOLUTION
#define USE_SX1262
+1
View File
@@ -24,6 +24,7 @@
#define BATTERY_PIN 26
// ratio of voltage divider = 3.0 (R17=200k, R18=100k)
#define ADC_MULTIPLIER 3.1 // 3.0 + a bit for being optimistic
#define BATTERY_SENSE_RESOLUTION_BITS ADC_RESOLUTION
#define USE_SX1262
+1
View File
@@ -8,6 +8,7 @@
#define LED_PIN PIN_LED
#undef BATTERY_PIN
#define BATTERY_SENSE_RESOLUTION_BITS ADC_RESOLUTION
#undef LORA_SCK
#undef LORA_MISO
+1 -1
View File
@@ -213,7 +213,7 @@ External serial flash WP25R1635FZUIL0
// Voltage divider value => 100K + 100K voltage divider on VBAT = (100K / (100K + 100K))
#define VBAT_DIVIDER (0.5F)
// Compensation factor for the VBAT divider
#define VBAT_DIVIDER_COMP (2.0)
#define VBAT_DIVIDER_COMP (2.0F)
// Fixed calculation of milliVolt from compensation value
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
#undef AREF_VOLTAGE