reorder ADC channel index (#1763)

* change config

* correct logic

* clearing these no longer needed

* test expected this to be set
This commit is contained in:
Matthew Kennedy 2020-09-06 15:25:26 -07:00 committed by GitHub
parent 4c129621c1
commit 0e14e51179
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 45 additions and 93 deletions

View File

@ -74,20 +74,6 @@ void setBoardConfigurationOverrides(void) {
engineConfiguration->mapMinBufferLength = 4;
// todo:
engineConfiguration->map.sensor.hwChannel = EFI_ADC_NONE;
engineConfiguration->mafAdcChannel = EFI_ADC_NONE;
engineConfiguration->hipOutputChannel = EFI_ADC_NONE;
engineConfiguration->tps1_1AdcChannel = EFI_ADC_NONE;
engineConfiguration->fuelLevelSensor = EFI_ADC_NONE;
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_NONE;
engineConfiguration->vbattAdcChannel = EFI_ADC_NONE;
engineConfiguration->clt.adcChannel = EFI_ADC_NONE;
engineConfiguration->iat.adcChannel = EFI_ADC_NONE;
engineConfiguration->afr.hwChannel = EFI_ADC_NONE;
engineConfiguration->oilPressure.hwChannel = EFI_ADC_NONE;
engineConfiguration->acSwitchAdc = EFI_ADC_NONE;
engineConfiguration->clt.adcChannel = EFI_ADC_14;
engineConfiguration->triggerInputPins[0] = GPIOE_7;

View File

@ -10,6 +10,6 @@
#define brain_input_pin_e_enum "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "N/A", "N/A", "PA10", "PA11", "PA12", "PA13", "N/A", "N/A", "N/A", "N/A", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "N/A", "N/A", "N/A", "N/A", "PB12", "PB13", "N/A", "N/A", "N/A", "N/A", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "N/A", "N/A", "N/A", "N/A", "PC14", "PC15", "PC16", "PC17", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "PD15", "PD16", "N/A", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A"
#define switch_input_pin_e_enum "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "N/A", "N/A", "PA10", "PA11", "PA12", "PA13", "N/A", "N/A", "N/A", "N/A", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "N/A", "N/A", "N/A", "N/A", "PB12", "PB13", "N/A", "N/A", "N/A", "N/A", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "N/A", "N/A", "N/A", "N/A", "PC14", "PC15", "PC16", "PC17", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "PD15", "PD16", "N/A", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A"
#define output_pin_e_enum "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "N/A", "N/A", "PA10", "PA11", "PA12", "PA13", "N/A", "N/A", "N/A", "N/A", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "N/A", "N/A", "N/A", "N/A", "PB12", "PB13", "N/A", "N/A", "N/A", "N/A", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "N/A", "N/A", "N/A", "N/A", "PC14", "PC15", "PC16", "PC17", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "PD15", "PD16", "N/A", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "TLE6240_1", "TLE6240_2", "TLE6240_3", "TLE6240_4", "TLE6240_5", "TLE6240_6", "TLE6240_7", "TLE6240_8", "TLE6240_9", "TLE6240_10", "TLE6240_11", "TLE6240_12", "TLE6240_13", "TLE6240_14", "TLE6240_15", "TLE6240_16"
#define adc_channel_e_enum "PA2", "PA3", "INVALID", "PD3", "INVALID", "INVALID", "INVALID", "PB12", "PB13", "INVALID", "PE2", "INVALID", "PC14", "PC15", "PC16", "PC17", "Disabled", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
#define adc_channel_e_enum "Disabled", "PA2", "PA3", "INVALID", "PD3", "INVALID", "INVALID", "INVALID", "PB12", "PB13", "INVALID", "PE2", "INVALID", "PC14", "PC15", "PC16", "PC17"
#define ts_show_trigger_comparator true

View File

@ -159,25 +159,26 @@ typedef enum __attribute__ ((__packed__))
} brain_pin_diag_e;
typedef enum __attribute__ ((__packed__)) {
EFI_ADC_0 = 0,
EFI_ADC_1 = 1,
EFI_ADC_2 = 2,
EFI_ADC_3 = 3,
EFI_ADC_4 = 4,
EFI_ADC_5 = 5,
EFI_ADC_6 = 6,
EFI_ADC_7 = 7,
EFI_ADC_8 = 8,
EFI_ADC_9 = 9,
EFI_ADC_10 = 10,
EFI_ADC_11 = 11,
EFI_ADC_12 = 12,
EFI_ADC_13 = 13,
EFI_ADC_14 = 14,
EFI_ADC_15 = 15,
EFI_ADC_NONE = 0,
EFI_ADC_0 = 1,
EFI_ADC_1 = 2,
EFI_ADC_2 = 3,
EFI_ADC_3 = 4,
EFI_ADC_4 = 5,
EFI_ADC_5 = 6,
EFI_ADC_6 = 7,
EFI_ADC_7 = 8,
EFI_ADC_8 = 9,
EFI_ADC_9 = 10,
EFI_ADC_10 = 11,
EFI_ADC_11 = 12,
EFI_ADC_12 = 13,
EFI_ADC_13 = 14,
EFI_ADC_14 = 15,
EFI_ADC_15 = 16,
// todo: bad choice of value since now we have ADC_CHANNEL_SENSOR and could end up with 17 and 18 also
EFI_ADC_NONE = 16,
EFI_ADC_ERROR = 17,
} adc_channel_e;

View File

@ -33,8 +33,6 @@ void setPinConfigurationOverrides(void) {
//NOT USED
engineConfiguration->baroSensor.hwChannel = EFI_ADC_NONE;
engineConfiguration->afr.hwChannel = EFI_ADC_NONE;
engineConfiguration->ignitionPins[8] = GPIO_UNASSIGNED;
engineConfiguration->ignitionPins[9] = GPIO_UNASSIGNED;
engineConfiguration->mainRelayPin = GPIO_UNASSIGNED;

View File

@ -32,6 +32,7 @@ void setTestEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
engineConfiguration->useOnlyRisingEdgeForTrigger = false;
engineConfiguration->mafAdcChannel = EFI_ADC_1;
engineConfiguration->tps1_1AdcChannel = EFI_ADC_2;
engineConfiguration->vbattAdcChannel = EFI_ADC_NONE;
setWholeIatCorrTimingTable(0 PASS_CONFIG_PARAMETER_SUFFIX);

View File

@ -308,44 +308,7 @@ static void initTemperatureCurve(float *bins, float *values, int size, float def
void prepareVoidConfiguration(engine_configuration_s *engineConfiguration) {
efiAssertVoid(OBD_PCM_Processor_Fault, engineConfiguration != NULL, "ec NULL");
memset(engineConfiguration, 0, sizeof(engine_configuration_s));
// Now that GPIO_UNASSIGNED == 0 we do not really need explicit zero assignments since memset above does that
// todo: migrate 'EFI_ADC_NONE' to '0' and eliminate the need in this method altogether
for (int i = 0; i < FSIO_ANALOG_INPUT_COUNT ; i++) {
engineConfiguration->fsioAdc[i] = EFI_ADC_NONE;
}
engineConfiguration->clt.adcChannel = EFI_ADC_NONE;
engineConfiguration->iat.adcChannel = EFI_ADC_NONE;
engineConfiguration->cj125ua = EFI_ADC_NONE;
engineConfiguration->cj125ur = EFI_ADC_NONE;
engineConfiguration->auxTempSensor1.adcChannel = EFI_ADC_NONE;
engineConfiguration->auxTempSensor2.adcChannel = EFI_ADC_NONE;
engineConfiguration->baroSensor.hwChannel = EFI_ADC_NONE;
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_NONE;
engineConfiguration->throttlePedalPositionSecondAdcChannel = EFI_ADC_NONE;
engineConfiguration->oilPressure.hwChannel = EFI_ADC_NONE;
engineConfiguration->vRefAdcChannel = EFI_ADC_NONE;
engineConfiguration->vbattAdcChannel = EFI_ADC_NONE;
engineConfiguration->map.sensor.hwChannel = EFI_ADC_NONE;
engineConfiguration->mafAdcChannel = EFI_ADC_NONE;
/* this breaks unit tests lovely TODO: fix this?
engineConfiguration->tps1_1AdcChannel = EFI_ADC_NONE;
*/
engineConfiguration->tps1_2AdcChannel = EFI_ADC_NONE;
engineConfiguration->tps2_1AdcChannel = EFI_ADC_NONE;
engineConfiguration->tps2_2AdcChannel = EFI_ADC_NONE;
engineConfiguration->auxFastSensor1_adcChannel = EFI_ADC_NONE;
engineConfiguration->acSwitchAdc = EFI_ADC_NONE;
engineConfiguration->externalKnockSenseAdc = EFI_ADC_NONE;
engineConfiguration->fuelLevelSensor = EFI_ADC_NONE;
engineConfiguration->hipOutputChannel = EFI_ADC_NONE;
engineConfiguration->afr.hwChannel = EFI_ADC_NONE;
engineConfiguration->high_fuel_pressure_sensor_1 = EFI_ADC_NONE;
engineConfiguration->high_fuel_pressure_sensor_2 = EFI_ADC_NONE;
engineConfiguration->clutchDownPinMode = PI_PULLUP;
engineConfiguration->clutchUpPinMode = PI_PULLUP;
engineConfiguration->brakePedalPinMode = PI_PULLUP;

View File

@ -246,25 +246,26 @@ typedef enum __attribute__ ((__packed__))
*/
typedef enum __attribute__ ((__packed__)) {
EFI_ADC_0 = 0, // PA0
EFI_ADC_1 = 1, // PA1
EFI_ADC_2 = 2, // PA2
EFI_ADC_3 = 3, // PA3
EFI_ADC_4 = 4, // PA4
EFI_ADC_5 = 5, // PA5
EFI_ADC_6 = 6, // PA6
EFI_ADC_7 = 7, // PA7
EFI_ADC_8 = 8, // PB0
EFI_ADC_9 = 9, // PB1
EFI_ADC_10 = 10, // PC0
EFI_ADC_11 = 11, // PC1
EFI_ADC_12 = 12, // PC2
EFI_ADC_13 = 13, // PC3
EFI_ADC_14 = 14, // PC4
EFI_ADC_15 = 15, // PC5
EFI_ADC_NONE = 0,
EFI_ADC_0 = 1, // PA0
EFI_ADC_1 = 2, // PA1
EFI_ADC_2 = 3, // PA2
EFI_ADC_3 = 4, // PA3
EFI_ADC_4 = 5, // PA4
EFI_ADC_5 = 6, // PA5
EFI_ADC_6 = 7, // PA6
EFI_ADC_7 = 8, // PA7
EFI_ADC_8 = 9, // PB0
EFI_ADC_9 = 10, // PB1
EFI_ADC_10 = 11, // PC0
EFI_ADC_11 = 12, // PC1
EFI_ADC_12 = 13, // PC2
EFI_ADC_13 = 14, // PC3
EFI_ADC_14 = 15, // PC4
EFI_ADC_15 = 16, // PC5
// todo: bad choice of value since now we have ADC_CHANNEL_SENSOR and could end up with 17 and 18 also
EFI_ADC_NONE = 16,
EFI_ADC_ERROR = 17,
} adc_channel_e;

View File

@ -329,14 +329,16 @@ bool AdcDevice::isHwUsed(adc_channel_e hwChannelIndex) const {
void AdcDevice::enableChannel(adc_channel_e hwChannel) {
int logicChannel = channelCount++;
size_t channelAdcIndex = hwChannel - 1;
internalAdcIndexByHardwareIndex[hwChannel] = logicChannel;
hardwareIndexByIndernalAdcIndex[logicChannel] = hwChannel;
if (logicChannel < 6) {
hwConfig->sqr3 += (hwChannel) << (5 * logicChannel);
hwConfig->sqr3 += (channelAdcIndex) << (5 * logicChannel);
} else if (logicChannel < 12) {
hwConfig->sqr2 += (hwChannel) << (5 * (logicChannel - 6));
hwConfig->sqr2 += (channelAdcIndex) << (5 * (logicChannel - 6));
} else {
hwConfig->sqr1 += (hwChannel) << (5 * (logicChannel - 12));
hwConfig->sqr1 += (channelAdcIndex) << (5 * (logicChannel - 12));
}
// todo: support for more then 12 channels? not sure how needed it would be
}

View File

@ -65,7 +65,7 @@
! Any time an incompatible change is made to the configuration format stored in flash,
! update this string to the current date! It is required to also update TS_SIGNATURE above
! when this happens.
#define FLASH_DATA_VERSION 10001
#define FLASH_DATA_VERSION 10002
! all the sub-structures are going to be nested within the primary structure, that's
! needed to get a proper TunerStudio file
@ -338,7 +338,7 @@ custom air_pressure_sensor_type_e 4 bits, U32, @OFFSET@, [0:3] "Custom", "DENSO
!
! lower 16 values are used on stm32 rusEfi, values above 16 are related to Kinetis work in progress
!
#define adc_channel_e_enum "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "Disabled", "PB12", "PB13", "PC14", "PC15", "PC16", "PC17", "PD3", "PD4", "PE2", "PE6", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
#define adc_channel_e_enum "Disabled", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5"
custom adc_channel_e 1 bits, U08, @OFFSET@, [0:4] @@adc_channel_e_enum@@
struct air_pressure_sensor_config_s