From 3c0f961bc3cdb28e76dcf7ddb7c2aeeae99affd6 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Mon, 11 Oct 2021 20:51:05 -0400 Subject: [PATCH] hellen88bmw --- .github/workflows/build-firmware.yaml | 6 +- .../config/boards/hellen/hellen88bmw/board.mk | 39 ++++ .../hellen88bmw/board_configuration.cpp | 201 ++++++++++++++++++ .../hellen/hellen88bmw/compile_hellen88bmw.sh | 8 + .../hellen/hellen88bmw/connectors/main.yaml | 5 + .../boards/hellen/hellen88bmw/knock_config.h | 1 + .../boards/hellen/hellen88bmw/prepend.txt | 27 +++ firmware/gen_config.sh | 1 + 8 files changed, 287 insertions(+), 1 deletion(-) create mode 100644 firmware/config/boards/hellen/hellen88bmw/board.mk create mode 100644 firmware/config/boards/hellen/hellen88bmw/board_configuration.cpp create mode 100755 firmware/config/boards/hellen/hellen88bmw/compile_hellen88bmw.sh create mode 100644 firmware/config/boards/hellen/hellen88bmw/connectors/main.yaml create mode 100644 firmware/config/boards/hellen/hellen88bmw/knock_config.h create mode 100644 firmware/config/boards/hellen/hellen88bmw/prepend.txt diff --git a/.github/workflows/build-firmware.yaml b/.github/workflows/build-firmware.yaml index 24af3aa6d4..4a636f17e8 100644 --- a/.github/workflows/build-firmware.yaml +++ b/.github/workflows/build-firmware.yaml @@ -16,7 +16,7 @@ jobs: # see also gen_config where we have a similar list for all boards! # see also build-primary-bundle where default/primary bundle is build separately # - build-target: [hellen72, hellen-nb1, hellenNA6, hellen128, hellen121vag, hellen121nissan, cypress, frankenso_na6, kinetis, mre_f4, mre_f4_recovery, mre_f4_hardware_QC_special_build, mre_f7, prometheus_405, prometheus_469, proteus_f4, proteus_f4_hardware_QC_special_build, proteus_f7, proteus_f7_hardware_QC_special_build, proteus_h7, proteus_legacy, stm32f767_nucleo, stm32h743_nucleo, subaru_eg33_f7, atlas] + build-target: [hellen72, hellen88bmw, hellen-nb1, hellenNA6, hellen128, hellen121vag, hellen121nissan, cypress, frankenso_na6, kinetis, mre_f4, mre_f4_recovery, mre_f4_hardware_QC_special_build, mre_f7, prometheus_405, prometheus_469, proteus_f4, proteus_f4_hardware_QC_special_build, proteus_f7, proteus_f7_hardware_QC_special_build, proteus_h7, proteus_legacy, stm32f767_nucleo, stm32h743_nucleo, subaru_eg33_f7, atlas] include: # Board configurations @@ -24,6 +24,10 @@ jobs: folder: hellen/hellen72 ini-file: rusefi_hellen72.ini + - build-target: hellen88bmw + folder: hellen/hellen88bmw + ini-file: rusefi_hellen88bmw.ini + - build-target: hellen-nb1 folder: hellen/hellen-nb1 ini-file: rusefi_hellen-nb1.ini diff --git a/firmware/config/boards/hellen/hellen88bmw/board.mk b/firmware/config/boards/hellen/hellen88bmw/board.mk new file mode 100644 index 0000000000..9b7e6cfff5 --- /dev/null +++ b/firmware/config/boards/hellen/hellen88bmw/board.mk @@ -0,0 +1,39 @@ +# Combine the related files for a specific platform and MCU. + +# Target ECU board design +BOARDCPPSRC = $(BOARDS_DIR)/hellen/hellen88bmw/board_configuration.cpp +BOARDINC = $(BOARDS_DIR)/hellen/hellen88bmw + +# Set this if you want a default engine type other than normal hellen88bmw +ifeq ($(DEFAULT_ENGINE_TYPE),) + DEFAULT_ENGINE_TYPE = -DDEFAULT_ENGINE_TYPE=HELLEN_88_BMW +endif + +# 144 package MCU +ifeq ($(LED_CRITICAL_ERROR_BRAIN_PIN),) + LED_CRITICAL_ERROR_BRAIN_PIN = -DLED_CRITICAL_ERROR_BRAIN_PIN=GPIOG_0 +endif + +DDEFS += -DEFI_MAIN_RELAY_CONTROL=TRUE + +DDEFS += -DLED_ERROR_BRAIN_PIN_MODE=INVERTED_OUTPUT +DDEFS += -DLED_RUNING_BRAIN_PIN_MODE=INVERTED_OUTPUT +DDEFS += -DLED_WARNING_BRAIN_PIN_MODE=INVERTED_OUTPUT +DDEFS += -DLED_COMMUNICATION_BRAIN_PIN_MODE=INVERTED_OUTPUT + +# Disable serial ports on this board as UART3 causes a DMA conflict with the SD card +DDEFS += -DTS_NO_PRIMARY -DTS_NO_SECONDARY + +# Add them all together +DDEFS += -DEFI_USE_OSC=TRUE -DFIRMWARE_ID=\"hellen88bmw\" $(DEFAULT_ENGINE_TYPE) $(LED_CRITICAL_ERROR_BRAIN_PIN) $(LED_COMMUNICATION_BRAIN_PIN) +DDEFS += -DEFI_SOFTWARE_KNOCK=TRUE -DSTM32_ADC_USE_ADC3=TRUE +DDEFS += -DEFI_ICU_INPUTS=FALSE -DHAL_TRIGGER_USE_PAL=TRUE -DHAL_VSS_USE_PAL=TRUE +# todo: is it broken? +DDEFS += -DEFI_LOGIC_ANALYZER=FALSE + +# We are running on Hellen-One hardware! +DDEFS += -DHW_HELLEN=1 + +# Shared variables +ALLCPPSRC += $(BOARDCPPSRC) +ALLINC += $(BOARDINC) diff --git a/firmware/config/boards/hellen/hellen88bmw/board_configuration.cpp b/firmware/config/boards/hellen/hellen88bmw/board_configuration.cpp new file mode 100644 index 0000000000..426d0cc41c --- /dev/null +++ b/firmware/config/boards/hellen/hellen88bmw/board_configuration.cpp @@ -0,0 +1,201 @@ +/** + * @file boards/hellen/hellen121nissan/board_configuration.cpp + * + * + * @brief Configuration defaults for the hellen121nissan board + * + * See https://rusefi.com/s/hellen121nissan + * + * @author andreika + * @author Andrey Belomutskiy, (c) 2012-2020 + */ + +#include "pch.h" +#include "fsio_impl.h" +#include "custom_engine.h" +#include "../hellen_meta.h" + +static void hellenWbo() { + engineConfiguration->enableAemXSeries = true; +} + +static void setInjectorPins() { + engineConfiguration->injectionPins[0] = H144_LS_1; + engineConfiguration->injectionPins[1] = H144_LS_2; + engineConfiguration->injectionPins[2] = H144_LS_3; + engineConfiguration->injectionPins[3] = H144_LS_4; + engineConfiguration->injectionPins[4] = H144_LS_5; + engineConfiguration->injectionPins[5] = H144_LS_6; + + // Disable remainder + for (int i = 6; i < MAX_CYLINDER_COUNT;i++) { + engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + } + + engineConfiguration->injectionPinMode = OM_DEFAULT; +} + +static void setIgnitionPins() { + engineConfiguration->ignitionPins[0] = GPIOC_13; + engineConfiguration->ignitionPins[1] = GPIOE_5; + engineConfiguration->ignitionPins[2] = GPIOE_4; + engineConfiguration->ignitionPins[3] = GPIOE_3; + engineConfiguration->ignitionPins[4] = GPIOE_2; + engineConfiguration->ignitionPins[5] = GPIOB_8; + + // disable remainder + for (int i = 6; i < MAX_CYLINDER_COUNT; i++) { + engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + } + + 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 + engineConfiguration->triggerInputPins[0] = H144_IN_CRANK; + engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + // Direct hall-only cam input + engineConfiguration->camInputs[0] = H144_IN_CAM; + // todo: remove from default since 4 cylinder does not use it + // todo: this requires unit test change + engineConfiguration->camInputs[1 * CAMS_PER_BANK] = H144_IN_D_AUX4; + + engineConfiguration->tps1_1AdcChannel = H144_IN_TPS; + engineConfiguration->tps1_2AdcChannel = H144_IN_AUX1; + + engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_3; + engineConfiguration->throttlePedalPositionSecondAdcChannel = EFI_ADC_14; + engineConfiguration->mafAdcChannel = EFI_ADC_10; + engineConfiguration->map.sensor.hwChannel = EFI_ADC_11; + + engineConfiguration->afr.hwChannel = EFI_ADC_1; + + engineConfiguration->clt.adcChannel = H144_IN_CLT; + + engineConfiguration->iat.adcChannel = H144_IN_IAT; + + engineConfiguration->auxTempSensor1.adcChannel = EFI_ADC_NONE; + engineConfiguration->auxTempSensor2.adcChannel = EFI_ADC_NONE; +} + +void setBoardConfigOverrides(void) { + setHellen144LedPins(); + setupVbatt(); + setSdCardConfigurationOverrides(); + + engineConfiguration->clt.config.bias_resistor = 4700; + engineConfiguration->iat.config.bias_resistor = 4700; +} + +void setPinConfigurationOverrides(void) { +} + +void setSerialConfigurationOverrides(void) { + engineConfiguration->useSerialPort = false; + engineConfiguration->binarySerialTxPin = GPIO_UNASSIGNED; + engineConfiguration->binarySerialRxPin = GPIO_UNASSIGNED; +// engineConfiguration->consoleSerialTxPin = GPIO_UNASSIGNED; +// engineConfiguration->consoleSerialRxPin = GPIO_UNASSIGNED; +} + + +/** + * @brief Board-specific configuration defaults. + * + * See also setDefaultEngineConfiguration + * + * @todo Add your board-specific code, if any. + */ +void setBoardDefaultConfiguration(void) { + setInjectorPins(); + setIgnitionPins(); + + engineConfiguration->displayLogicLevelsInEngineSniffer = true; + engineConfiguration->isSdCardEnabled = true; + + CONFIG(enableSoftwareKnock) = true; + CONFIG(canNbcType) = CAN_BUS_NISSAN_VQ; + + engineConfiguration->canTxPin = GPIOD_1; + engineConfiguration->canRxPin = GPIOD_0; + + engineConfiguration->fuelPumpPin = GPIOD_12; // OUT_IO9 // 113 Fuel Pump Relay + engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; +// engineConfiguration->fanPin = GPIOD_12; // OUT_PWM8 + engineConfiguration->mainRelayPin = GPIOG_14; // pin: 111a, OUT_IO3 + + // "required" hardware is done - set some reasonable defaults + setupDefaultSensorInputs(); + + engineConfiguration->etbIo[0].directionPin1 = GPIOD_15; // out_pwm7 + engineConfiguration->etbIo[0].directionPin2 = GPIOD_14; // out_pwm6 + engineConfiguration->etbIo[0].controlPin = GPIOD_13; // ETB_EN out_pwm1 + CONFIG(etb_use_two_wires) = true; + + // Some sensible defaults for other options + setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR); + + engineConfiguration->vvtCamSensorUseRise = true; + engineConfiguration->useOnlyRisingEdgeForTrigger = true; + setAlgorithm(LM_SPEED_DENSITY PASS_CONFIG_PARAMETER_SUFFIX); + + + // Bosch VQ40 VR56 VK56 0280158007 + engineConfiguration->injector.flow = 296.2; + + strcpy(CONFIG(engineMake), ENGINE_MAKE_NISSAN); + + engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK + engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; + engineConfiguration->injectionMode = IM_SIMULTANEOUS;//IM_BATCH;// IM_SEQUENTIAL; + + engineConfiguration->luaOutputPins[0] = GPIOG_5; // 104 ETB Relay + + engineConfiguration->throttlePedalUpVoltage = 0.75; + engineConfiguration->throttlePedalWOTVoltage = 4.45; + engineConfiguration->throttlePedalSecondaryUpVoltage = 0.43; + engineConfiguration->throttlePedalSecondaryWOTVoltage = 2.20; + + // this calibration reminds me of VAG just flipped? + engineConfiguration->tpsMin = 100; + engineConfiguration->tpsMax = 889; + + engineConfiguration->tps1SecondaryMin = 891; + engineConfiguration->tps1SecondaryMax = 102; + hellenWbo(); +} + +/** + * @brief Board-specific SD card configuration code overrides. Needed by bootloader code. + * @todo Add your board-specific code, if any. + */ +void setSdCardConfigurationOverrides(void) { + engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3; + + engineConfiguration->spi3mosiPin = GPIOC_12; + engineConfiguration->spi3misoPin = GPIOC_11; + engineConfiguration->spi3sckPin = GPIOC_10; + engineConfiguration->sdCardCsPin = GPIOA_15; + +// engineConfiguration->spi2mosiPin = GPIOB_15; +// engineConfiguration->spi2misoPin = GPIOB_14; +// engineConfiguration->spi2sckPin = GPIOB_13; +// engineConfiguration->sdCardCsPin = GPIOB_12; + CONFIG(is_enabled_spi_3) = true; +} diff --git a/firmware/config/boards/hellen/hellen88bmw/compile_hellen88bmw.sh b/firmware/config/boards/hellen/hellen88bmw/compile_hellen88bmw.sh new file mode 100755 index 0000000000..80476aeb4e --- /dev/null +++ b/firmware/config/boards/hellen/hellen88bmw/compile_hellen88bmw.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +export PROJECT_BOARD=hellen/hellen88bmw +export PROJECT_CPU=ARCH_STM32F4 +export EXTRA_PARAMS="-DSHORT_BOARD_NAME=hellen88bmw" + +cd .. +bash ../common_make.sh diff --git a/firmware/config/boards/hellen/hellen88bmw/connectors/main.yaml b/firmware/config/boards/hellen/hellen88bmw/connectors/main.yaml new file mode 100644 index 0000000000..c5c84ab8e8 --- /dev/null +++ b/firmware/config/boards/hellen/hellen88bmw/connectors/main.yaml @@ -0,0 +1,5 @@ +pins: + +info: + title: Hellen 88 BMW + pins: diff --git a/firmware/config/boards/hellen/hellen88bmw/knock_config.h b/firmware/config/boards/hellen/hellen88bmw/knock_config.h new file mode 100644 index 0000000000..c885793985 --- /dev/null +++ b/firmware/config/boards/hellen/hellen88bmw/knock_config.h @@ -0,0 +1 @@ +#include "hellen_knock_config.h" \ No newline at end of file diff --git a/firmware/config/boards/hellen/hellen88bmw/prepend.txt b/firmware/config/boards/hellen/hellen88bmw/prepend.txt new file mode 100644 index 0000000000..4ba09f48fe --- /dev/null +++ b/firmware/config/boards/hellen/hellen88bmw/prepend.txt @@ -0,0 +1,27 @@ +#define MAIN_HELP_URL "https://rusefi.com/s/hellen121nissan" + +#define ts_show_hip9011 false +#define ts_show_cj125 false + +//Jokeri says it's better with full pinout just in case +//#define ts_show_full_pinout false + +#define ts_show_lcd false +#define ts_show_joystick false +#define ts_show_egt false +#define ts_show_gps false +#define ts_show_etb_pins false +#define ts_show_analog_divider false +#define ts_show_spi true +#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 show_test_presets false +#define show_Frankenso_presets false +#define show_microRusEFI_presets false +#define show_Proteus_presets false +#define show_Hellen88bmw_presets true diff --git a/firmware/gen_config.sh b/firmware/gen_config.sh index 92d1794107..f8b8ac8ab9 100755 --- a/firmware/gen_config.sh +++ b/firmware/gen_config.sh @@ -22,6 +22,7 @@ for BOARD in \ "hellen/hellen121vag hellen121vag" \ "hellen/hellen121nissan hellen121nissan" \ "hellen/hellen154hyundai hellen154hyundai" \ + "hellen/hellen88bmw hellen88bmw" \ "hellen/hellen72 hellen72" \ "hellen/hellen-nb1 hellen-nb1" \ "hellen/hellen64_miataNA6_94 hellenNA6" \