reducing code duplication?
This commit is contained in:
parent
196337a8de
commit
1703152427
|
@ -208,11 +208,11 @@ void setCitroenBerlingoTU3JPConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
// engineConfiguration->mafAdcChannel = GPIO_UNASSIGNED;
|
||||
|
||||
#if DEFAULT_FUEL_LOAD_COUNT == FUEL_LOAD_COUNT
|
||||
copyFuelTable(tps_fuel_table, config->fuelTable);
|
||||
MEMCPY(config->fuelTable, tps_fuel_table);
|
||||
#endif
|
||||
|
||||
#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT
|
||||
copyTimingTable(default_tps_advance_table, config->ignitionTable);
|
||||
MEMCPY(config->ignitionTable, default_tps_advance_table);
|
||||
#endif
|
||||
|
||||
engineConfiguration->dizzySparkOutputPin = GPIOE_3;
|
||||
|
|
|
@ -276,15 +276,15 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
* set_whole_fuel_map 12
|
||||
*/
|
||||
//setWholeFuelMap(12 PASS_CONFIG_PARAMETER_SUFFIX);
|
||||
// copyFuelTable(alphaNfuel, config->fuelTable);
|
||||
// MEMCPY(config->fuelTable, alphaNfuel);
|
||||
//setWholeTimingTable_d(12 PASS_CONFIG_PARAMETER_SUFFIX);
|
||||
#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT
|
||||
copyTimingTable(fromODB, config->ignitionTable);
|
||||
MEMCPY(config->ignitionTable, fromODB);
|
||||
#endif
|
||||
|
||||
copy2DTable<FSIO_TABLE_8, FSIO_TABLE_8, float, float>(vBattTarget, config->fsioTable1);
|
||||
|
||||
copyFuelTable(veDodgeNeon2003Table, config->veTable);
|
||||
MEMCPY(config->veTable, veDodgeNeon2003Table);
|
||||
//setMap(config->veTable, 50);
|
||||
|
||||
// set cranking_charge_angle 70
|
||||
|
|
|
@ -78,10 +78,10 @@ static void setDefaultAspireMaps(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
setTimingRpmBin(800, 7000 PASS_CONFIG_PARAMETER_SUFFIX);
|
||||
|
||||
#if DEFAULT_FUEL_LOAD_COUNT == FUEL_LOAD_COUNT
|
||||
copyFuelTable(default_aspire_fuel_table, config->fuelTable);
|
||||
MEMCPY(config->fuelTable, default_aspire_fuel_table);
|
||||
#endif
|
||||
#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT
|
||||
copyTimingTable(default_aspire_timing_table, config->ignitionTable);
|
||||
MEMCPY(config->ignitionTable, default_aspire_timing_table);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ void setFordEscortGt(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
copyArray(config->veRpmBins, veRpmBins);
|
||||
|
||||
|
||||
copyFuelTable(racingFestivaVeTable, config->veTable);
|
||||
MEMCPY(config->veTable, racingFestivaVeTable);
|
||||
|
||||
// engineConfiguration->triggerInputPins[0] = GPIOC_6; // 2G YEL/BLU
|
||||
// engineConfiguration->triggerInputPins[1] = GPIOA_5; // 2E White CKP
|
||||
|
@ -281,7 +281,7 @@ void setFordEscortGt(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
copyArray(config->ignitionRpmBins, ignitionRpmBins);
|
||||
|
||||
#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT
|
||||
copyTimingTable(racingFestivaIgnitionTable, config->ignitionTable);
|
||||
MEMCPY(config->ignitionTable, racingFestivaIgnitionTable);
|
||||
#endif
|
||||
|
||||
engineConfiguration->tpsAccelEnrichmentThreshold = 40;
|
||||
|
|
|
@ -56,10 +56,9 @@ static void setDefaultCustomMaps(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
setTimingLoadBin(0,100 PASS_CONFIG_PARAMETER_SUFFIX);
|
||||
setTimingRpmBin(0,7000 PASS_CONFIG_PARAMETER_SUFFIX);
|
||||
|
||||
copyFuelTable(default_custom_fuel_table, config->fuelTable);
|
||||
copyFuelTable(default_custom_fuel_table, config->veTable);
|
||||
MEMCPY(config->fuelTable, default_custom_fuel_table);
|
||||
#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT
|
||||
copyTimingTable(default_custom_timing_table, config->ignitionTable);
|
||||
MEMCPY(config->ignitionTable, default_custom_timing_table);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -243,11 +243,11 @@ static void setMiata1994_common(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
engineConfiguration->crankingChargeAngle = 70;
|
||||
|
||||
#if DEFAULT_FUEL_LOAD_COUNT == FUEL_LOAD_COUNT
|
||||
copyFuelTable(miataNA8_maf_fuel_table, config->fuelTable);
|
||||
MEMCPY(config->fuelTable, miataNA8_maf_fuel_table);
|
||||
#endif
|
||||
|
||||
#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT
|
||||
copyTimingTable(miataNA8_maf_advance_table, config->ignitionTable);
|
||||
MEMCPY(config->ignitionTable, miataNA8_maf_advance_table);
|
||||
#endif
|
||||
|
||||
// engineConfiguration->triggerSimulatorPins[0] = GPIOD_2; // 2G - YEL/BLU
|
||||
|
@ -335,10 +335,10 @@ void setMiata1996(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
engineConfiguration->specs.displacement = 1.839;
|
||||
|
||||
#if DEFAULT_FUEL_LOAD_COUNT == FUEL_LOAD_COUNT
|
||||
copyFuelTable(miataNA8_maf_fuel_table, config->fuelTable);
|
||||
MEMCPY(config->fuelTable, miataNA8_maf_fuel_table);
|
||||
#endif
|
||||
#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT
|
||||
copyTimingTable(miataNA8_maf_advance_table, config->ignitionTable);
|
||||
MEMCPY(config->ignitionTable, miataNA8_maf_advance_table);
|
||||
#endif
|
||||
|
||||
// upside down
|
||||
|
|
|
@ -112,15 +112,15 @@ void setMazdaMiata2003EngineConfigurationNaFuelRail(DECLARE_CONFIG_PARAMETER_SIG
|
|||
config->fsioTable1[loadIndex][rpmIndex] = fsio_table_dyno[loadIndex][rpmIndex];
|
||||
}
|
||||
}
|
||||
memcpy(config->veRpmBins, mazda_miata_nb2_RpmBins, sizeof(mazda_miata_nb2_RpmBins));
|
||||
memcpy(config->veLoadBins, mazda_miata_nb2_LoadBins, sizeof(mazda_miata_nb2_LoadBins));
|
||||
copyFuelTable(mapBased18vvtVeTable_NA_fuel_rail, config->veTable);
|
||||
MEMCPY(config->veRpmBins, mazda_miata_nb2_RpmBins);
|
||||
MEMCPY(config->veLoadBins, mazda_miata_nb2_LoadBins);
|
||||
MEMCPY(config->veTable, mapBased18vvtVeTable_NA_fuel_rail);
|
||||
|
||||
engineConfiguration->vvtOffset = 83; // 2002 green car value
|
||||
|
||||
memcpy(config->afrRpmBins, mazda_miata_nb2_targetAfrRpmBins, sizeof(mazda_miata_nb2_targetAfrRpmBins));
|
||||
memcpy(config->afrLoadBins, mazda_miata_nb2_targetAfrLoadBins, sizeof(mazda_miata_nb2_targetAfrLoadBins));
|
||||
copyTargetAfrTable(target_AFR_hunchback, config->afrTable);
|
||||
MEMCPY(config->afrRpmBins, mazda_miata_nb2_targetAfrRpmBins);
|
||||
MEMCPY(config->afrLoadBins, mazda_miata_nb2_targetAfrLoadBins);
|
||||
MEMCPY(config->afrTable, target_AFR_hunchback);
|
||||
|
||||
engineConfiguration->ignitionPins[2] = GPIOC_7;
|
||||
|
||||
|
|
|
@ -335,14 +335,14 @@ static void setMazdaMiataEngineNB2Defaults(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
engineConfiguration->vvtMode = MIATA_NB2;
|
||||
engineConfiguration->vvtOffset = 98; // 2003 red car value
|
||||
|
||||
memcpy(config->veRpmBins, mazda_miata_nb2_RpmBins, sizeof(mazda_miata_nb2_RpmBins));
|
||||
memcpy(config->veLoadBins, mazda_miata_nb2_LoadBins, sizeof(mazda_miata_nb2_LoadBins));
|
||||
copyFuelTable(mapBased18vvtVeTable_NB_fuel_rail, config->veTable);
|
||||
MEMCPY(config->veRpmBins, mazda_miata_nb2_RpmBins);
|
||||
MEMCPY(config->veLoadBins, mazda_miata_nb2_LoadBins);
|
||||
MEMCPY(config->veTable, mapBased18vvtVeTable_NB_fuel_rail);
|
||||
|
||||
memcpy(config->ignitionRpmBins, ignition18vvtRpmBins, sizeof(ignition18vvtRpmBins));
|
||||
memcpy(config->ignitionLoadBins, ignition18vvtLoadBins, sizeof(ignition18vvtLoadBins));
|
||||
MEMCPY(config->ignitionRpmBins, ignition18vvtRpmBins);
|
||||
MEMCPY(config->ignitionLoadBins, ignition18vvtLoadBins);
|
||||
#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT
|
||||
copyTimingTable(mapBased18vvtTimingTable, config->ignitionTable);
|
||||
MEMCPY(config->ignitionTable, mapBased18vvtTimingTable);
|
||||
#endif
|
||||
|
||||
setMazdaNB2VVTSettings(PASS_CONFIG_PARAMETER_SIGNATURE);
|
||||
|
|
|
@ -278,8 +278,8 @@ size_t getMultiSparkCount(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
void setDefaultIatTimingCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
setLinearCurve(config->ignitionIatCorrLoadBins, /*from*/CLT_CURVE_RANGE_FROM, 110, 1);
|
||||
#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT
|
||||
memcpy(config->ignitionIatCorrRpmBins, iatTimingRpmBins, sizeof(iatTimingRpmBins));
|
||||
copyTimingTable(defaultIatTiming, config->ignitionIatCorrTable);
|
||||
MEMCPY(config->ignitionIatCorrRpmBins, iatTimingRpmBins);
|
||||
MEMCPY(config->ignitionIatCorrTable, defaultIatTiming);
|
||||
#else
|
||||
setLinearCurve(config->ignitionIatCorrLoadBins, /*from*/0, 6000, 1);
|
||||
#endif /* IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT */
|
||||
|
|
|
@ -1515,33 +1515,6 @@ void setFrankenso0_1_joystick(engine_configuration_s *engineConfiguration) {
|
|||
engineConfiguration->joystickDPin = GPIOD_11;
|
||||
}
|
||||
|
||||
void copyTargetAfrTable(fuel_table_t const source, afr_table_t destination) {
|
||||
// todo: extract a template!
|
||||
for (int loadIndex = 0; loadIndex < FUEL_LOAD_COUNT; loadIndex++) {
|
||||
for (int rpmIndex = 0; rpmIndex < FUEL_RPM_COUNT; rpmIndex++) {
|
||||
destination[loadIndex][rpmIndex] = AFR_STORAGE_MULT * source[loadIndex][rpmIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void copyFuelTable(fuel_table_t const source, fuel_table_t destination) {
|
||||
// todo: extract a template!
|
||||
for (int loadIndex = 0; loadIndex < FUEL_LOAD_COUNT; loadIndex++) {
|
||||
for (int rpmIndex = 0; rpmIndex < FUEL_RPM_COUNT; rpmIndex++) {
|
||||
destination[loadIndex][rpmIndex] = source[loadIndex][rpmIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void copyTimingTable(ignition_table_t const source, ignition_table_t destination) {
|
||||
// todo: extract a template!
|
||||
for (int k = 0; k < IGN_LOAD_COUNT; k++) {
|
||||
for (int rpmIndex = 0; rpmIndex < IGN_RPM_COUNT; rpmIndex++) {
|
||||
destination[k][rpmIndex] = source[k][rpmIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const ConfigOverrides defaultConfigOverrides{};
|
||||
// This symbol is weak so that a board_configuration.cpp file can override it
|
||||
__attribute__((weak)) const ConfigOverrides& getConfigOverrides() {
|
||||
|
|
|
@ -55,10 +55,6 @@ void setFrankenso0_1_joystick(engine_configuration_s *engineConfiguration);
|
|||
|
||||
#define MEMCPY(dest, src) {memcpy(dest, src, sizeof(src));}
|
||||
|
||||
void copyTargetAfrTable(fuel_table_t const source, afr_table_t destination);
|
||||
void copyFuelTable(fuel_table_t const source, fuel_table_t destination);
|
||||
void copyTimingTable(ignition_table_t const source, ignition_table_t destination);
|
||||
|
||||
void emptyCallbackWithConfiguration(engine_configuration_s * engine);
|
||||
void setDefaultFrankensoConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE);
|
||||
|
||||
|
|
Loading…
Reference in New Issue