auto-sync
This commit is contained in:
parent
7df1c68b4d
commit
45d9b0926b
|
@ -24,7 +24,7 @@ void setDodgeRam1996(DECLARE_ENGINE_PARAMETER_F) {
|
|||
engineConfiguration->specs.firingOrder = FO_1_8_4_3_6_5_7_2;
|
||||
|
||||
boardConfiguration->triggerInputPins[0] = GPIOC_6;
|
||||
boardConfiguration->triggerInputPins[1] = GPIOA_8;
|
||||
boardConfiguration->triggerInputPins[1] = GPIOA_5;
|
||||
|
||||
engineConfiguration->vbattAdcChannel = EFI_ADC_NONE; // todo: conflict with what?
|
||||
}
|
||||
|
|
|
@ -311,7 +311,7 @@ static void printAnalogChannelInfoExt(const char *name, adc_channel_e hwChannel,
|
|||
static void printAnalogChannelInfo(const char *name, adc_channel_e hwChannel) {
|
||||
#if HAL_USE_ADC || defined(__DOXYGEN__)
|
||||
if (hwChannel != EFI_ADC_NONE) {
|
||||
printAnalogChannelInfoExt(name, hwChannel, getVoltage(hwChannel));
|
||||
printAnalogChannelInfoExt(name, hwChannel, getVoltage("print", hwChannel));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -24,5 +24,5 @@ bool getAcToggle(Engine *engine) {
|
|||
* for now we are looking for a pull-up. High level means input switch is floating (which is OFF position)
|
||||
* low value means input is ground - which means ON.
|
||||
*/
|
||||
return getVoltageDivided(engine->engineConfiguration->acSwitchAdc) < 2.5;
|
||||
return getVoltageDivided("A/C", engine->engineConfiguration->acSwitchAdc) < 2.5;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ EXTERN_ENGINE;
|
|||
float getAfr(DECLARE_ENGINE_PARAMETER_F) {
|
||||
afr_sensor_s * sensor = &engineConfiguration->afr;
|
||||
|
||||
float volts = getVoltageDivided(sensor->hwChannel);
|
||||
float volts = getVoltageDivided("ego", sensor->hwChannel);
|
||||
|
||||
return interpolate(sensor->v1, sensor->value1, sensor->v2, sensor->value2, volts);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ float getMaf(DECLARE_ENGINE_PARAMETER_F) {
|
|||
* @return kg/hour value
|
||||
*/
|
||||
float getRealMaf(DECLARE_ENGINE_PARAMETER_F) {
|
||||
int mafAdc = getAdcValue(engineConfiguration->mafAdcChannel);
|
||||
int mafAdc = getAdcValue("maf", engineConfiguration->mafAdcChannel);
|
||||
/**
|
||||
* here we drop from 12 bit ADC to 8 bit index
|
||||
*/
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include "main.h"
|
||||
|
||||
#define getMafT(ec) (getVoltageDivided(ec->mafAdcChannel))
|
||||
#define getMafT(ec) (getVoltageDivided("maf", ec->mafAdcChannel))
|
||||
float getMaf(void);
|
||||
float getRealMaf(DECLARE_ENGINE_PARAMETER_F);
|
||||
|
||||
|
|
|
@ -76,12 +76,12 @@ float getMapByVoltage(float voltage DECLARE_ENGINE_PARAMETER_S) {
|
|||
* @return Manifold Absolute Pressure, in kPa
|
||||
*/
|
||||
float getRawMap(DECLARE_ENGINE_PARAMETER_F) {
|
||||
float voltage = getVoltageDivided(engineConfiguration->map.sensor.hwChannel);
|
||||
float voltage = getVoltageDivided("map", engineConfiguration->map.sensor.hwChannel);
|
||||
return getMapByVoltage(voltage PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
|
||||
float getBaroPressure(DECLARE_ENGINE_PARAMETER_F) {
|
||||
float voltage = getVoltageDivided(engineConfiguration->baroSensor.hwChannel);
|
||||
float voltage = getVoltageDivided("map", engineConfiguration->baroSensor.hwChannel);
|
||||
return decodePressure(voltage, &engineConfiguration->baroSensor);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ float getKelvinTemperature(float resistance, ThermistorConf *thermistor) {
|
|||
}
|
||||
|
||||
float getResistance(Thermistor *thermistor) {
|
||||
float voltage = getVoltageDivided(thermistor->channel);
|
||||
float voltage = getVoltageDivided("term", thermistor->channel);
|
||||
efiAssert(thermistor->config != NULL, "thermistor config is null", NAN);
|
||||
float resistance = getR2InVoltageDividor(voltage, _5_VOLTS, thermistor->config->bias_resistor);
|
||||
return resistance;
|
||||
|
|
|
@ -72,7 +72,7 @@ static float getTpsValue(int adc DECLARE_ENGINE_PARAMETER_S) {
|
|||
* Return voltage on TPS AND channel
|
||||
* */
|
||||
float getTPSVoltage(DECLARE_ENGINE_PARAMETER_F) {
|
||||
return getVoltageDivided(engineConfiguration->tpsAdcChannel);
|
||||
return getVoltageDivided("tps", engineConfiguration->tpsAdcChannel);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
#include "voltage.h"
|
||||
|
||||
float getVRef(engine_configuration_s *engineConfiguration) {
|
||||
return getVoltageDivided(engineConfiguration->vRefAdcChannel);
|
||||
return getVoltageDivided("vref", engineConfiguration->vRefAdcChannel);
|
||||
}
|
||||
|
||||
float getVBatt(engine_configuration_s *engineConfiguration) {
|
||||
return getVoltage(engineConfiguration->vbattAdcChannel) * engineConfiguration->vbattDividerCoeff;
|
||||
return getVoltage("vbatt", engineConfiguration->vbattAdcChannel) * engineConfiguration->vbattDividerCoeff;
|
||||
}
|
||||
|
|
|
@ -368,7 +368,7 @@ static char pinNameBuffer[16];
|
|||
|
||||
static void printThermistor(const char *msg, Thermistor *thermistor) {
|
||||
adc_channel_e adcChannel = thermistor->channel;
|
||||
float voltage = getVoltageDivided(adcChannel);
|
||||
float voltage = getVoltageDivided("term", adcChannel);
|
||||
float r = getResistance(thermistor);
|
||||
|
||||
float t = getTemperatureC(thermistor);
|
||||
|
|
|
@ -353,7 +353,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex DECL
|
|||
|
||||
if (eventIndex == engineConfiguration->ignMathCalculateAtIndex) {
|
||||
if (engineConfiguration->externalKnockSenseAdc != EFI_ADC_NONE) {
|
||||
float externalKnockValue = getVoltageDivided(engineConfiguration->externalKnockSenseAdc);
|
||||
float externalKnockValue = getVoltageDivided("knock", engineConfiguration->externalKnockSenseAdc);
|
||||
engine->knockNow = externalKnockValue > 2.5;
|
||||
engine->knockEver |= engine->knockNow;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ static void showHipInfo(void) {
|
|||
nonZeroResponse);
|
||||
scheduleMsg(logger, "CS=%s updateCount=%d", hwPortname(boardConfiguration->hip9011CsPin), settingUpdateCount);
|
||||
|
||||
scheduleMsg(logger, "value=%f@#%d", getVoltageDivided(engineConfiguration->hipOutputChannel),
|
||||
scheduleMsg(logger, "value=%f@#%d", getVoltageDivided("hip", engineConfiguration->hipOutputChannel),
|
||||
engineConfiguration->hipOutputChannel);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,6 @@
|
|||
|
||||
#define getAdcValue(channel) getMcp3208adc(channel)
|
||||
#define adcToVoltsDivided(adc) (5.0f / 4095 * adc)
|
||||
#define getVoltageDivided(channel) (channel == EFI_ADC_NONE ? 66.66 : adcToVoltsDivided(getAdcValue(channel)))
|
||||
#define getVoltageDivided(msg, channel) (channel == EFI_ADC_NONE ? 66.66 : adcToVoltsDivided(getAdcValue(msg, channel)))
|
||||
|
||||
#endif /* ADC_EXTERNAL_H_ */
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "pin_repository.h"
|
||||
#include "engine_math.h"
|
||||
#include "board_test.h"
|
||||
#include "engine_controller.h"
|
||||
|
||||
static adc_channel_mode_e adcHwChannelEnabled[HW_MAX_ADC_INDEX];
|
||||
|
||||
|
@ -187,9 +188,9 @@ static void pwmpcb_fast(PWMDriver *pwmp) {
|
|||
#endif
|
||||
}
|
||||
|
||||
int getInternalAdcValue(adc_channel_e hwChannel) {
|
||||
int getInternalAdcValue(const char *msg, adc_channel_e hwChannel) {
|
||||
if (hwChannel == EFI_ADC_NONE) {
|
||||
warning(OBD_PCM_Processor_Fault, "ADC: should not be asking for NONE");
|
||||
warning(OBD_PCM_Processor_Fault, "ADC: should not be asking for NONE %s", msg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -404,7 +405,7 @@ void AdcDevice::addChannel(adc_channel_e hwChannel) {
|
|||
}
|
||||
|
||||
static void printAdcValue(adc_channel_e channel) {
|
||||
int value = getAdcValue(channel);
|
||||
int value = getAdcValue("print", channel);
|
||||
float volts = adcToVoltsDivided(value);
|
||||
scheduleMsg(&logger, "adc voltage : %f", volts);
|
||||
}
|
||||
|
@ -465,12 +466,15 @@ static void adc_callback_slow(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
|
|||
}
|
||||
}
|
||||
|
||||
static char errorMsgBuff[10];
|
||||
|
||||
static void addChannel(const char *name, adc_channel_e setting, adc_channel_mode_e mode) {
|
||||
if (setting == EFI_ADC_NONE) {
|
||||
return;
|
||||
}
|
||||
if (adcHwChannelEnabled[setting] != ADC_OFF) {
|
||||
firmwareError("ADC mapping error: input for %s already used?", name);
|
||||
getPinNameByAdcChannel(setting, errorMsgBuff);
|
||||
firmwareError("ADC mapping error: input %s for %s already used?", errorMsgBuff, name);
|
||||
}
|
||||
|
||||
adcHwChannelEnabled[setting] = mode;
|
||||
|
|
|
@ -24,7 +24,7 @@ adc_channel_e getAdcChannel(brain_pin_e pin);
|
|||
int getAdcHardwareIndexByInternalIndex(int index);
|
||||
|
||||
void pokeAdcInputs(void);
|
||||
int getInternalAdcValue(adc_channel_e index);
|
||||
int getInternalAdcValue(const char *msg, adc_channel_e index);
|
||||
|
||||
/* Depth of the conversion buffer, channels are sampled X times each.*/
|
||||
#define ADC_BUF_DEPTH_SLOW 1
|
||||
|
@ -43,7 +43,7 @@ typedef struct {
|
|||
// time_t time;
|
||||
} adc_state;
|
||||
|
||||
#define getAdcValue(hwChannel) getInternalAdcValue(hwChannel)
|
||||
#define getAdcValue(msg, hwChannel) getInternalAdcValue(msg, hwChannel)
|
||||
|
||||
// todo: migrate to adcToVoltageInputDividerCoefficient
|
||||
#define adcToVoltsDivided(adc) (adcToVolts(adc) * engineConfiguration->analogInputDividerCoefficient)
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
#define voltsToAdc(volts) ((volts) * (ADC_MAX_VALUE / ADC_VCC))
|
||||
|
||||
#define getVoltage(hwChannel) (adcToVolts(getAdcValue(hwChannel)))
|
||||
#define getVoltage(msg, hwChannel) (adcToVolts(getAdcValue(msg, hwChannel)))
|
||||
|
||||
#define getVoltageDivided(hwChannel) (getVoltage(hwChannel) * engineConfiguration->analogInputDividerCoefficient)
|
||||
#define getVoltageDivided(msg, hwChannel) (getVoltage(msg, hwChannel) * engineConfiguration->analogInputDividerCoefficient)
|
||||
|
||||
#endif /* ADC_MATH_H_ */
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
float testMafValue = 0;
|
||||
|
||||
float getVoltageDivided(int channel) {
|
||||
float getVoltageDivided(const char *msg, int channel) {
|
||||
switch(channel) {
|
||||
case TEST_MAF_CHANNEL:
|
||||
return testMafValue;
|
||||
|
@ -17,11 +17,11 @@ float getVoltageDivided(int channel) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
float getVoltage(int channel) {
|
||||
float getVoltage(const char *msg, int channel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getAdcValue(int channel) {
|
||||
int getAdcValue(const char *msg, int channel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
|
||||
#define TEST_MAF_CHANNEL 10000013
|
||||
|
||||
float getVoltageDivided(int);
|
||||
float getVoltage(int channel);
|
||||
int getAdcValue(int channel);
|
||||
float getVoltageDivided(const char *msg, int);
|
||||
float getVoltage(const char *msg, int channel);
|
||||
int getAdcValue(const char *msg, int channel);
|
||||
|
||||
#endif /* BOARDS_H_ */
|
||||
|
|
Loading…
Reference in New Issue