rusefi/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp

195 lines
6.0 KiB
C++
Raw Normal View History

2021-08-03 02:22:35 -07:00
/**
2022-09-13 17:23:40 -07:00
* @file boards/hellen/hellen154hyundai/board_configuration.cpp
2021-08-03 02:22:35 -07:00
*
*
2022-09-13 17:23:40 -07:00
* @brief Configuration defaults for the hellen154hyundai board
2021-08-03 02:22:35 -07:00
*
2022-09-13 17:23:40 -07:00
* See https://rusefi.com/s/hellen154hyundai
2021-08-03 02:22:35 -07:00
*
* @author andreika <prometheus.pcb@gmail.com>
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "pch.h"
2022-10-29 20:38:22 -07:00
#include "defaults.h"
#include "hellen_meta.h"
2021-08-03 02:22:35 -07:00
static void setInjectorPins() {
2021-10-09 13:51:07 -07:00
engineConfiguration->injectionPins[0] = H144_LS_1;
engineConfiguration->injectionPins[1] = H144_LS_2;
engineConfiguration->injectionPins[2] = H144_LS_3;
engineConfiguration->injectionPins[3] = H144_LS_4;
2021-08-03 02:22:35 -07:00
engineConfiguration->injectionPinMode = OM_DEFAULT;
}
static void setIgnitionPins() {
2023-01-21 00:01:44 -08:00
engineConfiguration->ignitionPins[0] = H144_IGN_1;
engineConfiguration->ignitionPins[1] = H144_IGN_2;
engineConfiguration->ignitionPins[2] = H144_IGN_3;
engineConfiguration->ignitionPins[3] = H144_IGN_4;
2021-08-03 02:22:35 -07:00
engineConfiguration->ignitionPinMode = OM_DEFAULT;
}
static void setupVbatt() {
// 4.7k high side/4.7k low side = 2.0 ratio divider
engineConfiguration->analogInputDividerCoefficient = 2.0f;
// set vbatt_divider 5.835
// 33k / 6.8k
engineConfiguration->vbattDividerCoeff = (33 + 6.8) / 6.8; // 5.835
// pin input +12 from Main Relay
engineConfiguration->vbattAdcChannel = EFI_ADC_5; // 4T
engineConfiguration->adcVcc = 3.29f;
}
static void setupDefaultSensorInputs() {
2021-10-17 15:52:40 -07:00
engineConfiguration->vvtMode[0] = VVT_SECOND_HALF;
engineConfiguration->vvtMode[1] = VVT_SECOND_HALF;
2021-10-17 15:52:40 -07:00
2021-10-12 18:03:59 -07:00
engineConfiguration->vehicleSpeedSensorInputPin = H144_IN_VSS;
2021-08-03 02:22:35 -07:00
2022-10-29 21:20:15 -07:00
setTPS1Inputs(H144_IN_TPS, H144_IN_AUX1);
2021-10-17 15:52:40 -07:00
2022-11-04 09:37:28 -07:00
setPPSCalibration(0.73, 4.0, 0.34, 1.86);
2021-08-03 02:22:35 -07:00
2022-10-29 20:38:22 -07:00
setPPSInputs(EFI_ADC_3, EFI_ADC_14);
2021-10-12 18:03:59 -07:00
engineConfiguration->mafAdcChannel = EFI_ADC_NONE;
engineConfiguration->map.sensor.hwChannel = H144_IN_MAP1;
2021-08-03 02:22:35 -07:00
2021-10-12 18:03:59 -07:00
engineConfiguration->afr.hwChannel = EFI_ADC_NONE;
2021-08-03 02:22:35 -07:00
2021-10-09 20:35:28 -07:00
engineConfiguration->clt.adcChannel = H144_IN_CLT;
2021-08-03 02:22:35 -07:00
2021-10-09 20:35:28 -07:00
engineConfiguration->iat.adcChannel = H144_IN_IAT;
2021-08-03 02:22:35 -07:00
}
static bool isFirstInvocation = true;
void setBoardConfigOverrides() {
setHellen144LedPins();
2021-08-03 02:22:35 -07:00
setupVbatt();
2022-06-23 06:15:51 -07:00
setHellenSdCardSpi2();
2021-08-03 02:22:35 -07:00
2023-02-15 12:01:41 -08:00
setDefaultHellenAtPullUps();
// trigger inputs
engineConfiguration->triggerInputPins[1] = Gpio::Unassigned;
// Direct hall-only cam input
// exhaust input same on both revisions
engineConfiguration->camInputs[1] = H144_IN_D_AUX4;
if (engine->engineState.hellenBoardId == -1) {
engineConfiguration->triggerInputPins[0] = H144_IN_CRANK;
engineConfiguration->camInputs[0] = H144_IN_CAM;
2022-09-13 17:23:40 -07:00
// control pins are inverted since overall ECU pinout seems to be inverted
engineConfiguration->etbIo[0].directionPin1 = H144_OUT_PWM3;
engineConfiguration->etbIo[0].directionPin2 = H144_OUT_PWM2;
engineConfiguration->etbIo[0].controlPin = H144_OUT_IO12;
engineConfiguration->etb_use_two_wires = true;
// first revision of did not have Hellen Board ID
// https://github.com/rusefi/hellen154hyundai/issues/55
engineConfiguration->etbIo[1].directionPin1 = Gpio::Unassigned;
engineConfiguration->etbIo[1].directionPin2 = Gpio::Unassigned;
engineConfiguration->etbIo[1].controlPin = Gpio::Unassigned;
if (isFirstInvocation) {
isFirstInvocation = false;
efiSetPadMode("ETB FIX0", H144_OUT_PWM4, PAL_MODE_INPUT_ANALOG);
efiSetPadMode("ETB FIX1", H144_OUT_PWM5, PAL_MODE_INPUT_ANALOG);
efiSetPadMode("ETB FIX2", H144_OUT_IO13, PAL_MODE_INPUT_ANALOG);
}
2022-09-13 15:13:58 -07:00
} else if (engine->engineState.hellenBoardId == BOARD_ID_154hyundai_c) {
engineConfiguration->triggerInputPins[0] = H144_IN_SENS2;
engineConfiguration->camInputs[0] = H144_IN_SENS3;
// todo You would not believe how you invert TLE9201 #4579
engineConfiguration->stepperDcInvertedPins = true;
2022-09-13 15:13:58 -07:00
//ETB1
// PWM pin
engineConfiguration->etbIo[0].controlPin = H144_OUT_PWM2;
// DIR pin
engineConfiguration->etbIo[0].directionPin1 = H144_OUT_PWM3;
// Disable pin
engineConfiguration->etbIo[0].disablePin = H144_OUT_IO12;
// Unused
engineConfiguration->etbIo[0].directionPin2 = Gpio::Unassigned;
2022-09-13 17:23:40 -07:00
// wastegate DC motor
2022-09-13 15:13:58 -07:00
//ETB2
// PWM pin
engineConfiguration->etbIo[1].controlPin = H144_OUT_PWM4;
// DIR pin
engineConfiguration->etbIo[1].directionPin1 = H144_OUT_PWM5;
// Disable pin
engineConfiguration->etbIo[1].disablePin = H144_OUT_IO13;
// Unused
engineConfiguration->etbIo[1].directionPin2 = Gpio::Unassigned;
2022-09-13 17:23:40 -07:00
}
2021-08-03 02:22:35 -07:00
}
/**
* @brief Board-specific configuration defaults.
*
* See also setDefaultEngineConfiguration
*
* @todo Add your board-specific code, if any.
*/
void setBoardDefaultConfiguration() {
2021-08-03 02:22:35 -07:00
setInjectorPins();
setIgnitionPins();
engineConfiguration->displayLogicLevelsInEngineSniffer = true;
engineConfiguration->enableSoftwareKnock = true;
engineConfiguration->canNbcType = CAN_BUS_GENESIS_COUPE;
2021-08-03 02:22:35 -07:00
2021-10-09 13:51:07 -07:00
engineConfiguration->canTxPin = H176_CAN_TX;
engineConfiguration->canRxPin = H176_CAN_RX;
2021-08-03 02:22:35 -07:00
2021-10-16 15:45:14 -07:00
engineConfiguration->fuelPumpPin = H144_OUT_IO9;
// engineConfiguration->idle.solenoidPin = Gpio::D14; // OUT_PWM5
// engineConfiguration->fanPin = Gpio::D12; // OUT_PWM8
engineConfiguration->mainRelayPin = Gpio::G14; // pin: 111a, OUT_IO3
2021-10-09 20:35:28 -07:00
engineConfiguration->malfunctionIndicatorPin = H144_OUT_PWM8;
2021-08-03 02:22:35 -07:00
engineConfiguration->brakePedalPin = H144_IN_RES3;
engineConfiguration->clutchUpPin = H144_IN_RES2;
engineConfiguration->acSwitch = H144_IN_RES1;
2021-08-03 02:22:35 -07:00
// "required" hardware is done - set some reasonable defaults
setupDefaultSensorInputs();
2023-02-18 19:39:45 -08:00
engineConfiguration->etbFunctions[1] = DC_Wastegate;
2021-10-09 20:35:28 -07:00
2021-08-03 02:22:35 -07:00
// Some sensible defaults for other options
setCrankOperationMode();
2021-08-03 02:22:35 -07:00
setAlgorithm(LM_SPEED_DENSITY);
2021-08-03 02:22:35 -07:00
2022-11-04 10:27:40 -07:00
setEtbPID(8.8944, 70.2307, 0.1855);
2021-08-03 02:22:35 -07:00
2021-10-09 13:51:07 -07:00
engineConfiguration->injectorCompensationMode = ICM_FixedRailPressure;
engineConfiguration->specs.cylindersCount = 4;
engineConfiguration->specs.firingOrder = FO_1_3_4_2;
engineConfiguration->specs.displacement = 1.998;
strcpy(engineConfiguration->engineMake, ENGINE_MAKE_Hyundai);
strcpy(engineConfiguration->engineCode, "Theta II");
2021-10-17 15:52:40 -07:00
engineConfiguration->globalTriggerAngleOffset = 90;
2021-08-03 02:22:35 -07:00
engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK
2023-01-21 05:08:52 -08:00
2021-08-03 02:22:35 -07:00
2022-11-04 09:37:28 -07:00
setTPS1Calibration(98, 926, 891, 69);
2021-08-03 02:22:35 -07:00
}