mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-24 16:55:29 +03:00
[ADC] Implement ADC averaging on F7, enable ADC averaging on all targets
This commit is contained in:
parent
8847ce56e3
commit
07b831bed4
3 changed files with 8 additions and 8 deletions
|
@ -46,6 +46,10 @@ uint16_t adcGetChannel(uint8_t channel);
|
|||
bool adcIsFunctionAssigned(uint8_t function);
|
||||
int adcGetFunctionChannelAllocation(uint8_t function);
|
||||
|
||||
#if !defined(USE_ADC_AVERAGING)
|
||||
#define ADC_AVERAGE_N_SAMPLES 1
|
||||
#if defined(USE_ADC_AVERAGING)
|
||||
#if !defined(ADC_AVERAGE_N_SAMPLES)
|
||||
#define ADC_AVERAGE_N_SAMPLES 20
|
||||
#endif
|
||||
#else
|
||||
#define ADC_AVERAGE_N_SAMPLES 1
|
||||
#endif
|
||||
|
|
|
@ -110,7 +110,7 @@ static void adcInstanceInit(ADCDevice adcDevice)
|
|||
adc->DmaHandle.Init.Channel = adc->channel;
|
||||
adc->DmaHandle.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||
adc->DmaHandle.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
adc->DmaHandle.Init.MemInc = adc->usedChannelCount > 1 ? DMA_MINC_ENABLE : DMA_MINC_DISABLE;
|
||||
adc->DmaHandle.Init.MemInc = ((adc->usedChannelCount > 1) || (ADC_AVERAGE_N_SAMPLES > 1)) ? DMA_MINC_ENABLE : DMA_MINC_DISABLE;
|
||||
adc->DmaHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
|
||||
adc->DmaHandle.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
|
||||
adc->DmaHandle.Init.Mode = DMA_CIRCULAR;
|
||||
|
@ -152,7 +152,7 @@ static void adcInstanceInit(ADCDevice adcDevice)
|
|||
|
||||
//HAL_CLEANINVALIDATECACHE((uint32_t*)&adcValues[adcDevice], configuredAdcChannels);
|
||||
/*##-4- Start the conversion process #######################################*/
|
||||
if (HAL_ADC_Start_DMA(&adc->ADCHandle, (uint32_t*)&adcValues[adcDevice], adc->usedChannelCount) != HAL_OK)
|
||||
if (HAL_ADC_Start_DMA(&adc->ADCHandle, (uint32_t*)&adcValues[adcDevice], adc->usedChannelCount * ADC_AVERAGE_N_SAMPLES) != HAL_OK)
|
||||
{
|
||||
/* Start Conversation Error */
|
||||
}
|
||||
|
|
|
@ -45,11 +45,7 @@
|
|||
#define SKIP_CLI_RESOURCES
|
||||
#endif
|
||||
|
||||
#if defined(STM32F3) || defined(STM32F4)
|
||||
#define USE_ADC_AVERAGING
|
||||
#define ADC_AVERAGE_N_SAMPLES 20
|
||||
#endif
|
||||
|
||||
#define USE_64BIT_TIME
|
||||
#define USE_BLACKBOX
|
||||
#define USE_GPS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue