2021-08-03 02:22:35 -07:00
|
|
|
/**
|
|
|
|
* @file boards/hellen/hellen121nissan/board_configuration.cpp
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @brief Configuration defaults for the hellen121nissan board
|
|
|
|
*
|
|
|
|
* See https://rusefi.com/s/hellen121nissan
|
|
|
|
*
|
|
|
|
* @author andreika <prometheus.pcb@gmail.com>
|
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
|
|
|
*/
|
|
|
|
|
2021-08-04 16:30:52 -07:00
|
|
|
#include "pch.h"
|
2021-09-29 08:47:04 -07:00
|
|
|
#include "custom_engine.h"
|
2021-12-30 16:14:32 -08:00
|
|
|
#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
|
|
|
|
|
|
|
|
|
|
|
// Disable remainder
|
2021-10-09 13:51:07 -07:00
|
|
|
for (int i = 4; i < MAX_CYLINDER_COUNT;i++) {
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->injectionPins[i] = Gpio::Unassigned;
|
2021-08-03 02:22:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
engineConfiguration->injectionPinMode = OM_DEFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setIgnitionPins() {
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->ignitionPins[0] = Gpio::C13;
|
|
|
|
engineConfiguration->ignitionPins[1] = Gpio::E5;
|
|
|
|
engineConfiguration->ignitionPins[2] = Gpio::E4;
|
|
|
|
engineConfiguration->ignitionPins[3] = Gpio::E3;
|
2021-08-03 02:22:35 -07:00
|
|
|
|
|
|
|
// disable remainder
|
2021-10-09 13:51:07 -07:00
|
|
|
for (int i = 4; i < MAX_CYLINDER_COUNT; i++) {
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->ignitionPins[i] = Gpio::Unassigned;
|
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() {
|
|
|
|
// trigger inputs
|
2021-10-10 18:46:58 -07:00
|
|
|
engineConfiguration->triggerInputPins[0] = H144_IN_CRANK;
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->triggerInputPins[1] = Gpio::Unassigned;
|
|
|
|
engineConfiguration->triggerInputPins[2] = Gpio::Unassigned;
|
2021-08-03 02:22:35 -07:00
|
|
|
// Direct hall-only cam input
|
2021-10-10 18:46:58 -07:00
|
|
|
engineConfiguration->camInputs[0] = H144_IN_CAM;
|
2021-10-12 18:03:59 -07:00
|
|
|
engineConfiguration->camInputs[1 * CAMS_PER_BANK] = H144_IN_D_AUX4;
|
|
|
|
|
2021-10-17 15:52:40 -07:00
|
|
|
engineConfiguration->vvtMode[0] = VVT_SECOND_HALF;
|
|
|
|
engineConfiguration->vvtMode[1 * CAMS_PER_BANK] = VVT_SECOND_HALF;
|
|
|
|
|
2021-10-12 18:03:59 -07:00
|
|
|
engineConfiguration->vehicleSpeedSensorInputPin = H144_IN_VSS;
|
2021-08-03 02:22:35 -07:00
|
|
|
|
2021-10-09 20:35:28 -07:00
|
|
|
engineConfiguration->tps1_1AdcChannel = H144_IN_TPS;
|
|
|
|
engineConfiguration->tps1_2AdcChannel = H144_IN_AUX1;
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->useETBforIdleControl = true;
|
2021-10-17 15:52:40 -07:00
|
|
|
|
|
|
|
engineConfiguration->throttlePedalUpVoltage = 0.73;
|
|
|
|
engineConfiguration->throttlePedalWOTVoltage = 4.0;
|
|
|
|
engineConfiguration->throttlePedalSecondaryUpVoltage = 0.34;
|
|
|
|
engineConfiguration->throttlePedalSecondaryWOTVoltage = 1.86;
|
2021-08-03 02:22:35 -07:00
|
|
|
|
|
|
|
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_3;
|
|
|
|
engineConfiguration->throttlePedalPositionSecondAdcChannel = 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
|
|
|
|
2021-10-14 15:07:35 -07:00
|
|
|
// engineConfiguration->auxTempSensor1.adcChannel = H144_IN_O2S2;
|
2021-08-03 02:22:35 -07:00
|
|
|
engineConfiguration->auxTempSensor2.adcChannel = EFI_ADC_NONE;
|
|
|
|
}
|
|
|
|
|
2022-04-13 21:13:30 -07:00
|
|
|
extern int hellenBoardId;
|
|
|
|
|
2022-04-21 21:44:44 -07:00
|
|
|
static bool isFirstInvocation = true;
|
|
|
|
|
2022-01-11 19:26:24 -08:00
|
|
|
void setBoardConfigOverrides() {
|
2021-09-29 08:47:04 -07:00
|
|
|
setHellen144LedPins();
|
2021-08-03 02:22:35 -07:00
|
|
|
setupVbatt();
|
|
|
|
setSdCardConfigurationOverrides();
|
|
|
|
|
|
|
|
engineConfiguration->clt.config.bias_resistor = 4700;
|
|
|
|
engineConfiguration->iat.config.bias_resistor = 4700;
|
2022-04-13 21:13:30 -07:00
|
|
|
|
|
|
|
if (hellenBoardId == 0) {
|
|
|
|
// first revision of did not have Hellen Board ID
|
|
|
|
// https://github.com/rusefi/hellen154hyundai/issues/55
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->etbIo[1].directionPin1 = Gpio::Unassigned;
|
|
|
|
engineConfiguration->etbIo[1].directionPin2 = Gpio::Unassigned;
|
|
|
|
engineConfiguration->etbIo[1].controlPin = Gpio::Unassigned;
|
2022-04-13 21:13:30 -07:00
|
|
|
|
2022-04-21 21:44:44 -07:00
|
|
|
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-04-13 21:13:30 -07:00
|
|
|
}
|
2021-08-03 02:22:35 -07:00
|
|
|
}
|
|
|
|
|
2022-01-11 19:26:24 -08:00
|
|
|
void setSerialConfigurationOverrides() {
|
2021-08-03 02:22:35 -07:00
|
|
|
engineConfiguration->useSerialPort = false;
|
2022-02-06 18:50:09 -08: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.
|
|
|
|
*/
|
2022-01-11 19:26:24 -08:00
|
|
|
void setBoardDefaultConfiguration() {
|
2021-08-03 02:22:35 -07:00
|
|
|
setInjectorPins();
|
|
|
|
setIgnitionPins();
|
|
|
|
|
|
|
|
engineConfiguration->displayLogicLevelsInEngineSniffer = true;
|
|
|
|
engineConfiguration->isSdCardEnabled = true;
|
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
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;
|
2022-04-28 14:32:39 -07:00
|
|
|
// 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
|
|
|
|
2021-12-17 13:33:43 -08: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();
|
|
|
|
|
2021-10-16 15:45:14 -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;
|
2021-10-09 20:35:28 -07:00
|
|
|
engineConfiguration->etbIo[0].controlPin = H144_OUT_IO12;
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->etb_use_two_wires = true;
|
2021-08-03 02:22:35 -07:00
|
|
|
|
2021-10-09 20:35:28 -07:00
|
|
|
// wastegate DC motor
|
|
|
|
engineConfiguration->etbIo[1].directionPin1 = H144_OUT_PWM4;
|
|
|
|
engineConfiguration->etbIo[1].directionPin2 = H144_OUT_PWM5;
|
|
|
|
engineConfiguration->etbIo[1].controlPin = H144_OUT_IO13;
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->etb_use_two_wires = true;
|
|
|
|
engineConfiguration->etbFunctions[1] = ETB_Wastegate;
|
2021-10-09 20:35:28 -07:00
|
|
|
|
2021-08-03 02:22:35 -07:00
|
|
|
// Some sensible defaults for other options
|
2022-04-02 23:21:37 -07:00
|
|
|
setCrankOperationMode();
|
2021-08-03 02:22:35 -07:00
|
|
|
|
|
|
|
engineConfiguration->vvtCamSensorUseRise = true;
|
|
|
|
engineConfiguration->useOnlyRisingEdgeForTrigger = true;
|
2021-11-16 01:15:29 -08:00
|
|
|
setAlgorithm(LM_SPEED_DENSITY);
|
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;
|
2021-11-17 00:54:21 -08:00
|
|
|
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
|
|
|
|
engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS;
|
|
|
|
engineConfiguration->injectionMode = IM_SIMULTANEOUS;//IM_BATCH;// IM_SEQUENTIAL;
|
|
|
|
|
2021-10-16 15:45:14 -07:00
|
|
|
// very similar to Nissan?
|
|
|
|
engineConfiguration->tpsMin = 100;
|
|
|
|
engineConfiguration->tpsMax = 914;
|
|
|
|
|
|
|
|
engineConfiguration->tps1SecondaryMin = 880;
|
|
|
|
engineConfiguration->tps1SecondaryMax = 68;
|
2021-08-03 02:22:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Board-specific SD card configuration code overrides. Needed by bootloader code.
|
|
|
|
* @todo Add your board-specific code, if any.
|
|
|
|
*/
|
2022-01-11 19:26:24 -08:00
|
|
|
void setSdCardConfigurationOverrides() {
|
2021-10-17 20:15:23 -07:00
|
|
|
engineConfiguration->sdCardSpiDevice = SPI_DEVICE_2;
|
|
|
|
|
|
|
|
engineConfiguration->spi2mosiPin = H_SPI2_MOSI;
|
|
|
|
engineConfiguration->spi2misoPin = H_SPI2_MISO;
|
|
|
|
engineConfiguration->spi2sckPin = H_SPI2_SCK;
|
|
|
|
engineConfiguration->sdCardCsPin = H_SPI2_CS;
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->is_enabled_spi_2 = true;
|
2021-08-03 02:22:35 -07:00
|
|
|
}
|