mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
Improved AHRS_ADC_downsample_data() efficiency/speed.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2429 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
ad7a4cded0
commit
403c9ea2da
@ -257,15 +257,15 @@ void AHRS_ADC_downsample_data()
|
|||||||
uint16_t chan;
|
uint16_t chan;
|
||||||
uint16_t sample;
|
uint16_t sample;
|
||||||
|
|
||||||
for (chan = 0; chan < PIOS_ADC_NUM_CHANNELS; chan++) {
|
for (chan = 0; chan < PIOS_ADC_NUM_CHANNELS; chan++)
|
||||||
downsampled_buffer[chan] = 0;
|
{
|
||||||
for (sample = 0; sample < adc_config.adc_oversample; sample++) {
|
register int32_t sum = 0;
|
||||||
downsampled_buffer[chan] += adc_config.valid_data_buffer[chan + sample * PIOS_ADC_NUM_CHANNELS] * adc_config.fir_coeffs[sample];
|
for (sample = 0; sample < adc_config.adc_oversample; sample++)
|
||||||
}
|
sum += (int32_t)adc_config.valid_data_buffer[chan + sample * PIOS_ADC_NUM_CHANNELS] * adc_config.fir_coeffs[sample];
|
||||||
downsampled_buffer[chan] /= (float) adc_config.fir_coeffs[adc_config.adc_oversample];
|
downsampled_buffer[chan] = (float)sum / adc_config.fir_coeffs[adc_config.adc_oversample];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(callback_function != NULL)
|
if (callback_function)
|
||||||
callback_function(downsampled_buffer);
|
callback_function(downsampled_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user