diff --git a/firmware/config/boards/hellen/hellen154hyundai/board.mk b/firmware/config/boards/hellen/hellen154hyundai/board.mk index 990694b95d..6672150fee 100644 --- a/firmware/config/boards/hellen/hellen154hyundai/board.mk +++ b/firmware/config/boards/hellen/hellen154hyundai/board.mk @@ -10,14 +10,14 @@ endif DDEFS += -DEFI_MAIN_RELAY_CONTROL=TRUE -ifeq ($(PROJECT_CPU),ARCH_STM32F7) - DDEFS += -DCH_DBG_ENABLE_ASSERTS=FALSE - DDEFS += -DENABLE_PERF_TRACE=FALSE - USE_OPT += -Wl,--defsym=FLASH_SIZE=768k -endif + + + + + # Add them all together -DDEFS += -DFIRMWARE_ID=\"hellen154hyundai\" $(VAR_DEF_ENGINE_TYPE) +DDEFS += $(VAR_DEF_ENGINE_TYPE) DDEFS += -DEFI_SOFTWARE_KNOCK=TRUE -DSTM32_ADC_USE_ADC3=TRUE DDEFS += -DSTATIC_BOARD_ID=STATIC_BOARD_ID_HELLEN_154_HYUNDAI diff --git a/firmware/config/boards/hellen/hellen154hyundai_f7/board.mk b/firmware/config/boards/hellen/hellen154hyundai_f7/board.mk new file mode 100644 index 0000000000..259e757e7c --- /dev/null +++ b/firmware/config/boards/hellen/hellen154hyundai_f7/board.mk @@ -0,0 +1,25 @@ +# Combine the related files for a specific platform and MCU. + +# Target ECU board design +BOARDCPPSRC = $(BOARD_DIR)/board_configuration.cpp +# Set this if you want a default engine type other than normal +ifeq ($(VAR_DEF_ENGINE_TYPE),) + VAR_DEF_ENGINE_TYPE = -DDEFAULT_ENGINE_TYPE=engine_type_e::HELLEN_154_HYUNDAI_COUPE_BK2 +endif + +DDEFS += -DEFI_MAIN_RELAY_CONTROL=TRUE + + + + DDEFS += -DCH_DBG_ENABLE_ASSERTS=FALSE + DDEFS += -DENABLE_PERF_TRACE=FALSE + USE_OPT += -Wl,--defsym=FLASH_SIZE=768k + + +# Add them all together +DDEFS += $(VAR_DEF_ENGINE_TYPE) +DDEFS += -DEFI_SOFTWARE_KNOCK=TRUE -DSTM32_ADC_USE_ADC3=TRUE +DDEFS += -DSTATIC_BOARD_ID=STATIC_BOARD_ID_HELLEN_154_HYUNDAI + +include $(BOARDS_DIR)/hellen/hellen-common144.mk +DDEFS += -DHW_HELLEN_HYUNDAI=1 diff --git a/firmware/config/boards/hellen/hellen154hyundai_f7/board_configuration.cpp b/firmware/config/boards/hellen/hellen154hyundai_f7/board_configuration.cpp new file mode 100644 index 0000000000..1112ebcebb --- /dev/null +++ b/firmware/config/boards/hellen/hellen154hyundai_f7/board_configuration.cpp @@ -0,0 +1,194 @@ +/** + * @file boards/hellen/hellen154hyundai/board_configuration.cpp + * + * + * @brief Configuration defaults for the hellen154hyundai board + * + * See https://rusefi.com/s/hellen154hyundai + * + * @author andreika + * @author Andrey Belomutskiy, (c) 2012-2020 + */ + +#include "pch.h" +#include "defaults.h" +#include "hellen_meta.h" + +static void setInjectorPins() { + engineConfiguration->injectionPins[0] = Gpio::H144_LS_1; + engineConfiguration->injectionPins[1] = Gpio::H144_LS_2; + engineConfiguration->injectionPins[2] = Gpio::H144_LS_3; + engineConfiguration->injectionPins[3] = Gpio::H144_LS_4; +} + +static void setIgnitionPins() { + engineConfiguration->ignitionPins[0] = Gpio::H144_IGN_1; + engineConfiguration->ignitionPins[1] = Gpio::H144_IGN_2; + engineConfiguration->ignitionPins[2] = Gpio::H144_IGN_3; + engineConfiguration->ignitionPins[3] = Gpio::H144_IGN_4; +} + +static void setupDefaultSensorInputs() { + engineConfiguration->vvtMode[0] = VVT_SINGLE_TOOTH; + engineConfiguration->vvtMode[1] = VVT_SINGLE_TOOTH; + + engineConfiguration->vehicleSpeedSensorInputPin = Gpio::H144_IN_VSS; + + setTPS1Inputs(H144_IN_TPS, H144_IN_AUX1); + + setPPSInputs(EFI_ADC_3, EFI_ADC_14); + + engineConfiguration->map.sensor.hwChannel = H144_IN_MAP1; + + engineConfiguration->afr.hwChannel = EFI_ADC_NONE; + + engineConfiguration->clt.adcChannel = H144_IN_CLT; + + engineConfiguration->iat.adcChannel = H144_IN_IAT; +} + + + +static bool isFirstInvocation = true; + +int hackHellenBoardId(int detectedId) { + if (detectedId == BOARD_ID_VAG121_D) { + // wow something bad has happened to that batch of boards?! + return BOARD_ID_154HYUNDAI_C; + } + return detectedId; +} + +void setBoardConfigOverrides() { + setHellenVbatt(); + + setHellenSdCardSpi2(); + + setDefaultHellenAtPullUps(); + + // trigger inputs + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + // Direct hall-only cam input + // exhaust input same on both revisions + engineConfiguration->camInputs[1] = Gpio::H144_IN_D_AUX4; + + int16_t hellenBoardId = engine->engineState.hellenBoardId; + + if (hellenBoardId == -1) { + engineConfiguration->triggerInputPins[0] = Gpio::H144_IN_CRANK; + engineConfiguration->camInputs[0] = Gpio::H144_IN_CAM; + + // control pins are inverted since overall ECU pinout seems to be inverted + engineConfiguration->etbIo[0].directionPin1 = Gpio::H144_OUT_PWM3; + engineConfiguration->etbIo[0].directionPin2 = Gpio::H144_OUT_PWM2; + engineConfiguration->etbIo[0].controlPin = Gpio::H144_OUT_IO12; + engineConfiguration->etbIo[0].disablePin = Gpio::Unassigned; + 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; + engineConfiguration->etbIo[1].disablePin = Gpio::Unassigned; + + if (isFirstInvocation) { + isFirstInvocation = false; + efiSetPadMode("ETB FIX0", Gpio::H144_OUT_PWM4, PAL_MODE_INPUT_ANALOG); + efiSetPadMode("ETB FIX1", Gpio::H144_OUT_PWM5, PAL_MODE_INPUT_ANALOG); + efiSetPadMode("ETB FIX2", Gpio::H144_OUT_IO13, PAL_MODE_INPUT_ANALOG); + } + engineConfiguration->stepperDcInvertedPins = false; + } else if (hellenBoardId == BOARD_ID_154HYUNDAI_C || hellenBoardId == BOARD_ID_154HYUNDAI_D) { + engineConfiguration->triggerInputPins[0] = Gpio::H144_IN_SENS2; + engineConfiguration->camInputs[0] = Gpio::H144_IN_SENS3; + + + // todo You would not believe how you invert TLE9201 #4579 + engineConfiguration->stepperDcInvertedPins = true; + + //ETB1 + // PWM pin + engineConfiguration->etbIo[0].controlPin = Gpio::H144_OUT_PWM2; + // DIR pin + engineConfiguration->etbIo[0].directionPin1 = Gpio::H144_OUT_PWM3; + // Disable pin + engineConfiguration->etbIo[0].disablePin = Gpio::H144_OUT_IO12; + + // wastegate DC motor + //ETB2 + // PWM pin + engineConfiguration->etbIo[1].controlPin = Gpio::H144_OUT_PWM4; + // DIR pin + engineConfiguration->etbIo[1].directionPin1 = Gpio::H144_OUT_PWM5; + // Disable pin + engineConfiguration->etbIo[1].disablePin = Gpio::H144_OUT_IO13; + } +} + +/** + * @brief Board-specific configuration defaults. + * + * See also setDefaultEngineConfiguration + * + + */ +void setBoardDefaultConfiguration() { + setInjectorPins(); + setIgnitionPins(); + + setHellenCan(); + + engineConfiguration->fuelPumpPin = Gpio::H144_OUT_IO9; + engineConfiguration->fanPin = Gpio::H144_OUT_IO7; + engineConfiguration->mainRelayPin = Gpio::H144_OUT_IO3; // pin: 111a + // BK1 uses wire, BK2 uses CANbus + engineConfiguration->malfunctionIndicatorPin = Gpio::H144_OUT_PWM8; + + engineConfiguration->brakePedalPin = Gpio::H144_IN_RES3; + engineConfiguration->clutchUpPin = Gpio::H144_IN_RES2; + engineConfiguration->acSwitch = Gpio::H144_IN_RES1; + + // "required" hardware is done - set some reasonable defaults + setupDefaultSensorInputs(); + + engineConfiguration->etbFunctions[1] = DC_Wastegate; +} + +static Gpio OUTPUTS[] = { + Gpio::H144_LS_1, // 0: INJ_1 k25 + Gpio::H144_LS_2, // INJ_2 k26 + Gpio::H144_LS_3, // INJ_3 k27 + Gpio::H144_LS_4, // 3: INJ_4 k28 + Gpio::H144_LS_5, // VVT1 + Gpio::H144_LS_6, // 5: VVT2 + Gpio::H144_LS_7, // K47 BK1 Wastegate Solenoid + Gpio::H144_OUT_IO7, // Fan Relay Low + Gpio::H144_OUT_IO3, // Main Relay K64 + Gpio::H144_OUT_IO9, // Fuel Pump K70 + Gpio::H144_OUT_IO10, // 10: K87 AC Relay + Gpio::H144_OUT_IO8, // Fan Relay HI + Gpio::H144_IGN_1, // Coil 1 + Gpio::H144_IGN_2, // Coil 2 + Gpio::H144_IGN_3, // Coil 3 + Gpio::H144_IGN_4, // Coil 4 + Gpio::H144_OUT_PWM8, // MIL +// QC procedure seems to not work for that one Gpio::H144_OUT_PWM7, // low side? Tacho unused CAN tachometer right? +// Gpio::H_SPI1_SCK, // X8 AuxLS1 +}; + +int getBoardMetaOutputsCount() { + return efi::size(OUTPUTS); +} + +int getBoardMetaLowSideOutputsCount() { + return getBoardMetaOutputsCount(); +} + +int getBoardMetaDcOutputsCount() { + return 2; +} + +Gpio* getBoardMetaOutputs() { + return OUTPUTS; +} diff --git a/firmware/config/boards/hellen/hellen154hyundai/compile_hellen154hyundai_f7.sh b/firmware/config/boards/hellen/hellen154hyundai_f7/compile_hellen154hyundai_f7.sh similarity index 100% rename from firmware/config/boards/hellen/hellen154hyundai/compile_hellen154hyundai_f7.sh rename to firmware/config/boards/hellen/hellen154hyundai_f7/compile_hellen154hyundai_f7.sh diff --git a/firmware/config/boards/hellen/hellen154hyundai_f7/knock_config.h b/firmware/config/boards/hellen/hellen154hyundai_f7/knock_config.h new file mode 100644 index 0000000000..d03cdec9a4 --- /dev/null +++ b/firmware/config/boards/hellen/hellen154hyundai_f7/knock_config.h @@ -0,0 +1 @@ +#include "../hellen_knock_config.h" \ No newline at end of file diff --git a/firmware/config/boards/hellen/hellen154hyundai/meta-info-hellen154hyundai_f7.env b/firmware/config/boards/hellen/hellen154hyundai_f7/meta-info-hellen154hyundai_f7.env similarity index 82% rename from firmware/config/boards/hellen/hellen154hyundai/meta-info-hellen154hyundai_f7.env rename to firmware/config/boards/hellen/hellen154hyundai_f7/meta-info-hellen154hyundai_f7.env index f9e9992d2c..2063e56f25 100644 --- a/firmware/config/boards/hellen/hellen154hyundai/meta-info-hellen154hyundai_f7.env +++ b/firmware/config/boards/hellen/hellen154hyundai_f7/meta-info-hellen154hyundai_f7.env @@ -1,3 +1,2 @@ SHORT_BOARD_NAME=hellen154hyundai_f7 PROJECT_CPU=ARCH_STM32F7 -SKIP_RATE=90 diff --git a/firmware/config/boards/hellen/hellen154hyundai_f7/prepend.txt b/firmware/config/boards/hellen/hellen154hyundai_f7/prepend.txt new file mode 100644 index 0000000000..afa39053ee --- /dev/null +++ b/firmware/config/boards/hellen/hellen154hyundai_f7/prepend.txt @@ -0,0 +1,43 @@ +#define MAIN_HELP_URL "https://rusefi.com/s/hellen154hyuindai" + + + + +#define ts_show_vbatt false +#define ts_show_clt_iat_pullup false +#define ts_show_egt false + +#define ts_show_etb_pins false +#define ts_show_analog_divider false +#define ts_show_spi false +#define ts_show_sd_card true +#define ts_show_can_pins false +#define ts_show_tunerstudio_port false +#define ts_show_can2 false +#define ts_show_software_knock true +#define ts_show_hardware_simulator false +#define ts_show_sd_pins false +#define ts_show_ignitionPinMode false +#define ts_show_tps2 false +#define ts_show_speedo_settings false + +#define ts_show_bank2_cam1 false +#define ts_show_bank2_cam2 false + + +#define ts_show_starter_disable false +#define ts_show_fuel_pump false +#define ts_show_status_leds false +#define ts_show_idle_hardware false +#define ts_show_hd false +#define ts_show_odd_fire false +#define ts_show_rotary false +#define ts_show_cylinder_bank false +#define ts_show_maf false + +#define ts_show_cylinder_9 false +#define ts_show_cylinder_10 false +#define ts_show_cylinder_11 false +#define ts_show_cylinder_12 false + +#define show_Hellen_hyundai_154 true