feat: Radiomaster TX15 support (#6484)

Co-authored-by: Malte Langermann <54738901+gagarinlg@users.noreply.github.com>
Co-authored-by: 3djc <3djc@gh.com>
Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com>
Co-authored-by: philmoz <phil.a.mitchell@gmail.com>
Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
3djc
2025-08-20 09:13:30 +10:00
committed by GitHub
co-authored by Malte Langermann 3djc raphaelcoeffic philmoz Peter Feerick
parent 3a00c0812b
commit 324b2c7761
82 changed files with 5745 additions and 201 deletions
@@ -33,8 +33,12 @@
#include <string.h>
#include "FreeRTOSConfig.h"
#define OVERSAMPLING 4
#if defined(STM32H7) || defined(STM32H7RS) || defined(STM32H5)
// Disable software oversampling as HW one is used
#define OVERSAMPLING 1
#else
#define OVERSAMPLING 4
#endif
#define SAMPLING_TIMEOUT_US 500
@@ -78,6 +82,9 @@ static uint8_t _adc_run;
static uint8_t _adc_oversampling_disabled;
static uint16_t _adc_oversampling[MAX_ADC_INPUTS];
// Indicates ADC timeout has occured
static bool _adc_timeout_error;
void stm32_hal_set_inputs_mask(uint32_t inputs)
{
_adc_input_inhibt_mask |= inputs;
@@ -232,6 +239,12 @@ static void adc_setup_scan_mode(ADC_TypeDef* ADCx, uint8_t nconv)
wait_loop_index--;
}
}
/* Start ADC calibration in mode single-ended or differential */
LL_ADC_StartCalibration(ADCx, LL_ADC_CALIB_OFFSET_LINEARITY, LL_ADC_SINGLE_ENDED);
/* Wait for calibration completion */
while (LL_ADC_IsCalibrationOnGoing(ADCx) != 0UL);
#endif
#if defined(LL_ADC_RESOLUTION_12B_OPT)
@@ -253,6 +266,17 @@ static void adc_setup_scan_mode(ADC_TypeDef* ADCx, uint8_t nconv)
#endif
}
#if defined(STM32H7RS) || defined(STM32H7) || defined(STM32H5)
// set hardware oversampling
if (!_adc_oversampling_disabled && ADCx != ADC3) {
// LL_ADC_OVS_RATIO_x in stm32h7xx_ll_adc.h is broken
// so actual oversampling count need to be used
// ADC3 oversampling is disabled because of issues in LL libs
LL_ADC_ConfigOverSamplingRatioShift(ADCx, 16, LL_ADC_OVS_SHIFT_RIGHT_4);
LL_ADC_SetOverSamplingScope(ADCx, LL_ADC_OVS_GRP_REGULAR_CONTINUED);
}
#endif
LL_ADC_REG_Init(ADCx, &adcRegInit);
// Enable ADC
@@ -756,10 +780,12 @@ void stm32_hal_adc_wait_completion(const stm32_adc_t* ADCs, uint8_t n_ADC,
// busy wait
if ((uint32_t)(timersGetUsTick() - timeout) >= SAMPLING_TIMEOUT_US) {
TRACE("ADC timeout");
_adc_timeout_error = true;
_adc_started_mask = 0;
return;
}
}
_adc_timeout_error = false;
}
void stm32_hal_adc_disable_oversampling()
@@ -787,7 +813,7 @@ static void _adc_chain_conversions(const stm32_adc_t* adc)
for (uint8_t i = 0; i < _adc_n_inputs; i++) {
if (~_adc_input_mask & (1 << i)) continue;
if (_adc_inhibit_mask & (1 << i)) continue;
adcValues[i] = _adc_oversampling[i] / OVERSAMPLING;
if (!_adc_timeout_error) adcValues[i] = _adc_oversampling[i] / OVERSAMPLING;
}
// we're done!