refactor(radio): unified battery and RTC voltage (#6065)

This commit is contained in:
Raphael Coeffic
2025-04-27 13:46:18 +10:00
committed by GitHub
parent f237e9d40b
commit b52e7717ab
13 changed files with 185 additions and 154 deletions
+9 -14
View File
@@ -35,6 +35,8 @@
#define ANALOG_SCALE 1
#define JITTER_ALPHA (1<<JITTER_FILTER_STRENGTH)
#define ADC_MAX_FILTERED (ADC_MAX_VALUE >> ANALOG_SCALE)
enum {
ADC_INPUT_MAIN=0, // gimbals / wheel + throttle
ADC_INPUT_FLEX,
@@ -85,11 +87,9 @@ struct etx_hal_adc_driver_t {
bool adcInit(const etx_hal_adc_driver_t* driver);
// void adcDeInit();
bool adcRead();
uint16_t getBatteryVoltage();
uint16_t getRTCBatteryVoltage();
uint16_t getAnalogValue(uint8_t index);
void setAnalogValue(uint8_t index, uint16_t value);
bool adcRead();
uint16_t getAnalogValue(uint8_t index);
void setAnalogValue(uint8_t index, uint16_t value);
uint16_t* getAnalogValues();
// Run calibration steps:
@@ -114,10 +114,9 @@ extern JitterMeter<uint16_t> avgJitter[MAX_ANALOG_INPUTS];
void getADC();
uint16_t anaIn(uint8_t chan);
uint32_t anaIn_diag(uint8_t chan);
uint16_t getBatteryVoltage();
// Warning:
// STM32 uses a 25K+25K voltage divider bridge to measure the battery voltage
// STM32 uses a voltage divider bridge to measure the battery voltage
// Measuring VBAT puts considerable drain (22 µA) on the battery instead of
// normal drain (~10 nA)
void enableVBatBridge();
@@ -143,10 +142,6 @@ const char* adcGetInputShortLabel(uint8_t type, uint8_t idx);
void adcSetInputMask(uint32_t mask);
uint32_t adcGetInputMask();
// To be implemented by the target driver
// int8_t adcGetVRTC();
// int8_t adcGetVBAT();
// const char* adcGetStickName(uint8_t idx);
// const char* adcGetPotName(uint8_t idx);
// uint8_t adcGetMaxSticks();
// uint8_t adcGetMaxPots();
// these 2 must be implemented as part of board drivers
uint16_t getBatteryVoltage();
uint16_t getRTCBatteryVoltage();