@@ -29,10 +29,6 @@ const etx_hal_adc_inputs_t* _hal_adc_inputs = nullptr;
2929
3030static uint16_t adcValues[MAX_ANALOG_INPUTS] __DMA_NO_CACHE;
3131
32- #if defined(CSD203_SENSOR)
33- extern uint16_t getCSD203BatteryVoltage (void );
34- #endif
35-
3632bool adcInit (const etx_hal_adc_driver_t * driver)
3733{
3834 // Init buffer, provides non random values before mixer task starts
@@ -197,7 +193,7 @@ void adcCalibSetMinMax()
197193 }
198194
199195 xpot.stepsCount = ++count;
200- writeXPotCalib (i, xpot.steps , count);
196+ writeXPotCalib (i, xpot.steps , count);
201197 }
202198 }
203199 }
@@ -234,19 +230,6 @@ void adcCalibStore()
234230 storageDirty (EE_GENERAL);
235231}
236232
237- uint16_t getRTCBatteryVoltage ()
238- {
239- // anaIn() outputs value divided by (1 << ANALOG_SCALE)
240- if (adcGetMaxInputs (ADC_INPUT_RTC_BAT) < 1 ) return 0 ;
241- #if defined(STM32F413xx)
242- return (anaIn (adcGetInputOffset (ADC_INPUT_RTC_BAT)) * ADC_VREF_PREC2) /
243- (1024 >> ANALOG_SCALE);
244- #else
245- return (anaIn (adcGetInputOffset (ADC_INPUT_RTC_BAT)) * ADC_VREF_PREC2) /
246- (2048 >> ANALOG_SCALE);
247- #endif
248- }
249-
250233uint16_t getAnalogValue (uint8_t index)
251234{
252235 if (index >= MAX_ANALOG_INPUTS) return 0 ;
@@ -307,41 +290,6 @@ JitterMeter<uint16_t> avgJitter[MAX_ANALOG_INPUTS];
307290tmr10ms_t jitterResetTime = 0 ;
308291#endif
309292
310- uint16_t getBatteryVoltage ()
311- {
312- #if defined(CSD203_SENSOR) && !defined(SIMU)
313- return getCSD203BatteryVoltage () / 10 ;
314- #else
315- // using filtered ADC value on purpose
316- if (adcGetMaxInputs (ADC_INPUT_VBAT) < 1 ) return 0 ;
317- int32_t instant_vbat = anaIn (adcGetInputOffset (ADC_INPUT_VBAT));
318-
319- // TODO: remove BATT_SCALE / BATTERY_DIVIDER defines
320- #if defined(VBAT_MOSFET_DROP)
321- // 1000 is used as multiplier for both numerator and denominator to allow to stay in integer domain
322- return (uint16_t )((instant_vbat * ADC_VREF_PREC2 * ((((1000 + g_eeGeneral.txVoltageCalibration )) * (VBAT_DIV_R2 + VBAT_DIV_R1)) / VBAT_DIV_R1)) / (2 *RESX*1000 )) + VBAT_MOSFET_DROP;
323- #elif defined(BATT_SCALE)
324- instant_vbat =
325- (instant_vbat * BATT_SCALE * (128 + g_eeGeneral.txVoltageCalibration )) /
326- BATTERY_DIVIDER;
327- // add voltage drop because of the diode TODO check if this is needed, but
328- // removal will break existing calibrations!
329- instant_vbat += VOLTAGE_DROP;
330- return (uint16_t )instant_vbat;
331- #elif defined(VOLTAGE_DROP)
332- instant_vbat = ((instant_vbat * (1000 + g_eeGeneral.txVoltageCalibration )) /
333- BATTERY_DIVIDER);
334- // add voltage drop because of the diode
335- // removal will break existing calibrations!
336- instant_vbat += VOLTAGE_DROP;
337- return (uint16_t )instant_vbat;
338- #else
339- return (uint16_t )((instant_vbat * (1000 + g_eeGeneral.txVoltageCalibration )) /
340- BATTERY_DIVIDER);
341- #endif
342- #endif
343- }
344-
345293static uint32_t apply_low_pass_filter (uint32_t v, uint32_t v_prev,
346294 bool is_main_input)
347295{
@@ -470,7 +418,7 @@ void getADC()
470418#endif
471419
472420 DEBUG_TIMER_START (debugTimerAdcRead);
473- if (!adcRead ()) TRACE (" adcRead failed" );
421+ if (!adcRead ()) { TRACE (" adcRead failed" ); }
474422 DEBUG_TIMER_STOP (debugTimerAdcRead);
475423
476424 for (uint8_t x = 0 ; x < max_analogs; x++) {
0 commit comments