ADC: DMA buffers should be quilified volatile
This commit is contained in:
parent
75b3a26697
commit
5837abb4f1
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
class AdcDevice {
|
class AdcDevice {
|
||||||
public:
|
public:
|
||||||
explicit AdcDevice(ADCConversionGroup* p_hwConfig, adcsample_t *p_buf);
|
explicit AdcDevice(ADCConversionGroup* p_hwConfig, volatile adcsample_t *p_buf);
|
||||||
void enableChannel(adc_channel_e hwChannel);
|
void enableChannel(adc_channel_e hwChannel);
|
||||||
adc_channel_e getAdcChannelByInternalIndex(int index) const;
|
adc_channel_e getAdcChannelByInternalIndex(int index) const;
|
||||||
adcsample_t getAvgAdcValue(adc_channel_e hwChannel, size_t bufDepth);
|
adcsample_t getAvgAdcValue(adc_channel_e hwChannel, size_t bufDepth);
|
||||||
|
@ -32,7 +32,7 @@ public:
|
||||||
void init(void);
|
void init(void);
|
||||||
uint32_t conversionCount = 0;
|
uint32_t conversionCount = 0;
|
||||||
|
|
||||||
adcsample_t *samples;
|
volatile adcsample_t *samples;
|
||||||
private:
|
private:
|
||||||
ADCConversionGroup* hwConfig;
|
ADCConversionGroup* hwConfig;
|
||||||
uint8_t internalAdcIndexByHardwareIndex[EFI_ADC_TOTAL_CHANNELS];
|
uint8_t internalAdcIndexByHardwareIndex[EFI_ADC_TOTAL_CHANNELS];
|
||||||
|
|
|
@ -33,7 +33,7 @@ float __attribute__((weak)) getAnalogInputDividerCoefficient(adc_channel_e) {
|
||||||
#include "periodic_thread_controller.h"
|
#include "periodic_thread_controller.h"
|
||||||
#include "protected_gpio.h"
|
#include "protected_gpio.h"
|
||||||
|
|
||||||
static NO_CACHE adcsample_t slowAdcSamples[SLOW_ADC_CHANNEL_COUNT];
|
static volatile NO_CACHE adcsample_t slowAdcSamples[SLOW_ADC_CHANNEL_COUNT];
|
||||||
|
|
||||||
static adc_channel_mode_e adcHwChannelMode[HW_MAX_ADC_INDEX];
|
static adc_channel_mode_e adcHwChannelMode[HW_MAX_ADC_INDEX];
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ float getVoltage(const char *msg, adc_channel_e hwChannel) {
|
||||||
#define ADC_BUF_DEPTH_FAST 4
|
#define ADC_BUF_DEPTH_FAST 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AdcDevice::AdcDevice(ADCConversionGroup* p_hwConfig, adcsample_t *p_buf) {
|
AdcDevice::AdcDevice(ADCConversionGroup* p_hwConfig, volatile adcsample_t *p_buf) {
|
||||||
hwConfig = p_hwConfig;
|
hwConfig = p_hwConfig;
|
||||||
samples = p_buf;
|
samples = p_buf;
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ static ADCConversionGroup adcgrpcfgFast = {
|
||||||
#endif /* ADC_MAX_CHANNELS_COUNT */
|
#endif /* ADC_MAX_CHANNELS_COUNT */
|
||||||
};
|
};
|
||||||
|
|
||||||
static NO_CACHE adcsample_t fastAdcSampleBuf[ADC_BUF_DEPTH_FAST * ADC_MAX_CHANNELS_COUNT];
|
static volatile NO_CACHE adcsample_t fastAdcSampleBuf[ADC_BUF_DEPTH_FAST * ADC_MAX_CHANNELS_COUNT];
|
||||||
|
|
||||||
AdcDevice fastAdc(&adcgrpcfgFast, fastAdcSampleBuf);
|
AdcDevice fastAdc(&adcgrpcfgFast, fastAdcSampleBuf);
|
||||||
|
|
||||||
|
@ -170,7 +170,8 @@ static void fastAdcTrigger(GPTDriver*) {
|
||||||
// todo: when? why? criticalError("ADC fast not ready?");
|
// todo: when? why? criticalError("ADC fast not ready?");
|
||||||
// see notes at https://github.com/rusefi/rusefi/issues/6399
|
// see notes at https://github.com/rusefi/rusefi/issues/6399
|
||||||
} else {
|
} else {
|
||||||
adcStartConversionI(&ADC_FAST_DEVICE, &adcgrpcfgFast, fastAdc.samples, ADC_BUF_DEPTH_FAST);
|
/* drop volatile type qualifier - this is safe */
|
||||||
|
adcStartConversionI(&ADC_FAST_DEVICE, &adcgrpcfgFast, (adcsample_t *)fastAdc.samples, ADC_BUF_DEPTH_FAST);
|
||||||
}
|
}
|
||||||
chSysUnlockFromISR();
|
chSysUnlockFromISR();
|
||||||
#endif /* EFI_INTERNAL_ADC */
|
#endif /* EFI_INTERNAL_ADC */
|
||||||
|
@ -365,7 +366,8 @@ public:
|
||||||
{
|
{
|
||||||
ScopePerf perf(PE::AdcConversionSlow);
|
ScopePerf perf(PE::AdcConversionSlow);
|
||||||
|
|
||||||
if (!readSlowAnalogInputs(slowAdcSamples)) {
|
/* drop volatile type qualifier - this is safe */
|
||||||
|
if (!readSlowAnalogInputs((adcsample_t *)slowAdcSamples)) {
|
||||||
slowAdcErrorsCount++;
|
slowAdcErrorsCount++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue