auto-sync
This commit is contained in:
parent
5eaa81daf9
commit
e6fe729edb
|
@ -9,9 +9,9 @@
|
||||||
|
|
||||||
#if HAL_USE_ADC || defined(__DOXYGEN__)
|
#if HAL_USE_ADC || defined(__DOXYGEN__)
|
||||||
|
|
||||||
class AdcConfiguration {
|
class AdcDevice {
|
||||||
public:
|
public:
|
||||||
AdcConfiguration(ADCConversionGroup* hwConfig);
|
AdcDevice(ADCConversionGroup* hwConfig);
|
||||||
void addChannel(adc_channel_e hwChannelIndex);
|
void addChannel(adc_channel_e hwChannelIndex);
|
||||||
adc_channel_e getAdcHardwareIndexByInternalIndex(int index);
|
adc_channel_e getAdcHardwareIndexByInternalIndex(int index);
|
||||||
int internalAdcIndexByHardwareIndex[20];
|
int internalAdcIndexByHardwareIndex[20];
|
||||||
|
@ -22,6 +22,8 @@ public:
|
||||||
int errorsCount;
|
int errorsCount;
|
||||||
int getAdcValueByIndex(int internalIndex);
|
int getAdcValueByIndex(int internalIndex);
|
||||||
|
|
||||||
|
adcsample_t samples[ADC_MAX_CHANNELS_COUNT * ADC_GRP1_BUF_DEPTH_SLOW];
|
||||||
|
|
||||||
adc_state values;
|
adc_state values;
|
||||||
private:
|
private:
|
||||||
ADCConversionGroup* hwConfig;
|
ADCConversionGroup* hwConfig;
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "map_averaging.h"
|
#include "map_averaging.h"
|
||||||
#endif /* EFI_SPEED_DENSITY */
|
#endif /* EFI_SPEED_DENSITY */
|
||||||
|
|
||||||
AdcConfiguration::AdcConfiguration(ADCConversionGroup* hwConfig) {
|
AdcDevice::AdcDevice(ADCConversionGroup* hwConfig) {
|
||||||
this->hwConfig = hwConfig;
|
this->hwConfig = hwConfig;
|
||||||
channelCount = 0;
|
channelCount = 0;
|
||||||
conversionCount = 0;
|
conversionCount = 0;
|
||||||
|
@ -69,8 +69,6 @@ static int fastAdcValue;
|
||||||
extern engine_configuration_s *engineConfiguration;
|
extern engine_configuration_s *engineConfiguration;
|
||||||
extern board_configuration_s *boardConfiguration;
|
extern board_configuration_s *boardConfiguration;
|
||||||
|
|
||||||
static adc_hw_helper_s slowAdcState;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ADC samples buffer.
|
* ADC samples buffer.
|
||||||
*/
|
*/
|
||||||
|
@ -133,7 +131,7 @@ ADC_TwoSamplingDelay_20Cycles, // cr1
|
||||||
// Conversion group sequence 1...6
|
// Conversion group sequence 1...6
|
||||||
};
|
};
|
||||||
|
|
||||||
AdcConfiguration slowAdc(&adcgrpcfgSlow);
|
AdcDevice slowAdc(&adcgrpcfgSlow);
|
||||||
|
|
||||||
static ADCConversionGroup adcgrpcfg_fast = { FALSE, 0 /* num_channels */, adc_callback_fast, NULL,
|
static ADCConversionGroup adcgrpcfg_fast = { FALSE, 0 /* num_channels */, adc_callback_fast, NULL,
|
||||||
/* HW dependent part.*/
|
/* HW dependent part.*/
|
||||||
|
@ -151,7 +149,7 @@ ADC_TwoSamplingDelay_5Cycles, // cr1
|
||||||
// Conversion group sequence 1...6
|
// Conversion group sequence 1...6
|
||||||
};
|
};
|
||||||
|
|
||||||
AdcConfiguration fastAdc(&adcgrpcfg_fast);
|
AdcDevice fastAdc(&adcgrpcfg_fast);
|
||||||
|
|
||||||
static void pwmpcb_slow(PWMDriver *pwmp) {
|
static void pwmpcb_slow(PWMDriver *pwmp) {
|
||||||
#if EFI_INTERNAL_ADC
|
#if EFI_INTERNAL_ADC
|
||||||
|
@ -172,7 +170,7 @@ static void pwmpcb_slow(PWMDriver *pwmp) {
|
||||||
;
|
;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
adcStartConversionI(&ADC_SLOW_DEVICE, &adcgrpcfgSlow, slowAdcState.samples, ADC_GRP1_BUF_DEPTH_SLOW);
|
adcStartConversionI(&ADC_SLOW_DEVICE, &adcgrpcfgSlow, slowAdc.samples, ADC_GRP1_BUF_DEPTH_SLOW);
|
||||||
chSysUnlockFromIsr()
|
chSysUnlockFromIsr()
|
||||||
;
|
;
|
||||||
#endif
|
#endif
|
||||||
|
@ -371,20 +369,20 @@ static void initAdcHwChannel(adc_channel_e hwChannel) {
|
||||||
initAdcPin(port, pin, "hw");
|
initAdcPin(port, pin, "hw");
|
||||||
}
|
}
|
||||||
|
|
||||||
int AdcConfiguration::size() {
|
int AdcDevice::size() {
|
||||||
return channelCount;
|
return channelCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AdcConfiguration::getAdcValueByIndex(int internalIndex) {
|
int AdcDevice::getAdcValueByIndex(int internalIndex) {
|
||||||
return values.adc_data[internalIndex];
|
return values.adc_data[internalIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdcConfiguration::init(void) {
|
void AdcDevice::init(void) {
|
||||||
hwConfig->num_channels = size();
|
hwConfig->num_channels = size();
|
||||||
hwConfig->sqr1 += ADC_SQR1_NUM_CH(size());
|
hwConfig->sqr1 += ADC_SQR1_NUM_CH(size());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AdcConfiguration::isHwUsed(adc_channel_e hwChannelIndex) {
|
bool AdcDevice::isHwUsed(adc_channel_e hwChannelIndex) {
|
||||||
for (int i = 0; i < channelCount; i++) {
|
for (int i = 0; i < channelCount; i++) {
|
||||||
if (hardwareIndexByIndernalAdcIndex[i] == hwChannelIndex) {
|
if (hardwareIndexByIndernalAdcIndex[i] == hwChannelIndex) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -393,7 +391,7 @@ bool AdcConfiguration::isHwUsed(adc_channel_e hwChannelIndex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdcConfiguration::addChannel(adc_channel_e hwChannel) {
|
void AdcDevice::addChannel(adc_channel_e hwChannel) {
|
||||||
int logicChannel = channelCount++;
|
int logicChannel = channelCount++;
|
||||||
|
|
||||||
internalAdcIndexByHardwareIndex[hwChannel] = logicChannel;
|
internalAdcIndexByHardwareIndex[hwChannel] = logicChannel;
|
||||||
|
@ -414,7 +412,7 @@ static void printAdcValue(adc_channel_e channel) {
|
||||||
scheduleMsg(&logger, "adc voltage : %f", volts);
|
scheduleMsg(&logger, "adc voltage : %f", volts);
|
||||||
}
|
}
|
||||||
|
|
||||||
adc_channel_e AdcConfiguration::getAdcHardwareIndexByInternalIndex(int index) {
|
adc_channel_e AdcDevice::getAdcHardwareIndexByInternalIndex(int index) {
|
||||||
return hardwareIndexByIndernalAdcIndex[index];
|
return hardwareIndexByIndernalAdcIndex[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,7 +459,7 @@ static void adc_callback_slow(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
|
||||||
|
|
||||||
// newState.time = chimeNow();
|
// newState.time = chimeNow();
|
||||||
for (int i = 0; i < slowAdc.size(); i++) {
|
for (int i = 0; i < slowAdc.size(); i++) {
|
||||||
int value = getAvgAdcValue(i, slowAdcState.samples, ADC_GRP1_BUF_DEPTH_SLOW, slowAdc.size());
|
int value = getAvgAdcValue(i, slowAdc.samples, ADC_GRP1_BUF_DEPTH_SLOW, slowAdc.size());
|
||||||
slowAdc.values.adc_data[i] = value;
|
slowAdc.values.adc_data[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,13 +46,6 @@ typedef struct {
|
||||||
// time_t time;
|
// time_t time;
|
||||||
} adc_state;
|
} adc_state;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
adcsample_t samples[ADC_MAX_CHANNELS_COUNT * ADC_GRP1_BUF_DEPTH_SLOW];
|
|
||||||
|
|
||||||
|
|
||||||
} adc_hw_helper_s;
|
|
||||||
|
|
||||||
|
|
||||||
#define getAdcValue(hwChannel) getInternalAdcValue(hwChannel)
|
#define getAdcValue(hwChannel) getInternalAdcValue(hwChannel)
|
||||||
|
|
||||||
// todo: migrate to adcToVoltageInputDividerCoefficient
|
// todo: migrate to adcToVoltageInputDividerCoefficient
|
||||||
|
|
|
@ -36,12 +36,11 @@ static bool isTimeForNextStep(int copy) {
|
||||||
return copy != stepCoutner;
|
return copy != stepCoutner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if HAL_USE_ADC || defined(__DOXYGEN__)
|
#if HAL_USE_ADC || defined(__DOXYGEN__)
|
||||||
extern AdcConfiguration slowAdc;
|
extern AdcDevice slowAdc;
|
||||||
extern AdcConfiguration fastAdc;
|
extern AdcDevice fastAdc;
|
||||||
|
|
||||||
static void processAdcPin(AdcConfiguration *adc, int index, const char *prefix) {
|
static void processAdcPin(AdcDevice *adc, int index, const char *prefix) {
|
||||||
adc_channel_e hwIndex = adc->getAdcHardwareIndexByInternalIndex(index);
|
adc_channel_e hwIndex = adc->getAdcHardwareIndexByInternalIndex(index);
|
||||||
GPIO_TypeDef* port = getAdcChannelPort(hwIndex);
|
GPIO_TypeDef* port = getAdcChannelPort(hwIndex);
|
||||||
int pin = getAdcChannelPin(hwIndex);
|
int pin = getAdcChannelPin(hwIndex);
|
||||||
|
|
|
@ -265,5 +265,5 @@ int getRusEfiVersion(void) {
|
||||||
return 1; // this is here to make the compiler happy about the unused array
|
return 1; // this is here to make the compiler happy about the unused array
|
||||||
if (UNUSED_CCM_SIZE == 0)
|
if (UNUSED_CCM_SIZE == 0)
|
||||||
return 1; // this is here to make the compiler happy about the unused array
|
return 1; // this is here to make the compiler happy about the unused array
|
||||||
return 20150113;
|
return 20150114;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue