From 0f47cff952085eb86329bf5399ed7355c6ad0981 Mon Sep 17 00:00:00 2001 From: Andrey G Date: Sat, 6 Feb 2021 21:50:34 +0300 Subject: [PATCH] Add subaru eg33 (#2294) * engine: Subaru SVX EG33 engine configuration Not tested yet. Just basic settings and placeholder * board: add Dron_Gus's Subaru EG33 p'n'p board * board: subaru eg33: linker script: stack, bss and heap to ram0 * board: subaru eg33: add mapping.yaml * board: subaru eg33: scripts for autogenerated * board: subaru eg33: fix DMA conflict (ADC1 vs SPI5) * board: subaru eg33: enable ADC3 * board: subaru eg33: Autogenerated * board: subaru eg33: disable fsio control of Main Relay Default MAIN_RELAY_LOGIC cause error during parsing * board: subaru eg33: configuration hack to fix usbconsole.c * gen_config: generate config for Subaru SVX board too --- .../config/boards/subaru_eg33/STM32F76xxI.ld | 136 ++ firmware/config/boards/subaru_eg33/board.c | 298 ++++ firmware/config/boards/subaru_eg33/board.h | 49 + firmware/config/boards/subaru_eg33/board.mk | 37 + .../subaru_eg33/board_configuration.cpp | 246 +++ firmware/config/boards/subaru_eg33/board_io.h | 991 +++++++++++ firmware/config/boards/subaru_eg33/config.mk | 2 + .../controllers/algo/auto_generated_enums.cpp | 1531 +++++++++++++++++ .../controllers/algo/auto_generated_enums.h | 59 + .../boards/subaru_eg33/config/gen_config.sh | 49 + .../subaru_eg33/config/gen_enum_to_string.sh | 15 + .../config/tunerstudio/subaru_eg33_prefix.txt | 4 + .../config/boards/subaru_eg33/efifeatures.h | 145 ++ firmware/config/boards/subaru_eg33/halconf.h | 41 + firmware/config/boards/subaru_eg33/make.sh | 15 + .../config/boards/subaru_eg33/mapping.yaml | 92 + firmware/config/boards/subaru_eg33/mcuconf.h | 94 + .../config/boards/subaru_eg33/prepend.txt | 18 + firmware/config/boards/subaru_eg33/readme.txt | 4 + .../boards/subaru_eg33/rusefi_hw_enums.h | 294 ++++ firmware/config/engines/subaru.cpp | 57 + firmware/config/engines/subaru.h | 1 + .../controllers/algo/engine_configuration.cpp | 5 + firmware/controllers/algo/rusefi_enums.h | 1 + .../generated/signature_subaru_eg33_f7.h | 8 + firmware/gen_config.sh | 2 +- 26 files changed, 4193 insertions(+), 1 deletion(-) create mode 100644 firmware/config/boards/subaru_eg33/STM32F76xxI.ld create mode 100644 firmware/config/boards/subaru_eg33/board.c create mode 100644 firmware/config/boards/subaru_eg33/board.h create mode 100644 firmware/config/boards/subaru_eg33/board.mk create mode 100644 firmware/config/boards/subaru_eg33/board_configuration.cpp create mode 100644 firmware/config/boards/subaru_eg33/board_io.h create mode 100644 firmware/config/boards/subaru_eg33/config.mk create mode 100644 firmware/config/boards/subaru_eg33/config/controllers/algo/auto_generated_enums.cpp create mode 100644 firmware/config/boards/subaru_eg33/config/controllers/algo/auto_generated_enums.h create mode 100755 firmware/config/boards/subaru_eg33/config/gen_config.sh create mode 100755 firmware/config/boards/subaru_eg33/config/gen_enum_to_string.sh create mode 100644 firmware/config/boards/subaru_eg33/config/tunerstudio/subaru_eg33_prefix.txt create mode 100644 firmware/config/boards/subaru_eg33/efifeatures.h create mode 100644 firmware/config/boards/subaru_eg33/halconf.h create mode 100755 firmware/config/boards/subaru_eg33/make.sh create mode 100644 firmware/config/boards/subaru_eg33/mapping.yaml create mode 100644 firmware/config/boards/subaru_eg33/mcuconf.h create mode 100644 firmware/config/boards/subaru_eg33/prepend.txt create mode 100644 firmware/config/boards/subaru_eg33/readme.txt create mode 100644 firmware/config/boards/subaru_eg33/rusefi_hw_enums.h create mode 100644 firmware/controllers/generated/signature_subaru_eg33_f7.h diff --git a/firmware/config/boards/subaru_eg33/STM32F76xxI.ld b/firmware/config/boards/subaru_eg33/STM32F76xxI.ld new file mode 100644 index 0000000000..a239c4fe4a --- /dev/null +++ b/firmware/config/boards/subaru_eg33/STM32F76xxI.ld @@ -0,0 +1,136 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* + * STM32F76xxI generic setup. + * + * RAM0 - Data, Heap. + * RAM3 - Main Stack, Process Stack, BSS, NOCACHE, ETH. + * + * Notes: + * BSS is placed in DTCM RAM in order to simplify DMA buffers management. + */ +MEMORY +{ + flash0 (rx) : org = 0x08000000, len = 2M /* Flash as AXIM (writable) */ + flash1 (rx) : org = 0x00200000, len = 2M /* Flash as ITCM */ + flash2 (rx) : org = 0x00000000, len = 0 + flash3 (rx) : org = 0x00000000, len = 0 + flash4 (rx) : org = 0x00000000, len = 0 + flash5 (rx) : org = 0x00000000, len = 0 + flash6 (rx) : org = 0x00000000, len = 0 + flash7 (rx) : org = 0x00000000, len = 0 + ram0 (wx) : org = 0x20020000, len = 384k /* SRAM1 + SRAM2 */ + ram1 (wx) : org = 0x20020000, len = 368k /* SRAM1 */ + ram2 (wx) : org = 0x2007C000, len = 16k /* SRAM2 */ + ram3 (wx) : org = 0x20000000, len = 128k /* DTCM-RAM */ + ram4 (wx) : org = 0x00000000, len = 16k /* ITCM-RAM */ + ram5 (wx) : org = 0x40024000, len = 4k /* BCKP SRAM */ + ram6 (wx) : org = 0x00000000, len = 0 + ram7 (wx) : org = 0x00000000, len = 0 +} + +/* For each data/text section two region are defined, a virtual region + and a load region (_LMA suffix).*/ + +/* Flash region to be used for exception vectors.*/ +REGION_ALIAS("VECTORS_FLASH", flash1); +REGION_ALIAS("VECTORS_FLASH_LMA", flash0); + +/* Flash region to be used for constructors and destructors.*/ +REGION_ALIAS("XTORS_FLASH", flash1); +REGION_ALIAS("XTORS_FLASH_LMA", flash0); + +/* Flash region to be used for code text.*/ +REGION_ALIAS("TEXT_FLASH", flash1); +REGION_ALIAS("TEXT_FLASH_LMA", flash0); + +/* Flash region to be used for read only data.*/ +REGION_ALIAS("RODATA_FLASH", flash0); +REGION_ALIAS("RODATA_FLASH_LMA", flash0); + +/* Flash region to be used for various.*/ +REGION_ALIAS("VARIOUS_FLASH", flash1); +REGION_ALIAS("VARIOUS_FLASH_LMA", flash0); + +/* Flash region to be used for RAM(n) initialization data.*/ +REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0); + +/* RAM region to be used for Main stack. This stack accommodates the processing + of all exceptions and interrupts.*/ +REGION_ALIAS("MAIN_STACK_RAM", ram0); + +/* RAM region to be used for the process stack. This is the stack used by + the main() function.*/ +REGION_ALIAS("PROCESS_STACK_RAM", ram0); + +/* RAM region to be used for data segment.*/ +REGION_ALIAS("DATA_RAM", ram0); +REGION_ALIAS("DATA_RAM_LMA", flash0); + +/* RAM region to be used for BSS segment.*/ +REGION_ALIAS("BSS_RAM", ram0); + +/* RAM region to be used for the default heap.*/ +REGION_ALIAS("HEAP_RAM", ram0); + +/* Stack rules inclusion.*/ +INCLUDE rules_stacks.ld + +/*===========================================================================*/ +/* Custom sections for STM32F7xx. */ +/*===========================================================================*/ + +/* RAM region to be used for nocache segment.*/ +REGION_ALIAS("NOCACHE_RAM", ram3); + +/* RAM region to be used for eth segment.*/ +REGION_ALIAS("ETH_RAM", ram3); + +SECTIONS +{ + /* Special section for non cache-able areas.*/ + .nocache (NOLOAD) : ALIGN(4) + { + __nocache_base__ = .; + *(.nocache) + *(.nocache.*) + *(.bss.__nocache_*) + . = ALIGN(4); + __nocache_end__ = .; + } > NOCACHE_RAM + + /* Special section for Ethernet DMA non cache-able areas.*/ + .eth (NOLOAD) : ALIGN(4) + { + __eth_base__ = .; + *(.eth) + *(.eth.*) + *(.bss.__eth_*) + . = ALIGN(4); + __eth_end__ = .; + } > ETH_RAM +} + +/* Code rules inclusion.*/ +INCLUDE rules_code.ld + +/* Data rules inclusion.*/ +INCLUDE rules_data.ld + +/* Memory rules inclusion.*/ +INCLUDE rules_memory.ld + diff --git a/firmware/config/boards/subaru_eg33/board.c b/firmware/config/boards/subaru_eg33/board.c new file mode 100644 index 0000000000..4a648bdd94 --- /dev/null +++ b/firmware/config/boards/subaru_eg33/board.c @@ -0,0 +1,298 @@ +/** + * @file boards/subaru_eg33/board.c + * + * @date Feb 06, 2021 + * @author Andrey Gusakov, 2021 + */ + +#include "hal.h" +#include "stm32_gpio.h" +#include "efilib.h" +#include "rusefi_hw_enums.h" + +#include "board_io.h" + +#include "drivers/gpio/mc33810.h" + +/* drivers */ + +/*==========================================================================*/ +/* Driver local definitions. */ +/*==========================================================================*/ + +/*==========================================================================*/ +/* Driver exported variables. */ +/*==========================================================================*/ + +/*==========================================================================*/ +/* Driver local variables and types. */ +/*==========================================================================*/ + +/** + * @brief Type of STM32 GPIO port setup. + */ +typedef struct { + uint32_t moder; + uint32_t otyper; + uint32_t ospeedr; + uint32_t pupdr; + uint32_t odr; + uint32_t afrl; + uint32_t afrh; +} gpio_setup_t; + +/** + * @brief Type of STM32 GPIO initialization data. + */ +typedef struct { + gpio_setup_t PAData; + gpio_setup_t PBData; + gpio_setup_t PCData; + gpio_setup_t PDData; + gpio_setup_t PEData; + gpio_setup_t PFData; + gpio_setup_t PGData; + gpio_setup_t PHData; + gpio_setup_t PIData; +} gpio_config_t; + +/** + * @brief STM32 GPIO static initialization data. + */ +static const gpio_config_t gpio_default_config = { + {VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR, + VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH}, + {VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR, + VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH}, + {VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR, + VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH}, + {VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR, + VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH}, + {VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR, + VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH}, + {VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR, + VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH}, + {VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR, + VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH}, + {VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR, + VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH}, + {VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR, + VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH}, +}; + +/*==========================================================================*/ +/* Driver local functions. */ +/*==========================================================================*/ + +static void gpio_init(stm32_gpio_t *gpiop, const gpio_setup_t *config) { + + gpiop->OTYPER = config->otyper; + gpiop->OSPEEDR = config->ospeedr; + gpiop->PUPDR = config->pupdr; + gpiop->ODR = config->odr; + gpiop->AFRL = config->afrl; + gpiop->AFRH = config->afrh; + gpiop->MODER = config->moder; +} + +static void stm32_gpio_init(void) { + + /* Enabling GPIO-related clocks, the mask comes from the + * registry header file.*/ + rccResetAHB1(STM32_GPIO_EN_MASK); + rccEnableAHB1(STM32_GPIO_EN_MASK, true); + + /* Initializing all the defined GPIO ports.*/ + gpio_init(GPIOA, &gpio_default_config.PAData); + gpio_init(GPIOB, &gpio_default_config.PBData); + gpio_init(GPIOC, &gpio_default_config.PCData); + gpio_init(GPIOD, &gpio_default_config.PDData); + gpio_init(GPIOE, &gpio_default_config.PEData); + gpio_init(GPIOF, &gpio_default_config.PFData); + gpio_init(GPIOG, &gpio_default_config.PGData); + gpio_init(GPIOH, &gpio_default_config.PHData); + gpio_init(GPIOI, &gpio_default_config.PIData); +} + +/*==========================================================================*/ +/* Driver interrupt handlers. */ +/*==========================================================================*/ + +/*==========================================================================*/ +/* Driver exported functions. */ +/*==========================================================================*/ + +/** + * @brief Early initialization code. + * @details GPIO ports and system clocks are initialized before everything + * else. + */ +void __early_init(void) +{ + /* allow debug in all low-power modes */ + DBGMCU->CR |= DBGMCU_CR_DBG_SLEEP | DBGMCU_CR_DBG_STOP | DBGMCU_CR_DBG_STANDBY; + + stm32_gpio_init(); + stm32_clock_init(); +} + +#if HAL_USE_SDC || defined(__DOXYGEN__) +/** + * @brief SDC card detection. + */ +bool sdc_lld_is_card_inserted(SDCDriver *sdcp) +{ + UNUSED(sdcp); + /* TODO: Fill the implementation.*/ + return true; +} + +/** + * @brief SDC card write protection detection. + */ +bool sdc_lld_is_write_protected(SDCDriver *sdcp) +{ + UNUSED(sdcp); + /* TODO: Fill the implementation.*/ + return false; +} +#endif /* HAL_USE_SDC */ + +#if HAL_USE_MMC_SPI || defined(__DOXYGEN__) +/** + * @brief MMC_SPI card detection. + */ +bool mmc_lld_is_card_inserted(MMCDriver *mmcp) +{ + UNUSED(mmcp); + /* TODO: Fill the implementation.*/ + return true; +} + +/** + * @brief MMC_SPI card write protection detection. + */ +bool mmc_lld_is_write_protected(MMCDriver *mmcp) +{ + UNUSED(mmcp); + /* TODO: Fill the implementation.*/ + return false; +} +#endif + +/** + * @brief Board-specific ADC channel configuration code overrides. + * @todo Add your board-specific code, if any. + */ +void setAdcChannelOverrides(void) { +} + +#define STATUS_LED_PIN 8 +#define STATUS_LED_PORT GPIOG + +void BLIIINK(int t) { + int i, j; + palSetPadMode(STATUS_LED_PORT, STATUS_LED_PIN, PAL_MODE_OUTPUT_PUSHPULL); + //while (true) { + for (j = 0; j < 2; j++) { + palClearPad(STATUS_LED_PORT, STATUS_LED_PIN); + for (i = 0; i < 2 * t; i++) { + palTogglePad(STATUS_LED_PORT, STATUS_LED_PIN); + chThdSleepMilliseconds(250); + } + chThdSleepMilliseconds(1000); + } +} + +static const struct mc33810_config mc33810_odd = { + .spi_bus = &SPID5, + .spi_config = { + .circular = false, + .end_cb = NULL, + .ssport = GPIOF, + .sspad = 1, + .cr1 = + //SPI_CR1_16BIT_MODE | + SPI_CR1_SSM | + SPI_CR1_SSI | + ((3 << SPI_CR1_BR_Pos) & SPI_CR1_BR) | /* div = 16 */ + SPI_CR1_MSTR | + /* SPI_CR1_CPOL | */ // = 0 + SPI_CR1_CPHA | // = 1 + 0, + .cr2 = //SPI_CR2_16BIT_MODE | + SPI_CR2_DS_3 | SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0 + }, + .direct_io = { + /* injector drivers */ + [0] = {.port = GPIOI, .pad = 6}, /* INJ 1 */ + [1] = {.port = GPIOI, .pad = 5}, /* INJ 3 */ + [2] = {.port = GPIOI, .pad = 4}, /* INJ 5 */ + [3] = {.port = GPIOB, .pad = 9}, /* INJ 7 */ + /* ignition pre-dirvers */ + [4] = {.port = GPIOB, .pad = 3}, /* IGN 1 */ + [5] = {.port = GPIOB, .pad = 4}, /* IGN 3 */ + [6] = {.port = GPIOB, .pad = 5}, /* IGN 7 */ + [7] = {.port = GPIOB, .pad = 8}, /* IGN 5 */ + }, + /* en shared between two chips */ + .en = {.port = GPIOI, .pad = 7} +}; + +static const struct mc33810_config mc33810_even = { + .spi_bus = &SPID5, + .spi_config = { + .circular = false, + .end_cb = NULL, + .ssport = GPIOF, + .sspad = 2, + .cr1 = + //SPI_CR1_16BIT_MODE | + SPI_CR1_SSM | + SPI_CR1_SSI | + ((3 << SPI_CR1_BR_Pos) & SPI_CR1_BR) | /* div = 16 */ + SPI_CR1_MSTR | + /* SPI_CR1_CPOL | */ // = 0 + SPI_CR1_CPHA | // = 1 + 0, + .cr2 = //SPI_CR2_16BIT_MODE | + SPI_CR2_DS_3 | SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0 + }, + .direct_io = { + /* injector drivers */ + [0] = {.port = GPIOE, .pad = 3}, /* INJ 2 */ + [1] = {.port = GPIOE, .pad = 4}, /* INJ 4 */ + [2] = {.port = GPIOE, .pad = 5}, /* INJ 6 */ + [3] = {.port = GPIOE, .pad = 6}, /* INJ 8 */ + /* ignition pre-dirvers */ + [4] = {.port = GPIOC, .pad = 14}, /* IGN 2 */ + [5] = {.port = GPIOC, .pad = 13}, /* IGN 4 */ + [6] = {.port = GPIOC, .pad = 15}, /* IGN 6 */ + [7] = {.port = GPIOI, .pad = 9}, /* IGN 8 */ + }, + /* en shared between two chips */ + //.en = {.port = GPIOI, .pad = 7} +}; + +static void board_init_ext_gpios(void) +{ + int ret; + + ret = mc33810_add(MC33810_0_OUT_0, 0, &mc33810_odd); + if (ret < 0) { + /* error */ + } + ret = mc33810_add(MC33810_1_OUT_0, 1, &mc33810_even); + if (ret < 0) { + /* error */ + } +} + +/** + * @brief Board-specific initialization code. + * @todo Add your board-specific code, if any. + */ +void boardInit(void) +{ + board_init_ext_gpios(); +} diff --git a/firmware/config/boards/subaru_eg33/board.h b/firmware/config/boards/subaru_eg33/board.h new file mode 100644 index 0000000000..005fa73fee --- /dev/null +++ b/firmware/config/boards/subaru_eg33/board.h @@ -0,0 +1,49 @@ +/** + * @file boards/subaru_eg33/board.c + * + * @date Feb 06, 2021 + * @author Andrey Gusakov, 2021 + */ + +#ifndef BOARD_H +#define BOARD_H + +/* + * Board identifier. + */ +#define BOARD_NAME "Subaru EG33/STM32F765 for RusEFI" + +#define EFI_USB_AF 10U +//#define EFI_USB_SERIAL_ID GPIOA_10 +#define EFI_USB_SERIAL_DM GPIOA_11 +#define EFI_USB_SERIAL_DP GPIOA_12 + +/* + * Board oscillators-related settings. + * NOTE: LSE not fitted. + */ +#if !defined(STM32_LSECLK) +#define STM32_LSECLK 32768U +#endif + +#define STM32_LSEDRV (3U << 3U) + +#if !defined(STM32_HSECLK) +#define STM32_HSECLK 25000000U +#endif + +/* + * Board voltages. + * Required for performance limits calculation. + */ +#define STM32_VDD 330U + +/* + * MCU type as defined in the ST header. + * this declaration for stm32_registry.h + */ +#ifndef STM32F765xx +#define STM32F765xx +#endif + +#endif /* BOARD_H */ diff --git a/firmware/config/boards/subaru_eg33/board.mk b/firmware/config/boards/subaru_eg33/board.mk new file mode 100644 index 0000000000..6e66e53210 --- /dev/null +++ b/firmware/config/boards/subaru_eg33/board.mk @@ -0,0 +1,37 @@ +BOARD_DIR = $(PROJECT_DIR)/config/boards/$(PROJECT_BOARD) + +# List of all the board related files. +BOARDSRC = $(BOARD_DIR)/board.c +BOARDCPPSRC = $(BOARD_DIR)/board_configuration.cpp + +# Required include directories +BOARDINC = $(BOARD_DIR) +BOARDINC += $(BOARD_DIR)/config/controllers/algo + +# Override LD script +ifeq ($(USE_BOOTLOADER),yes) + # include Prometheus bootloader code + BOOTLOADERINC = $(PROJECT_DIR)/bootloader/subaru_eg33 +endif + +LDSCRIPT = $(BOARD_DIR)/STM32F76xxI.ld + +#FIX THIS +CONFIGPATH = $(PROJECT_DIR)/config/stm32f7ems + +CONFDIR = config/stm32f7ems + +#LED +LED_CRITICAL_ERROR_BRAIN_PIN = -DLED_CRITICAL_ERROR_BRAIN_PIN=GPIOG_7 + +# We are running on Subaru EG33 hardware! +DDEFS += -DHW_SUBARU_EG33=1 + +# Override DEFAULT_ENGINE_TYPE +# Fix +DDEFS += -DDEFAULT_ENGINE_TYPE=SUBARUEG33_DEFAULTS -DSTM32F765xx $(LED_CRITICAL_ERROR_BRAIN_PIN) + +# Shared variables +ALLCSRC += $(BOARDSRC) +ALLCPPSRC += $(BOARDCPPSRC) +ALLINC += $(BOARDINC) diff --git a/firmware/config/boards/subaru_eg33/board_configuration.cpp b/firmware/config/boards/subaru_eg33/board_configuration.cpp new file mode 100644 index 0000000000..92b2e3a522 --- /dev/null +++ b/firmware/config/boards/subaru_eg33/board_configuration.cpp @@ -0,0 +1,246 @@ +/** + * @file boards/subaru_eg33/board_configuration.h + * + * @brief In this file we can override engine_configuration.cpp. + * + * @date Feb 06, 2021 + * @author Andrey Gusakov, 2021 + */ + +#include "global.h" +#include "engine.h" +#include "engine_math.h" +#include "allsensors.h" +#include "fsio_impl.h" +#include "engine_configuration.h" +#include "smart_gpio.h" + +EXTERN_ENGINE; + +void setPinConfigurationOverrides(void) { + +} + +void setSerialConfigurationOverrides(void) { + engineConfiguration->useSerialPort = false; + engineConfiguration->binarySerialTxPin = GPIOE_1; + engineConfiguration->binarySerialRxPin = GPIOE_0; + /* actually Bluetooth/WiFi interface */ + //engineConfiguration->consoleSerialTxPin = GPIOC_10; + //engineConfiguration->consoleSerialRxPin = GPIOC_11; + engineConfiguration->tunerStudioSerialSpeed = SERIAL_SPEED; + engineConfiguration->uartConsoleSerialSpeed = SERIAL_SPEED; +} + +void setSdCardConfigurationOverrides(void) { + engineConfiguration->is_enabled_spi_1 = false; + engineConfiguration->sdCardSpiDevice = SPI_DEVICE_1; + engineConfiguration->sdCardCsPin = GPIOA_2; + engineConfiguration->isSdCardEnabled = false; +} + +/** + * @brief Board-specific configuration code overrides. + * @todo Add your board-specific code, if any. + */ +void setBoardConfigurationOverrides(void) { + setSerialConfigurationOverrides(); + + /* Battery voltage */ + engineConfiguration->vbattAdcChannel = EFI_ADC_6; + /* Throttle position */ + engineConfiguration->tps1_1AdcChannel = EFI_ADC_12; + /* MAP */ + engineConfiguration->map.sensor.hwChannel = EFI_ADC_10; + /* MAF */ + engineConfiguration->mafAdcChannel = EFI_ADC_3; + /* coolant t */ + engineConfiguration->clt.adcChannel = EFI_ADC_14; + /* not yet */ + engineConfiguration->iat.adcChannel = EFI_ADC_NONE; + /* narrow */ + engineConfiguration->afr.hwChannel = EFI_ADC_NONE; + + engineConfiguration->adcVcc = ADC_VCC; + + engineConfiguration->baroSensor.hwChannel = EFI_ADC_NONE; + engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_NONE; + + /* Injectors */ + engineConfiguration->injectionPins[1 - 1] = MC33810_0_OUT_0; + engineConfiguration->injectionPins[2 - 1] = MC33810_1_OUT_0; + engineConfiguration->injectionPins[3 - 1] = MC33810_0_OUT_1; + engineConfiguration->injectionPins[4 - 1] = MC33810_1_OUT_1; + engineConfiguration->injectionPins[5 - 1] = MC33810_0_OUT_2; + engineConfiguration->injectionPins[6 - 1] = MC33810_1_OUT_2; + engineConfiguration->injectionPins[7 - 1] = MC33810_0_OUT_3; + engineConfiguration->injectionPins[8 - 1] = MC33810_1_OUT_3; + + /* Ignition */ + engineConfiguration->ignitionPins[1 - 1] = MC33810_0_GD_0; + engineConfiguration->ignitionPins[2 - 1] = MC33810_1_GD_1; + engineConfiguration->ignitionPins[3 - 1] = MC33810_0_GD_1; + engineConfiguration->ignitionPins[4 - 1] = MC33810_1_GD_0; + engineConfiguration->ignitionPins[5 - 1] = MC33810_0_GD_3; + engineConfiguration->ignitionPins[6 - 1] = MC33810_1_GD_2; + engineConfiguration->ignitionPins[7 - 1] = MC33810_0_GD_2; + engineConfiguration->ignitionPins[8 - 1] = MC33810_1_GD_3; + //engineConfiguration->ignitionPinMode = OM_INVERTED; + + // Vbat divider: 10K + 1K + engineConfiguration->vbattDividerCoeff = (1.0 + 10.0) / 1.0; + //engineConfiguration->clt.config.bias_resistor = 2700; + //sengineConfiguration->iat.config.bias_resistor = 2700; + + // Idle configuration + engineConfiguration->useStepperIdle = false; + engineConfiguration->isDoubleSolenoidIdle = true; + engineConfiguration->idle.solenoidPin = TLE6240_PIN_11; + engineConfiguration->secondSolenoidPin = TLE6240_PIN_12; + + engineConfiguration->communicationLedPin = GPIOG_6; /* LD1 - green */ + engineConfiguration->runningLedPin = GPIOG_8; /* LD3 - yellow */ + engineConfiguration->warningLedPin = GPIO_UNASSIGNED; /* LD3 - yellow*/ + //engineConfiguration->unusedErrorPin = LED_ERROR_BRAIN_PIN; /* LD2 - red */ + + /* IF you have BOTH camshaft position sensor and crankshaft position sensor + * camshaft is always trigger#1 input and then crankshaft is trigger#2. */ + engineConfiguration->triggerInputPins[0] = GPIOH_12; /* cam */ + engineConfiguration->triggerInputPins[1] = GPIOH_10; /* crank pos #1 */ + engineConfiguration->triggerInputPins[2] = GPIOE_9; /* crank pos #2 */ + engineConfiguration->camInputs[0] = GPIO_UNASSIGNED; + + /* SPI devices: mess of board and engine configurations */ + /* TLE6240 */ + engineConfiguration->tle6240spiDevice = SPI_DEVICE_4; + engineConfiguration->tle6240_cs = GPIOE_15; /* SPI4_NSS0 */ + engineConfiguration->tle6240_csPinMode = OM_OPENDRAIN; + /* MC33972 */ + engineConfiguration->mc33972spiDevice = SPI_DEVICE_4; + engineConfiguration->mc33972_cs = GPIOE_10; /* SPI4_NSS2 */ + engineConfiguration->mc33972_csPinMode = OM_OPENDRAIN; + + /* TLE6240 - OUT3, also PG2 */ + engineConfiguration->tachOutputPin = TLE6240_PIN_2; + engineConfiguration->tachOutputPinMode = OM_DEFAULT; + /* spi driven - TLE6240 - OUT5 */ +#if 0 + engineConfiguration->fuelPumpPin = TLE6240_PIN_5; + engineConfiguration->fuelPumpPinMode = OM_DEFAULT; + /* self shutdown? */ + engineConfiguration->mainRelayPin = GPIOH_7; + engineConfiguration->mainRelayPinMode = OM_DEFAULT; +#else + engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED; + engineConfiguration->fuelPumpPinMode = OM_DEFAULT; + /* self shutdown? */ + engineConfiguration->mainRelayPin = TLE6240_PIN_5; + engineConfiguration->mainRelayPinMode = OM_DEFAULT; +#endif + /* spi driven - TLE6240 - OUT1, OUT2 */ + engineConfiguration->fanPin = TLE6240_PIN_1; + engineConfiguration->fanPinMode = OM_DEFAULT; + /* TODO: second fan */ + //engineConfiguration->fanPin[1] = TLE6240_PIN_2; + //engineConfiguration->fanPinMode[1] = OM_DEFAULT; + /* spi driven - TLE6240 - OUT8 */ + engineConfiguration->malfunctionIndicatorPin = TLE6240_PIN_7; + engineConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; + + // starter block + /* Starter signal connected through MC33972 - SG11 */ + //setFsio(0, (GPIOB_1), STARTER_RELAY_LOGIC PASS_CONFIG_PARAMETER_SUFFIX); + + // not used + engineConfiguration->externalKnockSenseAdc = EFI_ADC_NONE; + engineConfiguration->displayMode = DM_NONE; + engineConfiguration->HD44780_rs = GPIO_UNASSIGNED; + engineConfiguration->HD44780_e = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db4 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db5 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db6 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_db7 = GPIO_UNASSIGNED; + engineConfiguration->digitalPotentiometerChipSelect[0] = GPIO_UNASSIGNED; + engineConfiguration->digitalPotentiometerChipSelect[1] = GPIO_UNASSIGNED; + engineConfiguration->digitalPotentiometerChipSelect[2] = GPIO_UNASSIGNED; + engineConfiguration->digitalPotentiometerChipSelect[3] = GPIO_UNASSIGNED; + engineConfiguration->vehicleSpeedSensorInputPin = GPIO_UNASSIGNED; + + engineConfiguration->digitalPotentiometerSpiDevice = SPI_NONE; + engineConfiguration->max31855spiDevice = SPI_NONE; + + ///////////////////////////////////////////////////////// + + engineConfiguration->is_enabled_spi_1 = true; + engineConfiguration->is_enabled_spi_2 = false; + engineConfiguration->is_enabled_spi_3 = true; + engineConfiguration->is_enabled_spi_4 = true; + + engineConfiguration->spi1mosiPin = GPIO_UNASSIGNED; + engineConfiguration->spi1MosiMode = PO_DEFAULT; + engineConfiguration->spi1misoPin = GPIO_UNASSIGNED; + engineConfiguration->spi1MisoMode = PO_DEFAULT; + engineConfiguration->spi1sckPin = GPIO_UNASSIGNED; + engineConfiguration->spi1SckMode = PO_DEFAULT; + + engineConfiguration->spi3mosiPin = GPIOC_12; + engineConfiguration->spi3MosiMode = PO_DEFAULT; + engineConfiguration->spi3misoPin = GPIOC_11; + engineConfiguration->spi3MisoMode = PO_DEFAULT; + engineConfiguration->spi3sckPin = GPIOC_10; + engineConfiguration->spi3SckMode = PO_DEFAULT; + + /* Knock sensor */ + engineConfiguration->hip9011SpiDevice = SPI_DEVICE_4; + engineConfiguration->hip9011CsPin = GPIOE_11; /* SPI4_NSS1 */ + engineConfiguration->hip9011CsPinMode = OM_OPENDRAIN; + engineConfiguration->hip9011IntHoldPin = GPIOH_8; + engineConfiguration->hip9011IntHoldPinMode = OM_OPENDRAIN; + engineConfiguration->hipOutputChannel = EFI_ADC_7; /* PA7 */ + engineConfiguration->isHip9011Enabled = true; + + + engineConfiguration->hip9011PrescalerAndSDO = (0x6 << 1); //HIP_16MHZ_PRESCALER; + engineConfiguration->hip9011Gain = 1.0; + engineConfiguration->knockBandCustom = 0.0; + engineConfiguration->knockVThreshold = 4.0; + engineConfiguration->cylinderBore = 96.9; + engineConfiguration->maxKnockSubDeg = 20.0; + +#if 0 + engineConfiguration->cj125SpiDevice = SPI_DEVICE_3; + engineConfiguration->cj125ua = EFI_ADC_9; + engineConfiguration->cj125ur = EFI_ADC_12; + engineConfiguration->cj125CsPin = GPIOA_15; + engineConfiguration->cj125CsPinMode = OM_OPENDRAIN; + engineConfiguration->wboHeaterPin = GPIOC_13; + engineConfiguration->o2heaterPin = GPIOC_13; +#endif + engineConfiguration->isCJ125Enabled = false; + + engineConfiguration->canTxPin = GPIOD_1; + engineConfiguration->canRxPin = GPIOD_0; + + /* not used pins with testpads */ + engineConfiguration->triggerSimulatorPins[0] = GPIOH_2; + engineConfiguration->triggerSimulatorPins[1] = GPIOH_3; + engineConfiguration->triggerSimulatorPins[2] = GPIOH_4; + engineConfiguration->triggerSimulatorPinModes[0] = OM_DEFAULT; + engineConfiguration->triggerSimulatorPinModes[1] = OM_DEFAULT; + engineConfiguration->triggerSimulatorPinModes[2] = OM_DEFAULT; + + engineConfiguration->logicAnalyzerPins[0] = GPIO_UNASSIGNED; + engineConfiguration->logicAnalyzerPins[1] = GPIO_UNASSIGNED; + engineConfiguration->logicAnalyzerPins[2] = GPIO_UNASSIGNED; + engineConfiguration->logicAnalyzerPins[3] = GPIO_UNASSIGNED; + //!!!!!!!!!!!!!!!!!!! + //engineConfiguration->silentTriggerError = true; + + //!!!!!!!!!!!!! + //engineConfiguration->isEngineChartEnabled = false; + + if (engineConfiguration->fuelAlgorithm == LM_REAL_MAF) + setAlgorithm(LM_SPEED_DENSITY PASS_CONFIG_PARAMETER_SUFFIX); + if (engineConfiguration->fuelAlgorithm == LM_ALPHA_N) + setAlgorithm(LM_ALPHA_N PASS_CONFIG_PARAMETER_SUFFIX); +} diff --git a/firmware/config/boards/subaru_eg33/board_io.h b/firmware/config/boards/subaru_eg33/board_io.h new file mode 100644 index 0000000000..54b75b0a75 --- /dev/null +++ b/firmware/config/boards/subaru_eg33/board_io.h @@ -0,0 +1,991 @@ +/** + * @file boards/subaru_eg33/board_io.c + * + * @date Feb 06, 2021 + * @author Andrey Gusakov, 2021 + */ + +#ifndef BOARD_IO_H +#define BOARD_IO_H + +/* + * I/O ports initial setup, this configuration is established soon after reset + * in the initialization code. + * Please refer to the STM32 Reference Manual for details. + */ +#define PIN_MODE_INPUT(n) (0U << ((n) * 2U)) +#define PIN_MODE_OUTPUT(n) (1U << ((n) * 2U)) +#define PIN_MODE_ALTERNATE(n) (2U << ((n) * 2U)) +#define PIN_MODE_ANALOG(n) (3U << ((n) * 2U)) + +#define PIN_ODR_LOW(n) (0U << (n)) +#define PIN_ODR_HIGH(n) (1U << (n)) + +#define PIN_OTYPE_PUSHPULL(n) (0U << (n)) +#define PIN_OTYPE_OPENDRAIN(n) (1U << (n)) + +#define PIN_OSPEED_VERYLOW(n) (0U << ((n) * 2U)) +#define PIN_OSPEED_LOW(n) (1U << ((n) * 2U)) +#define PIN_OSPEED_MEDIUM(n) (2U << ((n) * 2U)) +#define PIN_OSPEED_HIGH(n) (3U << ((n) * 2U)) + +#define PIN_PUPDR_FLOATING(n) (0U << ((n) * 2U)) +#define PIN_PUPDR_PULLUP(n) (1U << ((n) * 2U)) +#define PIN_PUPDR_PULLDOWN(n) (2U << ((n) * 2U)) + +#define PIN_AFIO_AF(n, v) ((v) << (((n) % 8U) * 4U)) + +// See https://github.com/rusefi/rusefi/issues/397 +#define DEFAULT_GPIO_SPEED PIN_OSPEED_HIGH + +/* + * GPIOA setup: + * + * PA0 - n.u. + * PA1 - ignition current sensor for cyl 1, 3, 5, 7 + * PA2 - ignition current sensor for cyl 2, 4, 6, 8 + * PA3 - MAF sensor input + * PA4 - n.u. + * PA5 - n.u. + * PA6 - battery voltage input + * PA7 - knock sensor input + * PA8 - knock IC clock out + * PA9 - USART1_TX - boot/console - TTL level on XP4.2 + * PA10 - USART1_RX - boot/console - TTL level on XP4.3 + * PA11 - USB_FS_D- - boot/console/TS - XS3 + * PA12 - USB_FS_D+ - boot/console/TS - XS3 + * PA13 - SWDIO + * PA14 - SWCLK + * PA15 - bluetooth/wifi module reset gpio + */ +#define VAL_GPIOA_MODER (PIN_OTYPE_PUSHPULL(1) | \ + PIN_MODE_ANALOG(2) | \ + PIN_MODE_ANALOG(2) | \ + PIN_MODE_ANALOG(3) | \ + PIN_OTYPE_PUSHPULL(4) | \ + PIN_OTYPE_PUSHPULL(5) | \ + PIN_MODE_ANALOG(6) | \ + PIN_MODE_ANALOG(7) | \ + PIN_MODE_ALTERNATE(8) | \ + PIN_MODE_ALTERNATE(9) | \ + PIN_MODE_ALTERNATE(10) | \ + PIN_MODE_ALTERNATE(11) | \ + PIN_MODE_ALTERNATE(12) | \ + PIN_MODE_ALTERNATE(13) | \ + PIN_MODE_ALTERNATE(14) | \ + PIN_MODE_OUTPUT(15)) +#define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL( 0) | \ + PIN_OTYPE_PUSHPULL( 1) | \ + PIN_OTYPE_PUSHPULL( 2) | \ + PIN_OTYPE_PUSHPULL( 3) | \ + PIN_OTYPE_PUSHPULL( 4) | \ + PIN_OTYPE_PUSHPULL( 5) | \ + PIN_OTYPE_PUSHPULL( 6) | \ + PIN_OTYPE_PUSHPULL( 7) | \ + PIN_OTYPE_PUSHPULL( 8) | \ + PIN_OTYPE_PUSHPULL( 9) | \ + PIN_OTYPE_PUSHPULL(10) | \ + PIN_OTYPE_PUSHPULL(11) | \ + PIN_OTYPE_PUSHPULL(12) | \ + PIN_OTYPE_PUSHPULL(13) | \ + PIN_OTYPE_PUSHPULL(14) | \ + PIN_OTYPE_PUSHPULL(15)) +#define VAL_GPIOA_OSPEEDR (DEFAULT_GPIO_SPEED( 0) | \ + DEFAULT_GPIO_SPEED( 1) | \ + DEFAULT_GPIO_SPEED( 2) | \ + DEFAULT_GPIO_SPEED( 3) | \ + DEFAULT_GPIO_SPEED( 4) | \ + DEFAULT_GPIO_SPEED( 5) | \ + DEFAULT_GPIO_SPEED( 6) | \ + DEFAULT_GPIO_SPEED( 7) | \ + DEFAULT_GPIO_SPEED( 8) | \ + DEFAULT_GPIO_SPEED( 9) | \ + DEFAULT_GPIO_SPEED(10) | \ + DEFAULT_GPIO_SPEED(11) | \ + DEFAULT_GPIO_SPEED(12) | \ + DEFAULT_GPIO_SPEED(13) | \ + DEFAULT_GPIO_SPEED(14) | \ + DEFAULT_GPIO_SPEED(15)) +#define VAL_GPIOA_PUPDR (PIN_PUPDR_FLOATING( 0) | \ + PIN_PUPDR_FLOATING( 1) | \ + PIN_PUPDR_FLOATING( 2) | \ + PIN_PUPDR_FLOATING( 3) | \ + PIN_PUPDR_FLOATING( 4) | \ + PIN_PUPDR_FLOATING( 5) | \ + PIN_PUPDR_FLOATING( 6) | \ + PIN_PUPDR_FLOATING( 7) | \ + PIN_PUPDR_FLOATING( 8) | \ + PIN_PUPDR_PULLUP( 9) | \ + PIN_PUPDR_PULLUP(10) | \ + PIN_PUPDR_FLOATING(11) | \ + PIN_PUPDR_FLOATING(12) | \ + PIN_PUPDR_PULLUP(13) | \ + PIN_PUPDR_PULLDOWN(14) | \ + PIN_PUPDR_PULLUP(15)) +#define VAL_GPIOA_ODR (PIN_ODR_LOW(0) | \ + PIN_ODR_LOW(4) | \ + PIN_ODR_LOW(5) | \ + PIN_ODR_LOW(15)) +#define VAL_GPIOA_AFRL (PIN_AFIO_AF( 0, 1U) | \ + PIN_AFIO_AF( 1, 1U) | \ + PIN_AFIO_AF( 2, 0U) | \ + PIN_AFIO_AF( 3, 0U) | \ + PIN_AFIO_AF( 4, 0U) | \ + PIN_AFIO_AF( 5, 0U) | \ + PIN_AFIO_AF( 6, 0U) | \ + PIN_AFIO_AF( 7, 0U)) +#define VAL_GPIOA_AFRH (PIN_AFIO_AF( 8, 0U) | \ + PIN_AFIO_AF( 9, 7U) | \ + PIN_AFIO_AF(10, 7U) | \ + PIN_AFIO_AF(11, 10U) | \ + PIN_AFIO_AF(12, 10U) | \ + PIN_AFIO_AF(13, 0U) | \ + PIN_AFIO_AF(14, 0U) | \ + PIN_AFIO_AF(15, 0U)) + +/* + * GPIOB setup: + * + * PB0 - oxygen sensor #2 + * PB1 - EGR t sensor + * PB2 - boot mode - pulled low + * PB3 - ignition #1 + * PB4 - ignition #3 + * PB5 - ignition #7 + * PB6 - QSPI CS + * PB7 - ignition (1, 3, 5, 7) spark duration input + * PB8 - ignition #5 + * PB9 - injector #7 + * PB10 - VR diagnostic (crank #2 and cam) + * PB11 - n.u. + * PB12 - USB HS ID + * PB13 - USB HS VBus + * PB14 - USB HS DM + * PB15 - USB HS DP + */ +#define VAL_GPIOB_MODER (PIN_MODE_ANALOG(0) | \ + PIN_MODE_ANALOG(1) | \ + PIN_MODE_INPUT(2) | \ + PIN_MODE_OUTPUT(3) | \ + PIN_MODE_OUTPUT(4) | \ + PIN_MODE_OUTPUT(5) | \ + PIN_MODE_ALTERNATE(6) | \ + PIN_MODE_INPUT(7) | \ + PIN_MODE_OUTPUT(8) | \ + PIN_MODE_OUTPUT(9) | \ + PIN_MODE_OUTPUT(10) | \ + PIN_MODE_OUTPUT(11) | \ + PIN_MODE_ALTERNATE(12) | \ + PIN_MODE_INPUT(13) | \ + PIN_MODE_ALTERNATE(14) | \ + PIN_MODE_ALTERNATE(15)) +#define VAL_GPIOB_OTYPER (PIN_OTYPE_PUSHPULL( 0) | \ + PIN_OTYPE_PUSHPULL( 1) | \ + PIN_OTYPE_PUSHPULL( 2) | \ + PIN_OTYPE_PUSHPULL( 3) | \ + PIN_OTYPE_PUSHPULL( 4) | \ + PIN_OTYPE_PUSHPULL( 5) | \ + PIN_OTYPE_PUSHPULL( 6) | \ + PIN_OTYPE_PUSHPULL( 7) | \ + PIN_OTYPE_PUSHPULL( 8) | \ + PIN_OTYPE_PUSHPULL( 9) | \ + PIN_OTYPE_PUSHPULL(10) | \ + PIN_OTYPE_PUSHPULL(11) | \ + PIN_OTYPE_PUSHPULL(12) | \ + PIN_OTYPE_PUSHPULL(13) | \ + PIN_OTYPE_PUSHPULL(14) | \ + PIN_OTYPE_PUSHPULL(15)) +#define VAL_GPIOB_OSPEEDR (DEFAULT_GPIO_SPEED( 0) | \ + DEFAULT_GPIO_SPEED( 1) | \ + DEFAULT_GPIO_SPEED( 2) | \ + DEFAULT_GPIO_SPEED( 3) | \ + DEFAULT_GPIO_SPEED( 4) | \ + DEFAULT_GPIO_SPEED( 5) | \ + DEFAULT_GPIO_SPEED( 6) | \ + DEFAULT_GPIO_SPEED( 7) | \ + DEFAULT_GPIO_SPEED( 8) | \ + DEFAULT_GPIO_SPEED( 9) | \ + DEFAULT_GPIO_SPEED(10) | \ + DEFAULT_GPIO_SPEED(11) | \ + DEFAULT_GPIO_SPEED(12) | \ + DEFAULT_GPIO_SPEED(13) | \ + DEFAULT_GPIO_SPEED(14) | \ + DEFAULT_GPIO_SPEED(15)) +#define VAL_GPIOB_PUPDR (PIN_PUPDR_FLOATING( 0) | \ + PIN_PUPDR_FLOATING( 1) | \ + PIN_PUPDR_PULLDOWN( 2) | \ + PIN_PUPDR_FLOATING( 3) | \ + PIN_PUPDR_FLOATING( 4) | \ + PIN_PUPDR_FLOATING( 5) | \ + PIN_PUPDR_FLOATING( 6) | \ + PIN_PUPDR_PULLUP( 7) | \ + PIN_PUPDR_FLOATING( 8) | \ + PIN_PUPDR_FLOATING( 9) | \ + PIN_PUPDR_FLOATING(10) | \ + PIN_PUPDR_FLOATING(11) | \ + PIN_PUPDR_FLOATING(12) | \ + PIN_PUPDR_FLOATING(13) | \ + PIN_PUPDR_PULLDOWN(14) | \ + PIN_PUPDR_FLOATING(15)) +#define VAL_GPIOB_ODR (PIN_ODR_LOW(3) | \ + PIN_ODR_LOW(4) | \ + PIN_ODR_LOW(5) | \ + PIN_ODR_LOW(8) | \ + PIN_ODR_LOW(9) | \ + PIN_ODR_LOW(10) | \ + PIN_ODR_LOW(11) | \ + PIN_ODR_LOW(13)) +#define VAL_GPIOB_AFRL (PIN_AFIO_AF( 0, 0U) | \ + PIN_AFIO_AF( 1, 0U) | \ + PIN_AFIO_AF( 2, 0U) | \ + PIN_AFIO_AF( 3, 0U) | \ + PIN_AFIO_AF( 4, 0U) | \ + PIN_AFIO_AF( 5, 0U) | \ + PIN_AFIO_AF( 6, 0U) | \ + PIN_AFIO_AF( 7, 0U)) +#define VAL_GPIOB_AFRH (PIN_AFIO_AF( 8, 0U) | \ + PIN_AFIO_AF( 9, 0U) | \ + PIN_AFIO_AF(10, 0U) | \ + PIN_AFIO_AF(11, 0U) | \ + PIN_AFIO_AF(12, 12U) | \ + PIN_AFIO_AF(13, 0U) | \ + PIN_AFIO_AF(14, 12U) | \ + PIN_AFIO_AF(15, 12U)) + +/* + * GPIOC setup: + * + * PC0 - Atm P input + * PC1 - Aux0 input + * PC2 - Throtle input + * PC3 - mc33972 analog input + * PC4 - coolant T input + * PC5 - oxygen #1 input + * PC6 - idle open + * PC7 - USB HS power enable + * PC8 - idle close + * PC9 - USB HS overcurrent input + * PC10 - UART4 TX + * PC11 - UART4 Rx + * PC12 - bluetooth/wifi mode + * PC13 - ignition #4 + * PC14 - ignition #2 + * PC15 - ignition #6 + */ +#define VAL_GPIOC_MODER (PIN_MODE_ANALOG(0) | \ + PIN_MODE_ANALOG(1) | \ + PIN_MODE_ANALOG(2) | \ + PIN_MODE_ANALOG(3) | \ + PIN_MODE_ANALOG(4) | \ + PIN_MODE_ANALOG(5) | \ + PIN_MODE_OUTPUT(6) | \ + PIN_MODE_OUTPUT(7) | \ + PIN_MODE_OUTPUT(8) | \ + PIN_MODE_INPUT(9) | \ + PIN_MODE_ALTERNATE(10) | \ + PIN_MODE_ALTERNATE(11) | \ + PIN_MODE_OUTPUT(12) | \ + PIN_MODE_OUTPUT(13) | \ + PIN_MODE_OUTPUT(14) | \ + PIN_MODE_OUTPUT(15)) +#define VAL_GPIOC_OTYPER (PIN_OTYPE_PUSHPULL( 0) | \ + PIN_OTYPE_PUSHPULL( 1) | \ + PIN_OTYPE_PUSHPULL( 2) | \ + PIN_OTYPE_PUSHPULL( 3) | \ + PIN_OTYPE_PUSHPULL( 4) | \ + PIN_OTYPE_PUSHPULL( 5) | \ + PIN_OTYPE_PUSHPULL( 6) | \ + PIN_OTYPE_PUSHPULL( 7) | \ + PIN_OTYPE_PUSHPULL( 8) | \ + PIN_OTYPE_PUSHPULL( 9) | \ + PIN_OTYPE_PUSHPULL(10) | \ + PIN_OTYPE_PUSHPULL(11) | \ + PIN_OTYPE_PUSHPULL(12) | \ + PIN_OTYPE_PUSHPULL(13) | \ + PIN_OTYPE_PUSHPULL(14) | \ + PIN_OTYPE_PUSHPULL(15)) +#define VAL_GPIOC_OSPEEDR (DEFAULT_GPIO_SPEED( 0) | \ + DEFAULT_GPIO_SPEED( 1) | \ + DEFAULT_GPIO_SPEED( 2) | \ + DEFAULT_GPIO_SPEED( 3) | \ + DEFAULT_GPIO_SPEED( 4) | \ + DEFAULT_GPIO_SPEED( 5) | \ + DEFAULT_GPIO_SPEED( 6) | \ + DEFAULT_GPIO_SPEED( 7) | \ + DEFAULT_GPIO_SPEED( 8) | \ + DEFAULT_GPIO_SPEED( 9) | \ + DEFAULT_GPIO_SPEED(10) | \ + DEFAULT_GPIO_SPEED(11) | \ + DEFAULT_GPIO_SPEED(12) | \ + DEFAULT_GPIO_SPEED(13) | \ + DEFAULT_GPIO_SPEED(14) | \ + DEFAULT_GPIO_SPEED(15)) +#define VAL_GPIOC_PUPDR (PIN_PUPDR_FLOATING( 0) | \ + PIN_PUPDR_FLOATING( 1) | \ + PIN_PUPDR_FLOATING( 2) | \ + PIN_PUPDR_FLOATING( 3) | \ + PIN_PUPDR_FLOATING( 4) | \ + PIN_PUPDR_FLOATING( 5) | \ + PIN_PUPDR_FLOATING( 6) | \ + PIN_PUPDR_FLOATING( 7) | \ + PIN_PUPDR_FLOATING( 8) | \ + PIN_PUPDR_PULLUP( 9) | \ + PIN_PUPDR_FLOATING(10) | \ + PIN_PUPDR_PULLUP(11) | \ + PIN_PUPDR_FLOATING(12) | \ + PIN_PUPDR_FLOATING(13) | \ + PIN_PUPDR_FLOATING(14) | \ + PIN_PUPDR_FLOATING(15)) +#define VAL_GPIOC_ODR (PIN_ODR_LOW(6) | \ + PIN_ODR_LOW(7) | \ + PIN_ODR_LOW(8) | \ + PIN_ODR_LOW(12) | \ + PIN_ODR_LOW(13) | \ + PIN_ODR_LOW(14) | \ + PIN_ODR_LOW(15)) +#define VAL_GPIOC_AFRL (PIN_AFIO_AF( 0, 0U) | \ + PIN_AFIO_AF( 1, 0U) | \ + PIN_AFIO_AF( 2, 0U) | \ + PIN_AFIO_AF( 3, 0U) | \ + PIN_AFIO_AF( 4, 0U) | \ + PIN_AFIO_AF( 5, 0U) | \ + PIN_AFIO_AF( 6, 0U) | \ + PIN_AFIO_AF( 7, 0U)) +#define VAL_GPIOC_AFRH (PIN_AFIO_AF( 8, 0U) | \ + PIN_AFIO_AF( 9, 0U) | \ + PIN_AFIO_AF(10, 8U) | \ + PIN_AFIO_AF(11, 8U) | \ + PIN_AFIO_AF(12, 0U) | \ + PIN_AFIO_AF(13, 0U) | \ + PIN_AFIO_AF(14, 0U) | \ + PIN_AFIO_AF(15, 0U)) + +/* + * GPIOD setup: + * + * PD0 - CAN1 Rx + * PD1 - CAN1 Tx + * PD2 - E-Thtot #2 direction + * PD3 - E-Thtot #2 PWM + * PD4 - E-Thtot #1 direction + * PD5 - E-Thtot #1 PWM + * PD6 - MMC clk + * PD7 - MMC cmd + * PD8 - UART3 Tx + * PD9 - UART3 Rx + * PD10 - Power hold to PMIC + * PD11 - QSPI IO0 + * PD12 - QSPI IO1 + * PD13 - QSPI IO2 + * PD14 - Speed sensor input + * PD15 - LIN RTS + */ +#define VAL_GPIOD_MODER (PIN_MODE_ALTERNATE(0) | \ + PIN_MODE_ALTERNATE(1) | \ + PIN_MODE_OUTPUT(2) | \ + PIN_MODE_OUTPUT(3) | \ + PIN_MODE_OUTPUT(4) | \ + PIN_MODE_OUTPUT(5) | \ + PIN_MODE_ALTERNATE(6) | \ + PIN_MODE_ALTERNATE(7) | \ + PIN_MODE_ALTERNATE(8) | \ + PIN_MODE_ALTERNATE(9) | \ + PIN_MODE_OUTPUT(10) | \ + PIN_MODE_ALTERNATE(11) | \ + PIN_MODE_ALTERNATE(12) | \ + PIN_MODE_ALTERNATE(13) | \ + PIN_MODE_INPUT(14) | \ + PIN_MODE_ALTERNATE(15)) +#define VAL_GPIOD_OTYPER (PIN_OTYPE_PUSHPULL( 0) | \ + PIN_OTYPE_PUSHPULL( 1) | \ + PIN_OTYPE_PUSHPULL( 2) | \ + PIN_OTYPE_PUSHPULL( 3) | \ + PIN_OTYPE_PUSHPULL( 4) | \ + PIN_OTYPE_PUSHPULL( 5) | \ + PIN_OTYPE_PUSHPULL( 6) | \ + PIN_OTYPE_PUSHPULL( 7) | \ + PIN_OTYPE_PUSHPULL( 8) | \ + PIN_OTYPE_PUSHPULL( 9) | \ + PIN_OTYPE_PUSHPULL(10) | \ + PIN_OTYPE_PUSHPULL(11) | \ + PIN_OTYPE_PUSHPULL(12) | \ + PIN_OTYPE_PUSHPULL(13) | \ + PIN_OTYPE_PUSHPULL(14) | \ + PIN_OTYPE_PUSHPULL(15)) +#define VAL_GPIOD_OSPEEDR (DEFAULT_GPIO_SPEED( 0) | \ + DEFAULT_GPIO_SPEED( 1) | \ + DEFAULT_GPIO_SPEED( 2) | \ + DEFAULT_GPIO_SPEED( 3) | \ + DEFAULT_GPIO_SPEED( 4) | \ + DEFAULT_GPIO_SPEED( 5) | \ + PIN_OSPEED_HIGH( 6) | \ + PIN_OSPEED_HIGH( 7) | \ + DEFAULT_GPIO_SPEED( 8) | \ + DEFAULT_GPIO_SPEED( 9) | \ + DEFAULT_GPIO_SPEED(10) | \ + PIN_OSPEED_HIGH(11) | \ + PIN_OSPEED_HIGH(12) | \ + PIN_OSPEED_HIGH(13) | \ + DEFAULT_GPIO_SPEED(14) | \ + DEFAULT_GPIO_SPEED(15)) +#define VAL_GPIOD_PUPDR (PIN_PUPDR_PULLUP( 0) | \ + PIN_PUPDR_FLOATING( 1) | \ + PIN_PUPDR_FLOATING( 2) | \ + PIN_PUPDR_FLOATING( 3) | \ + PIN_PUPDR_FLOATING( 4) | \ + PIN_PUPDR_FLOATING( 5) | \ + PIN_PUPDR_FLOATING( 6) | \ + PIN_PUPDR_FLOATING( 7) | \ + PIN_PUPDR_FLOATING( 8) | \ + PIN_PUPDR_PULLUP( 9) | \ + PIN_PUPDR_FLOATING(10) | \ + PIN_PUPDR_PULLUP(11) | \ + PIN_PUPDR_PULLUP(12) | \ + PIN_PUPDR_PULLUP(13) | \ + PIN_PUPDR_FLOATING(14) | \ + PIN_PUPDR_FLOATING(15)) +#define VAL_GPIOD_ODR (PIN_ODR_LOW(2) | \ + PIN_ODR_LOW(3) | \ + PIN_ODR_LOW(4) | \ + PIN_ODR_LOW(5) | \ + PIN_ODR_HIGH(10)) +#define VAL_GPIOD_AFRL (PIN_AFIO_AF( 0, 9U) | \ + PIN_AFIO_AF( 1, 9U) | \ + PIN_AFIO_AF( 2, 0U) | \ + PIN_AFIO_AF( 3, 0U) | \ + PIN_AFIO_AF( 4, 0U) | \ + PIN_AFIO_AF( 5, 0U) | \ + PIN_AFIO_AF( 6, 11U) | \ + PIN_AFIO_AF( 7, 11U)) +#define VAL_GPIOD_AFRH (PIN_AFIO_AF( 8, 7U) | \ + PIN_AFIO_AF( 9, 7U) | \ + PIN_AFIO_AF(10, 0U) | \ + PIN_AFIO_AF(11, 9U) | \ + PIN_AFIO_AF(12, 9U) | \ + PIN_AFIO_AF(13, 9U) | \ + PIN_AFIO_AF(14, 0U) | \ + PIN_AFIO_AF(15, 8U)) + +/* + * GPIOE setup: + * + * PE0 - LIN Rx + * PE1 - LIN Tx + * PE2 - QSPI IO2 + * PE3 - injector #2 + * PE4 - injector #4 + * PE5 - injector #6 + * PE6 - injector %8 + * PE7 - n.u. + * PE8 - n.u. + * PE9 - Crank position sensor #2 + * PE10 - SPI4 CS2 (5V pulled) + * PE11 - SPI4 CS1 (5V pulled) + * PE12 - SPI4 SCK (5V pulled) + * PE13 - SPI4 MISO (5V pulled) + * PE14 - SPI4 MOSI (5V pulled) + * PE15 - SPI4 CS0 (5V pulled) + */ +#define VAL_GPIOE_MODER (PIN_MODE_ALTERNATE(0) | \ + PIN_MODE_ALTERNATE(1) | \ + PIN_MODE_OUTPUT(2) /* PIN_MODE_ALTERNATE(2) */ | \ + PIN_MODE_OUTPUT(3) | \ + PIN_MODE_OUTPUT(4) | \ + PIN_MODE_OUTPUT(5) | \ + PIN_MODE_OUTPUT(6) | \ + PIN_MODE_OUTPUT(7) | \ + PIN_MODE_OUTPUT(8) | \ + PIN_MODE_INPUT(9) | \ + PIN_MODE_OUTPUT(10) | \ + PIN_MODE_OUTPUT(11) | \ + PIN_MODE_ALTERNATE(12) | \ + PIN_MODE_ALTERNATE(13) | \ + PIN_MODE_ALTERNATE(14) | \ + PIN_MODE_OUTPUT(15)) +#define VAL_GPIOE_OTYPER (PIN_OTYPE_PUSHPULL( 0) | \ + PIN_OTYPE_PUSHPULL( 1) | \ + PIN_OTYPE_PUSHPULL( 2) | \ + PIN_OTYPE_PUSHPULL( 3) | \ + PIN_OTYPE_PUSHPULL( 4) | \ + PIN_OTYPE_PUSHPULL( 5) | \ + PIN_OTYPE_PUSHPULL( 6) | \ + PIN_OTYPE_PUSHPULL( 7) | \ + PIN_OTYPE_PUSHPULL( 8) | \ + PIN_OTYPE_PUSHPULL( 9) | \ + PIN_OTYPE_OPENDRAIN(10)| \ + PIN_OTYPE_OPENDRAIN(11)| \ + PIN_OTYPE_OPENDRAIN(12)| \ + PIN_OTYPE_PUSHPULL(13) /* PIN_OTYPE_OPENDRAIN(13) */| \ + PIN_OTYPE_OPENDRAIN(14)| \ + PIN_OTYPE_OPENDRAIN(15)) +#define VAL_GPIOE_OSPEEDR (DEFAULT_GPIO_SPEED( 0) | \ + DEFAULT_GPIO_SPEED( 1) | \ + DEFAULT_GPIO_SPEED( 2) | \ + DEFAULT_GPIO_SPEED( 3) | \ + DEFAULT_GPIO_SPEED( 4) | \ + DEFAULT_GPIO_SPEED( 5) | \ + DEFAULT_GPIO_SPEED( 6) | \ + DEFAULT_GPIO_SPEED( 7) | \ + DEFAULT_GPIO_SPEED( 8) | \ + DEFAULT_GPIO_SPEED( 9) | \ + DEFAULT_GPIO_SPEED(10) | \ + DEFAULT_GPIO_SPEED(11) | \ + DEFAULT_GPIO_SPEED(12) | \ + DEFAULT_GPIO_SPEED(13) | \ + DEFAULT_GPIO_SPEED(14) | \ + DEFAULT_GPIO_SPEED(15)) +#define VAL_GPIOE_PUPDR (PIN_PUPDR_PULLUP( 0) | \ + PIN_PUPDR_FLOATING( 1) | \ + PIN_PUPDR_PULLUP( 2) | \ + PIN_PUPDR_FLOATING( 3) | \ + PIN_PUPDR_FLOATING( 4) | \ + PIN_PUPDR_FLOATING( 5) | \ + PIN_PUPDR_FLOATING( 6) | \ + PIN_PUPDR_FLOATING( 7) | \ + PIN_PUPDR_FLOATING( 8) | \ + PIN_PUPDR_PULLUP( 9) | \ + PIN_PUPDR_FLOATING(10) | \ + PIN_PUPDR_FLOATING(11) | \ + PIN_PUPDR_FLOATING(12) | \ + PIN_PUPDR_FLOATING(13) | \ + PIN_PUPDR_FLOATING(14) | \ + PIN_PUPDR_FLOATING(15)) +#define VAL_GPIOE_ODR (PIN_ODR_LOW(3) | \ + PIN_ODR_LOW(4) | \ + PIN_ODR_LOW(5) | \ + PIN_ODR_LOW(6) | \ + PIN_ODR_LOW(7) | \ + PIN_ODR_LOW(8) | \ + PIN_ODR_HIGH(10) | \ + PIN_ODR_HIGH(11) | \ + PIN_ODR_HIGH(15)) +#define VAL_GPIOE_AFRL (PIN_AFIO_AF( 0, 8U) | \ + PIN_AFIO_AF( 1, 8U) | \ + PIN_AFIO_AF( 2, 9U) | \ + PIN_AFIO_AF( 3, 0U) | \ + PIN_AFIO_AF( 4, 0U) | \ + PIN_AFIO_AF( 5, 0U) | \ + PIN_AFIO_AF( 6, 0U) | \ + PIN_AFIO_AF( 7, 0U)) +#define VAL_GPIOE_AFRH (PIN_AFIO_AF( 8, 0U) | \ + PIN_AFIO_AF( 9, 0U) | \ + PIN_AFIO_AF(10, 0U) | \ + PIN_AFIO_AF(11, 0U) | \ + PIN_AFIO_AF(12, 5U) | \ + PIN_AFIO_AF(13, 5U) | \ + PIN_AFIO_AF(14, 5U) | \ + PIN_AFIO_AF(15, 0U)) + +/* + * GPIOF setup: + * + * PF0 - Ignition (2, 4, 6, 8) MAXI input + * PF1 - SPI5 CS0 + * PF2 - SPI5 CS1 + * PF3 - optional analog input 3 + * PF4 - optional analog input 2 + * PF5 - optional analog input 1 + * PF6 - optional analog input 0 + * PF7 - SPI5 SCK + * PF8 - SPI5 MISO + * PF9 - SPI5 MOSI + * PF10 - QSPI CLK + * PF11 - SPI5 CS4 + * PF12 - SPI5 CS5 + * PF13 - n.u. + * PF14 - SPI5 CS2 + * PF15 - SPI5 CS3 + */ +#define VAL_GPIOF_MODER (PIN_MODE_INPUT(0) | \ + PIN_MODE_OUTPUT(1) | \ + PIN_MODE_OUTPUT(2) | \ + PIN_MODE_ANALOG(3) | \ + PIN_MODE_ANALOG(4) | \ + PIN_MODE_ANALOG(5) | \ + PIN_MODE_ANALOG(6) | \ + PIN_MODE_ALTERNATE(7) | \ + PIN_MODE_ALTERNATE(8) | \ + PIN_MODE_ALTERNATE(9) | \ + PIN_MODE_ALTERNATE(10) | \ + PIN_MODE_OUTPUT(11) | \ + PIN_MODE_OUTPUT(12) | \ + PIN_MODE_OUTPUT(13) | \ + PIN_MODE_OUTPUT(14) | \ + PIN_MODE_OUTPUT(15)) +#define VAL_GPIOF_OTYPER (PIN_OTYPE_PUSHPULL( 0) | \ + PIN_OTYPE_PUSHPULL( 1) | \ + PIN_OTYPE_PUSHPULL( 2) | \ + PIN_OTYPE_PUSHPULL( 3) | \ + PIN_OTYPE_PUSHPULL( 4) | \ + PIN_OTYPE_PUSHPULL( 5) | \ + PIN_OTYPE_PUSHPULL( 6) | \ + PIN_OTYPE_PUSHPULL( 7) | \ + PIN_OTYPE_PUSHPULL( 8) | \ + PIN_OTYPE_PUSHPULL( 9) | \ + PIN_OTYPE_PUSHPULL(10) | \ + PIN_OTYPE_PUSHPULL(11) | \ + PIN_OTYPE_PUSHPULL(12) | \ + PIN_OTYPE_PUSHPULL(13) | \ + PIN_OTYPE_PUSHPULL(14) | \ + PIN_OTYPE_PUSHPULL(15)) +#define VAL_GPIOF_OSPEEDR (DEFAULT_GPIO_SPEED( 0) | \ + DEFAULT_GPIO_SPEED( 1) | \ + DEFAULT_GPIO_SPEED( 2) | \ + DEFAULT_GPIO_SPEED( 3) | \ + DEFAULT_GPIO_SPEED( 4) | \ + DEFAULT_GPIO_SPEED( 5) | \ + DEFAULT_GPIO_SPEED( 6) | \ + DEFAULT_GPIO_SPEED( 7) | \ + DEFAULT_GPIO_SPEED( 8) | \ + DEFAULT_GPIO_SPEED( 9) | \ + DEFAULT_GPIO_SPEED(10) | \ + DEFAULT_GPIO_SPEED(11) | \ + DEFAULT_GPIO_SPEED(12) | \ + DEFAULT_GPIO_SPEED(13) | \ + DEFAULT_GPIO_SPEED(14) | \ + DEFAULT_GPIO_SPEED(15)) +#define VAL_GPIOF_PUPDR (PIN_PUPDR_PULLUP( 0) | \ + PIN_PUPDR_FLOATING( 1) | \ + PIN_PUPDR_FLOATING( 2) | \ + PIN_PUPDR_FLOATING( 3) | \ + PIN_PUPDR_FLOATING( 4) | \ + PIN_PUPDR_FLOATING( 5) | \ + PIN_PUPDR_FLOATING( 6) | \ + PIN_PUPDR_FLOATING( 7) | \ + PIN_PUPDR_PULLUP( 8) | \ + PIN_PUPDR_FLOATING( 9) | \ + PIN_PUPDR_FLOATING(10) | \ + PIN_PUPDR_FLOATING(11) | \ + PIN_PUPDR_FLOATING(12) | \ + PIN_PUPDR_FLOATING(13) | \ + PIN_PUPDR_FLOATING(14) | \ + PIN_PUPDR_FLOATING(15)) +#define VAL_GPIOF_ODR (PIN_ODR_HIGH(1) | \ + PIN_ODR_HIGH(2) | \ + PIN_ODR_HIGH(11) | \ + PIN_ODR_HIGH(12) | \ + PIN_ODR_HIGH(14) | \ + PIN_ODR_HIGH(15)) +#define VAL_GPIOF_AFRL (PIN_AFIO_AF( 0, 0U) | \ + PIN_AFIO_AF( 1, 0U) | \ + PIN_AFIO_AF( 2, 0U) | \ + PIN_AFIO_AF( 3, 0U) | \ + PIN_AFIO_AF( 4, 0U) | \ + PIN_AFIO_AF( 5, 0U) | \ + PIN_AFIO_AF( 6, 0U) | \ + PIN_AFIO_AF( 7, 5U)) +#define VAL_GPIOF_AFRH (PIN_AFIO_AF( 8, 5U) | \ + PIN_AFIO_AF( 9, 5U) | \ + PIN_AFIO_AF(10, 9U) | \ + PIN_AFIO_AF(11, 0U) | \ + PIN_AFIO_AF(12, 0U) | \ + PIN_AFIO_AF(13, 0U) | \ + PIN_AFIO_AF(14, 0U) | \ + PIN_AFIO_AF(15, 0U)) + +/* + * GPIOG setup: + * + * PG0 - CAN1 EN + * PG1 - SW2 irq + * PG2 - taho out + * PG3 - 1 wire interface + * PG4 - mc33972 irq + * PG5 - mc33972 wake up input + * PG6 - LD2 - active low + * PG7 - LD1 - active low + * PG8 - LD0 - active low + * PG9 - MMC D0 + * PG10 - MMC D1 + * PG11 - MMC D2 + * PG12 - MMC D3 + * PG13 - ignition (1, 3, 5, 7) MAXI input + * PG14 - E-Throttle disable + * PG15 - ignition (1, 3, 5, 7) NOMI input + */ +#define VAL_GPIOG_MODER (PIN_MODE_OUTPUT(0) | \ + PIN_MODE_INPUT(1) | \ + PIN_MODE_OUTPUT(2) | \ + PIN_MODE_OUTPUT(3) | \ + PIN_MODE_INPUT(4) | \ + PIN_MODE_INPUT(5) | \ + PIN_MODE_OUTPUT(6) | \ + PIN_MODE_OUTPUT(7) | \ + PIN_MODE_OUTPUT(8) | \ + PIN_MODE_ALTERNATE(9) | \ + PIN_MODE_ALTERNATE(10) | \ + PIN_MODE_ALTERNATE(11) | \ + PIN_MODE_ALTERNATE(12) | \ + PIN_MODE_INPUT(13) | \ + PIN_MODE_OUTPUT(14) | \ + PIN_MODE_INPUT(15)) +#define VAL_GPIOG_OTYPER (PIN_OTYPE_PUSHPULL( 0) | \ + PIN_OTYPE_PUSHPULL( 1) | \ + PIN_OTYPE_PUSHPULL( 2) | \ + PIN_OTYPE_PUSHPULL( 3) | \ + PIN_OTYPE_PUSHPULL( 4) | \ + PIN_OTYPE_PUSHPULL( 5) | \ + PIN_OTYPE_OPENDRAIN( 6)| \ + PIN_OTYPE_OPENDRAIN( 7)| \ + PIN_OTYPE_OPENDRAIN( 8)| \ + PIN_OTYPE_PUSHPULL( 9) | \ + PIN_OTYPE_PUSHPULL(10) | \ + PIN_OTYPE_PUSHPULL(11) | \ + PIN_OTYPE_PUSHPULL(12) | \ + PIN_OTYPE_PUSHPULL(13) | \ + PIN_OTYPE_PUSHPULL(14)| \ + PIN_OTYPE_PUSHPULL(15)) +#define VAL_GPIOG_OSPEEDR (DEFAULT_GPIO_SPEED( 0) | \ + DEFAULT_GPIO_SPEED( 1) | \ + DEFAULT_GPIO_SPEED( 2) | \ + DEFAULT_GPIO_SPEED( 3) | \ + DEFAULT_GPIO_SPEED( 4) | \ + DEFAULT_GPIO_SPEED( 5) | \ + DEFAULT_GPIO_SPEED( 6) | \ + DEFAULT_GPIO_SPEED( 7) | \ + DEFAULT_GPIO_SPEED( 8) | \ + DEFAULT_GPIO_SPEED( 9) | \ + DEFAULT_GPIO_SPEED(10) | \ + DEFAULT_GPIO_SPEED(11) | \ + DEFAULT_GPIO_SPEED(12) | \ + DEFAULT_GPIO_SPEED(13) | \ + DEFAULT_GPIO_SPEED(14) | \ + DEFAULT_GPIO_SPEED(15)) +#define VAL_GPIOG_PUPDR (PIN_PUPDR_FLOATING( 0) | \ + PIN_PUPDR_PULLUP( 1) | \ + PIN_PUPDR_FLOATING( 2) | \ + PIN_PUPDR_FLOATING( 3) | \ + PIN_PUPDR_PULLUP( 4) | \ + PIN_PUPDR_PULLUP( 5) | \ + PIN_PUPDR_FLOATING( 6) | \ + PIN_PUPDR_FLOATING( 7) | \ + PIN_PUPDR_FLOATING( 8) | \ + PIN_PUPDR_PULLUP( 9) | \ + PIN_PUPDR_PULLUP(10) | \ + PIN_PUPDR_PULLUP(11) | \ + PIN_PUPDR_PULLUP(12) | \ + PIN_PUPDR_PULLUP(13) | \ + PIN_PUPDR_FLOATING(14) | \ + PIN_PUPDR_PULLUP(15)) +#define VAL_GPIOG_ODR (PIN_ODR_LOW(0) | \ + PIN_ODR_LOW(2) | \ + PIN_ODR_HIGH(3) | \ + PIN_ODR_HIGH(6) | \ + PIN_ODR_HIGH(7) | \ + PIN_ODR_HIGH(8) | \ + PIN_ODR_HIGH(14)) +#define VAL_GPIOG_AFRL (PIN_AFIO_AF( 0, 0U) | \ + PIN_AFIO_AF( 1, 0U) | \ + PIN_AFIO_AF( 2, 0U) | \ + PIN_AFIO_AF( 3, 0U) | \ + PIN_AFIO_AF( 4, 0U) | \ + PIN_AFIO_AF( 5, 0U) | \ + PIN_AFIO_AF( 6, 0U) | \ + PIN_AFIO_AF( 7, 0U)) +#define VAL_GPIOG_AFRH (PIN_AFIO_AF( 8, 0U) | \ + PIN_AFIO_AF( 9, 11U) | \ + PIN_AFIO_AF(10, 11U) | \ + PIN_AFIO_AF(11, 10U) | \ + PIN_AFIO_AF(12, 11U) | \ + PIN_AFIO_AF(13, 0U) | \ + PIN_AFIO_AF(14, 0U) | \ + PIN_AFIO_AF(15, 0U)) + +/* + * GPIOH setup: + * + * PH0 - OSC_IN (input floating). + * PH1 - OSC_OUT (input floating). + * PH2 - n.u. + * PH3 - n.u. + * PH4 - n.u. + * PH5 - n.u. + * PH6 - SW reset + * PH7 - self shutdown output + * PH8 - knock sensor IC hold output (5V pulled) + * PH9 - knock sensor IC tst output (5V pulled) + * PH10 - Crank position #1 + * PH11 - watchdog + * PH12 - Cam positio #1 + * PH13 - USB FS overcurrent input + * PH14 - USB FS power enable + * PH15 - OLED DC output + */ +#define VAL_GPIOH_MODER (PIN_MODE_INPUT(0) | \ + PIN_MODE_INPUT(1) | \ + PIN_MODE_OUTPUT(2) | \ + PIN_MODE_OUTPUT(3) | \ + PIN_MODE_OUTPUT(4) | \ + PIN_MODE_OUTPUT(5) | \ + PIN_MODE_OUTPUT(6) | \ + PIN_MODE_OUTPUT(7) | \ + PIN_MODE_OUTPUT(8) | \ + PIN_MODE_OUTPUT(9) | \ + PIN_MODE_INPUT(10) | \ + PIN_MODE_OUTPUT(11) | \ + PIN_MODE_INPUT(12) | \ + PIN_MODE_INPUT(13) | \ + PIN_MODE_OUTPUT(14) | \ + PIN_MODE_OUTPUT(15)) +#define VAL_GPIOH_OTYPER (PIN_OTYPE_PUSHPULL( 0) | \ + PIN_OTYPE_PUSHPULL( 1) | \ + PIN_OTYPE_PUSHPULL( 2) | \ + PIN_OTYPE_PUSHPULL( 3) | \ + PIN_OTYPE_PUSHPULL( 4) | \ + PIN_OTYPE_PUSHPULL( 5) | \ + PIN_OTYPE_PUSHPULL( 6) | \ + PIN_OTYPE_PUSHPULL( 7) | \ + PIN_OTYPE_OPENDRAIN( 8)| \ + PIN_OTYPE_OPENDRAIN( 9)| \ + PIN_OTYPE_PUSHPULL(10) | \ + PIN_OTYPE_PUSHPULL(11) | \ + PIN_OTYPE_PUSHPULL(12) | \ + PIN_OTYPE_PUSHPULL(13) | \ + PIN_OTYPE_PUSHPULL(14) | \ + PIN_OTYPE_PUSHPULL(15)) +#define VAL_GPIOH_OSPEEDR (DEFAULT_GPIO_SPEED( 0) | \ + DEFAULT_GPIO_SPEED( 1) | \ + DEFAULT_GPIO_SPEED( 2) | \ + DEFAULT_GPIO_SPEED( 3) | \ + DEFAULT_GPIO_SPEED( 4) | \ + DEFAULT_GPIO_SPEED( 5) | \ + DEFAULT_GPIO_SPEED( 6) | \ + DEFAULT_GPIO_SPEED( 7) | \ + DEFAULT_GPIO_SPEED( 8) | \ + DEFAULT_GPIO_SPEED( 9) | \ + DEFAULT_GPIO_SPEED(10) | \ + DEFAULT_GPIO_SPEED(11) | \ + DEFAULT_GPIO_SPEED(12) | \ + DEFAULT_GPIO_SPEED(13) | \ + DEFAULT_GPIO_SPEED(14) | \ + DEFAULT_GPIO_SPEED(15)) +#define VAL_GPIOH_PUPDR (PIN_PUPDR_FLOATING( 0) | \ + PIN_PUPDR_FLOATING( 1) | \ + PIN_PUPDR_FLOATING( 2) | \ + PIN_PUPDR_FLOATING( 3) | \ + PIN_PUPDR_FLOATING( 4) | \ + PIN_PUPDR_FLOATING( 5) | \ + PIN_PUPDR_FLOATING( 6) | \ + PIN_PUPDR_FLOATING( 7) | \ + PIN_PUPDR_FLOATING( 8) | \ + PIN_PUPDR_FLOATING( 9) | \ + PIN_PUPDR_PULLUP(10) | \ + PIN_PUPDR_FLOATING(11) | \ + PIN_PUPDR_PULLUP(12) | \ + PIN_PUPDR_PULLUP(13) | \ + PIN_PUPDR_FLOATING(14) | \ + PIN_PUPDR_FLOATING(15)) +#define VAL_GPIOH_ODR (PIN_ODR_HIGH( 0) | \ + PIN_ODR_HIGH( 1) | \ + PIN_ODR_LOW( 2) | \ + PIN_ODR_LOW( 3) | \ + PIN_ODR_LOW( 4) | \ + PIN_ODR_LOW( 5) | \ + PIN_ODR_LOW( 6) | \ + PIN_ODR_LOW( 7) | \ + PIN_ODR_HIGH( 8) | \ + PIN_ODR_HIGH( 9) | \ + PIN_ODR_LOW(11) | \ + PIN_ODR_LOW(14) | \ + PIN_ODR_LOW(15)) +#define VAL_GPIOH_AFRL (PIN_AFIO_AF( 0, 0U) | \ + PIN_AFIO_AF( 1, 0U) | \ + PIN_AFIO_AF( 2, 0U) | \ + PIN_AFIO_AF( 3, 0U) | \ + PIN_AFIO_AF( 4, 0U) | \ + PIN_AFIO_AF( 5, 0U) | \ + PIN_AFIO_AF( 6, 0U) | \ + PIN_AFIO_AF( 7, 0U)) +#define VAL_GPIOH_AFRH (PIN_AFIO_AF( 8, 0U) | \ + PIN_AFIO_AF( 9, 0U) | \ + PIN_AFIO_AF(10, 0U) | \ + PIN_AFIO_AF(11, 0U) | \ + PIN_AFIO_AF(12, 0U) | \ + PIN_AFIO_AF(13, 0U) | \ + PIN_AFIO_AF(14, 0U) | \ + PIN_AFIO_AF(15, 0U)) + +/* + * GPIOI setup: + * + * PI0 - SPI2 CS0 + * PI1 - SPI2 SCK + * PI2 - SPI2 MISO + * PI3 - SPI2 MOSI + * PI4 - injector #5 + * PI5 - injector #3 + * PI6 - injector #1 + * PI7 - SW enable + * PI8 - ignition (2, 4, 6, 8) spark duration input + * PI9 - ignition #8 + * PI10 - n.u. + * PI11 - ignition (2, 4, 6, 8) NOMI input + */ +#define VAL_GPIOI_MODER (PIN_MODE_OUTPUT(0) | \ + PIN_MODE_ALTERNATE(1) | \ + PIN_MODE_ALTERNATE(2) | \ + PIN_MODE_ALTERNATE(3) | \ + PIN_MODE_OUTPUT(4) | \ + PIN_MODE_OUTPUT(5) | \ + PIN_MODE_OUTPUT(6) | \ + PIN_MODE_OUTPUT(7) | \ + PIN_MODE_INPUT(8) | \ + PIN_MODE_OUTPUT(9) | \ + PIN_MODE_OUTPUT(10) | \ + PIN_MODE_INPUT(11)) +#define VAL_GPIOI_OTYPER (PIN_OTYPE_PUSHPULL( 0) | \ + PIN_OTYPE_PUSHPULL( 1) | \ + PIN_OTYPE_PUSHPULL( 2) | \ + PIN_OTYPE_PUSHPULL( 3) | \ + PIN_OTYPE_PUSHPULL( 4) | \ + PIN_OTYPE_PUSHPULL( 5) | \ + PIN_OTYPE_PUSHPULL( 6) | \ + PIN_OTYPE_PUSHPULL( 7) | \ + PIN_OTYPE_PUSHPULL( 8) | \ + PIN_OTYPE_PUSHPULL( 9) | \ + PIN_OTYPE_PUSHPULL(10) | \ + PIN_OTYPE_PUSHPULL(11)) +#define VAL_GPIOI_OSPEEDR (DEFAULT_GPIO_SPEED( 0) | \ + DEFAULT_GPIO_SPEED( 1) | \ + DEFAULT_GPIO_SPEED( 2) | \ + DEFAULT_GPIO_SPEED( 3) | \ + DEFAULT_GPIO_SPEED( 4) | \ + DEFAULT_GPIO_SPEED( 5) | \ + DEFAULT_GPIO_SPEED( 6) | \ + DEFAULT_GPIO_SPEED( 7) | \ + DEFAULT_GPIO_SPEED( 8) | \ + DEFAULT_GPIO_SPEED( 9) | \ + DEFAULT_GPIO_SPEED(10) | \ + DEFAULT_GPIO_SPEED(11)) +#define VAL_GPIOI_PUPDR (PIN_PUPDR_FLOATING( 0) | \ + PIN_PUPDR_FLOATING( 1) | \ + PIN_PUPDR_FLOATING( 2) | \ + PIN_PUPDR_FLOATING( 3) | \ + PIN_PUPDR_FLOATING( 4) | \ + PIN_PUPDR_FLOATING( 5) | \ + PIN_PUPDR_FLOATING( 6) | \ + PIN_PUPDR_FLOATING( 7) | \ + PIN_PUPDR_PULLUP( 8) | \ + PIN_PUPDR_FLOATING( 9) | \ + PIN_PUPDR_FLOATING(10) | \ + PIN_PUPDR_PULLUP(11)) +#define VAL_GPIOI_ODR (PIN_ODR_HIGH( 0) | \ + PIN_ODR_LOW( 4) | \ + PIN_ODR_LOW( 5) | \ + PIN_ODR_LOW( 6) | \ + PIN_ODR_LOW( 7) | \ + PIN_ODR_LOW( 9)) +#define VAL_GPIOI_AFRL (PIN_AFIO_AF( 0, 0U) | \ + PIN_AFIO_AF( 1, 5U) | \ + PIN_AFIO_AF( 2, 5U) | \ + PIN_AFIO_AF( 3, 5U) | \ + PIN_AFIO_AF( 4, 0U) | \ + PIN_AFIO_AF( 5, 0U) | \ + PIN_AFIO_AF( 6, 0U) | \ + PIN_AFIO_AF( 7, 0U)) +#define VAL_GPIOI_AFRH (PIN_AFIO_AF( 8, 0U) | \ + PIN_AFIO_AF( 9, 0U) | \ + PIN_AFIO_AF(10, 0U) | \ + PIN_AFIO_AF(11, 0U)) + +#endif /* BOARD_IO_H */ diff --git a/firmware/config/boards/subaru_eg33/config.mk b/firmware/config/boards/subaru_eg33/config.mk new file mode 100644 index 0000000000..8f03483943 --- /dev/null +++ b/firmware/config/boards/subaru_eg33/config.mk @@ -0,0 +1,2 @@ +#We have our own enums +GENERATED_ENUMS_DIR = $(PROJECT_DIR)/config/boards/$(PROJECT_BOARD)/config/controllers/algo diff --git a/firmware/config/boards/subaru_eg33/config/controllers/algo/auto_generated_enums.cpp b/firmware/config/boards/subaru_eg33/config/controllers/algo/auto_generated_enums.cpp new file mode 100644 index 0000000000..fee4e3481c --- /dev/null +++ b/firmware/config/boards/subaru_eg33/config/controllers/algo/auto_generated_enums.cpp @@ -0,0 +1,1531 @@ +#include "global.h" +#include "rusefi_enums.h" +#include "rusefi_hw_enums.h" +// was generated automatically by rusEfi tool from rusefi_hw_enums.h // was generated automatically by rusEfi tool from rusefi_enums.h // by enum2string.jar tool on Sat Feb 06 13:39:37 MSK 2021 +// see also gen_config_and_enums.bat + + + +const char *getPidAutoTune_AutoTunerState(PidAutoTune_AutoTunerState value){ +switch(value) { +case AUTOTUNER_OFF: + return "AUTOTUNER_OFF"; +case CONVERGED: + return "CONVERGED"; +case FAILED: + return "FAILED"; +case RELAY_STEP_DOWN: + return "RELAY_STEP_DOWN"; +case RELAY_STEP_UP: + return "RELAY_STEP_UP"; +case STEADY_STATE_AFTER_STEP_UP: + return "STEADY_STATE_AFTER_STEP_UP"; +case STEADY_STATE_AT_BASELINE: + return "STEADY_STATE_AT_BASELINE"; + } + return NULL; +} +const char *getPidAutoTune_Peak(PidAutoTune_Peak value){ +switch(value) { +case MAXIMUM: + return "MAXIMUM"; +case MINIMUM: + return "MINIMUM"; +case NOT_A_PEAK: + return "NOT_A_PEAK"; + } + return NULL; +} +const char *getAdc_channel_e(adc_channel_e value){ +switch(value) { +case EFI_ADC3_14: + return "EFI_ADC3_14"; +case EFI_ADC3_15: + return "EFI_ADC3_15"; +case EFI_ADC3_4: + return "EFI_ADC3_4"; +case EFI_ADC3_5: + return "EFI_ADC3_5"; +case EFI_ADC3_6: + return "EFI_ADC3_6"; +case EFI_ADC3_7: + return "EFI_ADC3_7"; +case EFI_ADC3_8: + return "EFI_ADC3_8"; +case EFI_ADC3_9: + return "EFI_ADC3_9"; +case EFI_ADC_0: + return "EFI_ADC_0"; +case EFI_ADC_1: + return "EFI_ADC_1"; +case EFI_ADC_10: + return "EFI_ADC_10"; +case EFI_ADC_11: + return "EFI_ADC_11"; +case EFI_ADC_12: + return "EFI_ADC_12"; +case EFI_ADC_13: + return "EFI_ADC_13"; +case EFI_ADC_14: + return "EFI_ADC_14"; +case EFI_ADC_15: + return "EFI_ADC_15"; +case EFI_ADC_2: + return "EFI_ADC_2"; +case EFI_ADC_3: + return "EFI_ADC_3"; +case EFI_ADC_4: + return "EFI_ADC_4"; +case EFI_ADC_5: + return "EFI_ADC_5"; +case EFI_ADC_6: + return "EFI_ADC_6"; +case EFI_ADC_7: + return "EFI_ADC_7"; +case EFI_ADC_8: + return "EFI_ADC_8"; +case EFI_ADC_9: + return "EFI_ADC_9"; +case EFI_ADC_ERROR: + return "EFI_ADC_ERROR"; +case EFI_ADC_LAST_CHANNEL: + return "EFI_ADC_LAST_CHANNEL"; +case EFI_ADC_NONE: + return "EFI_ADC_NONE"; +case EFI_ADC_TEMP_SENSOR: + return "EFI_ADC_TEMP_SENSOR"; + } + return NULL; +} +const char *getAdc_channel_mode_e(adc_channel_mode_e value){ +switch(value) { +case ADC_FAST: + return "ADC_FAST"; +case ADC_OFF: + return "ADC_OFF"; +case ADC_SLOW: + return "ADC_SLOW"; +case Force_4_bytes_size_adc_channel_mode: + return "Force_4_bytes_size_adc_channel_mode"; + } + return NULL; +} +const char *getAfr_override_e(afr_override_e value){ +switch(value) { +case AFR_AccPedal: + return "AFR_AccPedal"; +case AFR_CylFilling: + return "AFR_CylFilling"; +case AFR_MAP: + return "AFR_MAP"; +case AFR_None: + return "AFR_None"; +case AFR_Tps: + return "AFR_Tps"; + } + return NULL; +} +const char *getAir_pressure_sensor_type_e(air_pressure_sensor_type_e value){ +switch(value) { +case Force_4_bytes_size_cranking_map_type: + return "Force_4_bytes_size_cranking_map_type"; +case MT_BOSCH_2_5: + return "MT_BOSCH_2_5"; +case MT_CUSTOM: + return "MT_CUSTOM"; +case MT_DENSO183: + return "MT_DENSO183"; +case MT_DODGE_NEON_2003: + return "MT_DODGE_NEON_2003"; +case MT_GM_1_BAR: + return "MT_GM_1_BAR"; +case MT_GM_2_BAR: + return "MT_GM_2_BAR"; +case MT_GM_3_BAR: + return "MT_GM_3_BAR"; +case MT_HONDA3BAR: + return "MT_HONDA3BAR"; +case MT_MAZDA_1_BAR: + return "MT_MAZDA_1_BAR"; +case MT_MPX4100: + return "MT_MPX4100"; +case MT_MPX4250: + return "MT_MPX4250"; +case MT_MPX4250A: + return "MT_MPX4250A"; +case MT_SUBY_DENSO: + return "MT_SUBY_DENSO"; +case MT_TOYOTA_89420_02010: + return "MT_TOYOTA_89420_02010"; + } + return NULL; +} +const char *getAntiLagActivationMode_e(antiLagActivationMode_e value){ +switch(value) { +case ALWAYS_ON_ANTILAG: + return "ALWAYS_ON_ANTILAG"; +case Force_4bytes_size_antiLagActivationMode_e: + return "Force_4bytes_size_antiLagActivationMode_e"; +case SWITCH_INPUT_ANTILAG: + return "SWITCH_INPUT_ANTILAG"; + } + return NULL; +} +const char *getBoostType_e(boostType_e value){ +switch(value) { +case CLOSED_LOOP: + return "CLOSED_LOOP"; +case Force_4bytes_size_boostType_e: + return "Force_4bytes_size_boostType_e"; +case OPEN_LOOP: + return "OPEN_LOOP"; + } + return NULL; +} +const char *getBrain_pin_diag_e(brain_pin_diag_e value){ +switch(value) { +case PIN_DRIVER_OVERTEMP: + return "PIN_DRIVER_OVERTEMP"; +case PIN_INVALID: + return "PIN_INVALID"; +case PIN_OK: + return "PIN_OK"; +case PIN_OPEN: + return "PIN_OPEN"; +case PIN_OVERLOAD: + return "PIN_OVERLOAD"; +case PIN_SHORT_TO_BAT: + return "PIN_SHORT_TO_BAT"; +case PIN_SHORT_TO_GND: + return "PIN_SHORT_TO_GND"; + } + return NULL; +} +const char *getBrain_pin_e(brain_pin_e value){ +switch(value) { +case GPIOA_0: + return "GPIOA_0"; +case GPIOA_1: + return "GPIOA_1"; +case GPIOA_10: + return "GPIOA_10"; +case GPIOA_11: + return "GPIOA_11"; +case GPIOA_12: + return "GPIOA_12"; +case GPIOA_13: + return "GPIOA_13"; +case GPIOA_14: + return "GPIOA_14"; +case GPIOA_15: + return "GPIOA_15"; +case GPIOA_2: + return "GPIOA_2"; +case GPIOA_3: + return "GPIOA_3"; +case GPIOA_4: + return "GPIOA_4"; +case GPIOA_5: + return "GPIOA_5"; +case GPIOA_6: + return "GPIOA_6"; +case GPIOA_7: + return "GPIOA_7"; +case GPIOA_8: + return "GPIOA_8"; +case GPIOA_9: + return "GPIOA_9"; +case GPIOB_0: + return "GPIOB_0"; +case GPIOB_1: + return "GPIOB_1"; +case GPIOB_10: + return "GPIOB_10"; +case GPIOB_11: + return "GPIOB_11"; +case GPIOB_12: + return "GPIOB_12"; +case GPIOB_13: + return "GPIOB_13"; +case GPIOB_14: + return "GPIOB_14"; +case GPIOB_15: + return "GPIOB_15"; +case GPIOB_2: + return "GPIOB_2"; +case GPIOB_3: + return "GPIOB_3"; +case GPIOB_4: + return "GPIOB_4"; +case GPIOB_5: + return "GPIOB_5"; +case GPIOB_6: + return "GPIOB_6"; +case GPIOB_7: + return "GPIOB_7"; +case GPIOB_8: + return "GPIOB_8"; +case GPIOB_9: + return "GPIOB_9"; +case GPIOC_0: + return "GPIOC_0"; +case GPIOC_1: + return "GPIOC_1"; +case GPIOC_10: + return "GPIOC_10"; +case GPIOC_11: + return "GPIOC_11"; +case GPIOC_12: + return "GPIOC_12"; +case GPIOC_13: + return "GPIOC_13"; +case GPIOC_14: + return "GPIOC_14"; +case GPIOC_15: + return "GPIOC_15"; +case GPIOC_2: + return "GPIOC_2"; +case GPIOC_3: + return "GPIOC_3"; +case GPIOC_4: + return "GPIOC_4"; +case GPIOC_5: + return "GPIOC_5"; +case GPIOC_6: + return "GPIOC_6"; +case GPIOC_7: + return "GPIOC_7"; +case GPIOC_8: + return "GPIOC_8"; +case GPIOC_9: + return "GPIOC_9"; +case GPIOD_0: + return "GPIOD_0"; +case GPIOD_1: + return "GPIOD_1"; +case GPIOD_10: + return "GPIOD_10"; +case GPIOD_11: + return "GPIOD_11"; +case GPIOD_12: + return "GPIOD_12"; +case GPIOD_13: + return "GPIOD_13"; +case GPIOD_14: + return "GPIOD_14"; +case GPIOD_15: + return "GPIOD_15"; +case GPIOD_2: + return "GPIOD_2"; +case GPIOD_3: + return "GPIOD_3"; +case GPIOD_4: + return "GPIOD_4"; +case GPIOD_5: + return "GPIOD_5"; +case GPIOD_6: + return "GPIOD_6"; +case GPIOD_7: + return "GPIOD_7"; +case GPIOD_8: + return "GPIOD_8"; +case GPIOD_9: + return "GPIOD_9"; +case GPIOE_0: + return "GPIOE_0"; +case GPIOE_1: + return "GPIOE_1"; +case GPIOE_10: + return "GPIOE_10"; +case GPIOE_11: + return "GPIOE_11"; +case GPIOE_12: + return "GPIOE_12"; +case GPIOE_13: + return "GPIOE_13"; +case GPIOE_14: + return "GPIOE_14"; +case GPIOE_15: + return "GPIOE_15"; +case GPIOE_2: + return "GPIOE_2"; +case GPIOE_3: + return "GPIOE_3"; +case GPIOE_4: + return "GPIOE_4"; +case GPIOE_5: + return "GPIOE_5"; +case GPIOE_6: + return "GPIOE_6"; +case GPIOE_7: + return "GPIOE_7"; +case GPIOE_8: + return "GPIOE_8"; +case GPIOE_9: + return "GPIOE_9"; +case GPIOF_0: + return "GPIOF_0"; +case GPIOF_1: + return "GPIOF_1"; +case GPIOF_10: + return "GPIOF_10"; +case GPIOF_11: + return "GPIOF_11"; +case GPIOF_12: + return "GPIOF_12"; +case GPIOF_13: + return "GPIOF_13"; +case GPIOF_14: + return "GPIOF_14"; +case GPIOF_15: + return "GPIOF_15"; +case GPIOF_2: + return "GPIOF_2"; +case GPIOF_3: + return "GPIOF_3"; +case GPIOF_4: + return "GPIOF_4"; +case GPIOF_5: + return "GPIOF_5"; +case GPIOF_6: + return "GPIOF_6"; +case GPIOF_7: + return "GPIOF_7"; +case GPIOF_8: + return "GPIOF_8"; +case GPIOF_9: + return "GPIOF_9"; +case GPIOG_0: + return "GPIOG_0"; +case GPIOG_1: + return "GPIOG_1"; +case GPIOG_10: + return "GPIOG_10"; +case GPIOG_11: + return "GPIOG_11"; +case GPIOG_12: + return "GPIOG_12"; +case GPIOG_13: + return "GPIOG_13"; +case GPIOG_14: + return "GPIOG_14"; +case GPIOG_15: + return "GPIOG_15"; +case GPIOG_2: + return "GPIOG_2"; +case GPIOG_3: + return "GPIOG_3"; +case GPIOG_4: + return "GPIOG_4"; +case GPIOG_5: + return "GPIOG_5"; +case GPIOG_6: + return "GPIOG_6"; +case GPIOG_7: + return "GPIOG_7"; +case GPIOG_8: + return "GPIOG_8"; +case GPIOG_9: + return "GPIOG_9"; +case GPIOH_0: + return "GPIOH_0"; +case GPIOH_1: + return "GPIOH_1"; +case GPIOH_10: + return "GPIOH_10"; +case GPIOH_11: + return "GPIOH_11"; +case GPIOH_12: + return "GPIOH_12"; +case GPIOH_13: + return "GPIOH_13"; +case GPIOH_14: + return "GPIOH_14"; +case GPIOH_15: + return "GPIOH_15"; +case GPIOH_2: + return "GPIOH_2"; +case GPIOH_3: + return "GPIOH_3"; +case GPIOH_4: + return "GPIOH_4"; +case GPIOH_5: + return "GPIOH_5"; +case GPIOH_6: + return "GPIOH_6"; +case GPIOH_7: + return "GPIOH_7"; +case GPIOH_8: + return "GPIOH_8"; +case GPIOH_9: + return "GPIOH_9"; +case GPIOI_0: + return "GPIOI_0"; +case GPIOI_1: + return "GPIOI_1"; +case GPIOI_10: + return "GPIOI_10"; +case GPIOI_11: + return "GPIOI_11"; +case GPIOI_12: + return "GPIOI_12"; +case GPIOI_13: + return "GPIOI_13"; +case GPIOI_14: + return "GPIOI_14"; +case GPIOI_15: + return "GPIOI_15"; +case GPIOI_2: + return "GPIOI_2"; +case GPIOI_3: + return "GPIOI_3"; +case GPIOI_4: + return "GPIOI_4"; +case GPIOI_5: + return "GPIOI_5"; +case GPIOI_6: + return "GPIOI_6"; +case GPIOI_7: + return "GPIOI_7"; +case GPIOI_8: + return "GPIOI_8"; +case GPIOI_9: + return "GPIOI_9"; +case GPIO_INVALID: + return "GPIO_INVALID"; +case GPIO_UNASSIGNED: + return "GPIO_UNASSIGNED"; +case MC33810_0_GD_0: + return "MC33810_0_GD_0"; +case MC33810_0_GD_1: + return "MC33810_0_GD_1"; +case MC33810_0_GD_2: + return "MC33810_0_GD_2"; +case MC33810_0_GD_3: + return "MC33810_0_GD_3"; +case MC33810_0_OUT_0: + return "MC33810_0_OUT_0"; +case MC33810_0_OUT_1: + return "MC33810_0_OUT_1"; +case MC33810_0_OUT_2: + return "MC33810_0_OUT_2"; +case MC33810_0_OUT_3: + return "MC33810_0_OUT_3"; +case MC33810_1_GD_0: + return "MC33810_1_GD_0"; +case MC33810_1_GD_1: + return "MC33810_1_GD_1"; +case MC33810_1_GD_2: + return "MC33810_1_GD_2"; +case MC33810_1_GD_3: + return "MC33810_1_GD_3"; +case MC33810_1_OUT_0: + return "MC33810_1_OUT_0"; +case MC33810_1_OUT_1: + return "MC33810_1_OUT_1"; +case MC33810_1_OUT_2: + return "MC33810_1_OUT_2"; +case MC33810_1_OUT_3: + return "MC33810_1_OUT_3"; +case MC33972_PIN_1: + return "MC33972_PIN_1"; +case MC33972_PIN_10: + return "MC33972_PIN_10"; +case MC33972_PIN_11: + return "MC33972_PIN_11"; +case MC33972_PIN_12: + return "MC33972_PIN_12"; +case MC33972_PIN_13: + return "MC33972_PIN_13"; +case MC33972_PIN_14: + return "MC33972_PIN_14"; +case MC33972_PIN_15: + return "MC33972_PIN_15"; +case MC33972_PIN_16: + return "MC33972_PIN_16"; +case MC33972_PIN_17: + return "MC33972_PIN_17"; +case MC33972_PIN_18: + return "MC33972_PIN_18"; +case MC33972_PIN_19: + return "MC33972_PIN_19"; +case MC33972_PIN_2: + return "MC33972_PIN_2"; +case MC33972_PIN_20: + return "MC33972_PIN_20"; +case MC33972_PIN_21: + return "MC33972_PIN_21"; +case MC33972_PIN_22: + return "MC33972_PIN_22"; +case MC33972_PIN_3: + return "MC33972_PIN_3"; +case MC33972_PIN_4: + return "MC33972_PIN_4"; +case MC33972_PIN_5: + return "MC33972_PIN_5"; +case MC33972_PIN_6: + return "MC33972_PIN_6"; +case MC33972_PIN_7: + return "MC33972_PIN_7"; +case MC33972_PIN_8: + return "MC33972_PIN_8"; +case MC33972_PIN_9: + return "MC33972_PIN_9"; +case TLE6240_PIN_1: + return "TLE6240_PIN_1"; +case TLE6240_PIN_10: + return "TLE6240_PIN_10"; +case TLE6240_PIN_11: + return "TLE6240_PIN_11"; +case TLE6240_PIN_12: + return "TLE6240_PIN_12"; +case TLE6240_PIN_13: + return "TLE6240_PIN_13"; +case TLE6240_PIN_14: + return "TLE6240_PIN_14"; +case TLE6240_PIN_15: + return "TLE6240_PIN_15"; +case TLE6240_PIN_16: + return "TLE6240_PIN_16"; +case TLE6240_PIN_2: + return "TLE6240_PIN_2"; +case TLE6240_PIN_3: + return "TLE6240_PIN_3"; +case TLE6240_PIN_4: + return "TLE6240_PIN_4"; +case TLE6240_PIN_5: + return "TLE6240_PIN_5"; +case TLE6240_PIN_6: + return "TLE6240_PIN_6"; +case TLE6240_PIN_7: + return "TLE6240_PIN_7"; +case TLE6240_PIN_8: + return "TLE6240_PIN_8"; +case TLE6240_PIN_9: + return "TLE6240_PIN_9"; + } + return NULL; +} +const char *getCan_baudrate_e(can_baudrate_e value){ +switch(value) { +case B100KBPS: + return "B100KBPS"; +case B1MBPS: + return "B1MBPS"; +case B250KBPS: + return "B250KBPS"; +case B500KBPS: + return "B500KBPS"; + } + return NULL; +} +const char *getCan_nbc_e(can_nbc_e value){ +switch(value) { +case CAN_BUS_BMW_E90: + return "CAN_BUS_BMW_E90"; +case CAN_BUS_Haltech: + return "CAN_BUS_Haltech"; +case CAN_BUS_MAZDA_RX8: + return "CAN_BUS_MAZDA_RX8"; +case CAN_BUS_NBC_BMW: + return "CAN_BUS_NBC_BMW"; +case CAN_BUS_NBC_FIAT: + return "CAN_BUS_NBC_FIAT"; +case CAN_BUS_NBC_NONE: + return "CAN_BUS_NBC_NONE"; +case CAN_BUS_NBC_VAG: + return "CAN_BUS_NBC_VAG"; +case CAN_BUS_W202_C180: + return "CAN_BUS_W202_C180"; +case Internal_ForceMyEnumIntSize_can_nbc: + return "Internal_ForceMyEnumIntSize_can_nbc"; + } + return NULL; +} +const char *getCan_vss_nbc_e(can_vss_nbc_e value){ +switch(value) { +case BMW_e46: + return "BMW_e46"; +case Force_4_bytes_size_can_vss_nbc_e: + return "Force_4_bytes_size_can_vss_nbc_e"; +case W202: + return "W202"; + } + return NULL; +} +const char *getChamber_style_e(chamber_style_e value){ +switch(value) { +case CS_CLOSED: + return "CS_CLOSED"; +case CS_OPEN: + return "CS_OPEN"; +case CS_SWIRL_TUMBLE: + return "CS_SWIRL_TUMBLE"; +case Internal_ForceMyEnumIntSize_chamber_stype: + return "Internal_ForceMyEnumIntSize_chamber_stype"; + } + return NULL; +} +const char *getCranking_ignition_mode_e(cranking_ignition_mode_e value){ +switch(value) { +case CIM_DEFAULT: + return "CIM_DEFAULT"; +case CIM_FIXED_ANGLE: + return "CIM_FIXED_ANGLE"; +case Force_4_bytes_size_cranking_ignition_mode: + return "Force_4_bytes_size_cranking_ignition_mode"; + } + return NULL; +} +const char *getDebug_mode_e(debug_mode_e value){ +switch(value) { +case DBG_16: + return "DBG_16"; +case DBG_34: + return "DBG_34"; +case DBG_48: + return "DBG_48"; +case DBG_ALTERNATOR_PID: + return "DBG_ALTERNATOR_PID"; +case DBG_ANALOG_INPUTS: + return "DBG_ANALOG_INPUTS"; +case DBG_ANALOG_INPUTS2: + return "DBG_ANALOG_INPUTS2"; +case DBG_AUX_PID_1: + return "DBG_AUX_PID_1"; +case DBG_AUX_VALVES: + return "DBG_AUX_VALVES"; +case DBG_BENCH_TEST: + return "DBG_BENCH_TEST"; +case DBG_BOOST: + return "DBG_BOOST"; +case DBG_CAN: + return "DBG_CAN"; +case DBG_CJ125: + return "DBG_CJ125"; +case DBG_COMPOSITE_LOG: + return "DBG_COMPOSITE_LOG"; +case DBG_CRANKING_DETAILS: + return "DBG_CRANKING_DETAILS"; +case DBG_DWELL_METRIC: + return "DBG_DWELL_METRIC"; +case DBG_DYNO_VIEW: + return "DBG_DYNO_VIEW"; +case DBG_ELECTRONIC_THROTTLE_EXTRA: + return "DBG_ELECTRONIC_THROTTLE_EXTRA"; +case DBG_ELECTRONIC_THROTTLE_PID: + return "DBG_ELECTRONIC_THROTTLE_PID"; +case DBG_EL_ACCEL: + return "DBG_EL_ACCEL"; +case DBG_ETB_AUTOTUNE: + return "DBG_ETB_AUTOTUNE"; +case DBG_ETB_LOGIC: + return "DBG_ETB_LOGIC"; +case DBG_EXECUTOR: + return "DBG_EXECUTOR"; +case DBG_FSIO_ADC: + return "DBG_FSIO_ADC"; +case DBG_FSIO_EXPRESSION_1_7: + return "DBG_FSIO_EXPRESSION_1_7"; +case DBG_FSIO_EXPRESSION_8_14: + return "DBG_FSIO_EXPRESSION_8_14"; +case DBG_FSIO_SPECIAL: + return "DBG_FSIO_SPECIAL"; +case DBG_FUEL_PID_CORRECTION: + return "DBG_FUEL_PID_CORRECTION"; +case DBG_GPPWM: + return "DBG_GPPWM"; +case DBG_IDLE_CONTROL: + return "DBG_IDLE_CONTROL"; +case DBG_IGNITION_TIMING: + return "DBG_IGNITION_TIMING"; +case DBG_INJECTOR_COMPENSATION: + return "DBG_INJECTOR_COMPENSATION"; +case DBG_INSTANT_RPM: + return "DBG_INSTANT_RPM"; +case DBG_ION: + return "DBG_ION"; +case DBG_KNOCK: + return "DBG_KNOCK"; +case DBG_LAUNCH: + return "DBG_LAUNCH"; +case DBG_LOGIC_ANALYZER: + return "DBG_LOGIC_ANALYZER"; +case DBG_MAP: + return "DBG_MAP"; +case DBG_METRICS: + return "DBG_METRICS"; +case DBG_RUSEFI_WIDEBAND: + return "DBG_RUSEFI_WIDEBAND"; +case DBG_SD_CARD: + return "DBG_SD_CARD"; +case DBG_SR5_PROTOCOL: + return "DBG_SR5_PROTOCOL"; +case DBG_START_STOP: + return "DBG_START_STOP"; +case DBG_STATUS: + return "DBG_STATUS"; +case DBG_TCU: + return "DBG_TCU"; +case DBG_TLE8888: + return "DBG_TLE8888"; +case DBG_TPS_ACCEL: + return "DBG_TPS_ACCEL"; +case DBG_TRIGGER_COUNTERS: + return "DBG_TRIGGER_COUNTERS"; +case DBG_VEHICLE_SPEED_SENSOR: + return "DBG_VEHICLE_SPEED_SENSOR"; +case DBG_VVT: + return "DBG_VVT"; +case Force_4_bytes_size_debug_mode_e: + return "Force_4_bytes_size_debug_mode_e"; + } + return NULL; +} +const char *getDisplay_mode_e(display_mode_e value){ +switch(value) { +case DM_HD44780: + return "DM_HD44780"; +case DM_HD44780_OVER_PCF8574: + return "DM_HD44780_OVER_PCF8574"; +case DM_NONE: + return "DM_NONE"; +case Force_4_bytes_size_display_mode: + return "Force_4_bytes_size_display_mode"; + } + return NULL; +} +const char *getEgo_sensor_e(ego_sensor_e value){ +switch(value) { +case ES_14Point7_Free: + return "ES_14Point7_Free"; +case ES_AEM: + return "ES_AEM"; +case ES_BPSX_D1: + return "ES_BPSX_D1"; +case ES_Custom: + return "ES_Custom"; +case ES_Innovate_MTX_L: + return "ES_Innovate_MTX_L"; +case ES_NarrowBand: + return "ES_NarrowBand"; +case ES_PLX: + return "ES_PLX"; +case Force_4_bytes_size_ego_sensor: + return "Force_4_bytes_size_ego_sensor"; + } + return NULL; +} +const char *getEngine_load_mode_e(engine_load_mode_e value){ +switch(value) { +case Force_4_bytes_size_engine_load_mode: + return "Force_4_bytes_size_engine_load_mode"; +case LM_ALPHA_N: + return "LM_ALPHA_N"; +case LM_MOCK: + return "LM_MOCK"; +case LM_REAL_MAF: + return "LM_REAL_MAF"; +case LM_SPEED_DENSITY: + return "LM_SPEED_DENSITY"; + } + return NULL; +} +const char *getEngine_type_e(engine_type_e value){ +switch(value) { +case BMW_M73_F: + return "BMW_M73_F"; +case BMW_M73_M: + return "BMW_M73_M"; +case BMW_M73_MRE: + return "BMW_M73_MRE"; +case BMW_M73_MRE_SLAVE: + return "BMW_M73_MRE_SLAVE"; +case BMW_M73_PROTEUS: + return "BMW_M73_PROTEUS"; +case CAMARO_4: + return "CAMARO_4"; +case CITROEN_TU3JP: + return "CITROEN_TU3JP"; +case DEFAULT_FRANKENSO: + return "DEFAULT_FRANKENSO"; +case DODGE_NEON_1995: + return "DODGE_NEON_1995"; +case DODGE_NEON_2003_CRANK: + return "DODGE_NEON_2003_CRANK"; +case DODGE_RAM: + return "DODGE_RAM"; +case ETB_BENCH_ENGINE: + return "ETB_BENCH_ENGINE"; +case FORD_ASPIRE_1996: + return "FORD_ASPIRE_1996"; +case FORD_ESCORT_GT: + return "FORD_ESCORT_GT"; +case FORD_INLINE_6_1995: + return "FORD_INLINE_6_1995"; +case FRANKENSO_QA_ENGINE: + return "FRANKENSO_QA_ENGINE"; +case Force_4_bytes_size_engine_type: + return "Force_4_bytes_size_engine_type"; +case GY6_139QMB: + return "GY6_139QMB"; +case HELLEN_NB2: + return "HELLEN_NB2"; +case HONDA_600: + return "HONDA_600"; +case HONDA_ACCORD_1_24_SHIFTED: + return "HONDA_ACCORD_1_24_SHIFTED"; +case HONDA_ACCORD_CD: + return "HONDA_ACCORD_CD"; +case HONDA_ACCORD_CD_DIP: + return "HONDA_ACCORD_CD_DIP"; +case HONDA_ACCORD_CD_TWO_WIRES: + return "HONDA_ACCORD_CD_TWO_WIRES"; +case LADA_KALINA: + return "LADA_KALINA"; +case MAZDA_626: + return "MAZDA_626"; +case MAZDA_MIATA_2003: + return "MAZDA_MIATA_2003"; +case MAZDA_MIATA_2003_BOARD_TEST: + return "MAZDA_MIATA_2003_BOARD_TEST"; +case MAZDA_MIATA_2003_NA_RAIL: + return "MAZDA_MIATA_2003_NA_RAIL"; +case MAZDA_MIATA_NA8: + return "MAZDA_MIATA_NA8"; +case MAZDA_MIATA_NB1: + return "MAZDA_MIATA_NB1"; +case MIATA_1990: + return "MIATA_1990"; +case MIATA_1996: + return "MIATA_1996"; +case MIATA_NA6_MAP: + return "MIATA_NA6_MAP"; +case MIATA_NA6_VAF: + return "MIATA_NA6_VAF"; +case MIATA_PROTEUS_TCU: + return "MIATA_PROTEUS_TCU"; +case MICRO_RUS_EFI: + return "MICRO_RUS_EFI"; +case MINIMAL_PINS: + return "MINIMAL_PINS"; +case MITSU_4G93: + return "MITSU_4G93"; +case MRE_BOARD_NEW_TEST: + return "MRE_BOARD_NEW_TEST"; +case MRE_BOARD_OLD_TEST: + return "MRE_BOARD_OLD_TEST"; +case MRE_BODY_CONTROL: + return "MRE_BODY_CONTROL"; +case MRE_M111: + return "MRE_M111"; +case MRE_MIATA_94_MAP: + return "MRE_MIATA_94_MAP"; +case MRE_MIATA_NA6_MAP: + return "MRE_MIATA_NA6_MAP"; +case MRE_MIATA_NA6_VAF: + return "MRE_MIATA_NA6_VAF"; +case MRE_MIATA_NB2_ETB: + return "MRE_MIATA_NB2_ETB"; +case MRE_MIATA_NB2_MAF: + return "MRE_MIATA_NB2_MAF"; +case MRE_MIATA_NB2_MAP: + return "MRE_MIATA_NB2_MAP"; +case MRE_SUBARU_EJ18: + return "MRE_SUBARU_EJ18"; +case NISSAN_PRIMERA: + return "NISSAN_PRIMERA"; +case PROMETHEUS_DEFAULTS: + return "PROMETHEUS_DEFAULTS"; +case PROTEUS_ANALOG_PWM_TEST: + return "PROTEUS_ANALOG_PWM_TEST"; +case PROTEUS_DEFAULTS: + return "PROTEUS_DEFAULTS"; +case PROTEUS_MIATA_NB2: + return "PROTEUS_MIATA_NB2"; +case PROTEUS_QC_TEST_BOARD: + return "PROTEUS_QC_TEST_BOARD"; +case SACHS: + return "SACHS"; +case SUBARUEG33_DEFAULTS: + return "SUBARUEG33_DEFAULTS"; +case SUBARUEJ20G_DEFAULTS: + return "SUBARUEJ20G_DEFAULTS"; +case SUBARU_2003_WRX: + return "SUBARU_2003_WRX"; +case TEST_33816: + return "TEST_33816"; +case TEST_CIVIC_4_0_BOTH: + return "TEST_CIVIC_4_0_BOTH"; +case TEST_CIVIC_4_0_RISE: + return "TEST_CIVIC_4_0_RISE"; +case TEST_ENGINE: + return "TEST_ENGINE"; +case TEST_ENGINE_VVT: + return "TEST_ENGINE_VVT"; +case TEST_ISSUE_366_BOTH: + return "TEST_ISSUE_366_BOTH"; +case TEST_ISSUE_366_RISE: + return "TEST_ISSUE_366_RISE"; +case TEST_ISSUE_898: + return "TEST_ISSUE_898"; +case TLE8888_BENCH_ENGINE: + return "TLE8888_BENCH_ENGINE"; +case TOYOTA_2JZ_GTE_VVTi: + return "TOYOTA_2JZ_GTE_VVTi"; +case TOYOTA_JZS147: + return "TOYOTA_JZS147"; +case UNUSED_33: + return "UNUSED_33"; +case UNUSED_34: + return "UNUSED_34"; +case UNUSED_36: + return "UNUSED_36"; +case VAG_18_TURBO: + return "VAG_18_TURBO"; +case VW_ABA: + return "VW_ABA"; +case VW_B6: + return "VW_B6"; + } + return NULL; +} +const char *getEtb_function_e(etb_function_e value){ +switch(value) { +case ETB_IdleValve: + return "ETB_IdleValve"; +case ETB_None: + return "ETB_None"; +case ETB_Throttle1: + return "ETB_Throttle1"; +case ETB_Throttle2: + return "ETB_Throttle2"; +case ETB_Wastegate: + return "ETB_Wastegate"; + } + return NULL; +} +const char *getGear_e(gear_e value){ +switch(value) { +case GEAR_1: + return "GEAR_1"; +case GEAR_2: + return "GEAR_2"; +case GEAR_3: + return "GEAR_3"; +case GEAR_4: + return "GEAR_4"; +case NEUTRAL: + return "NEUTRAL"; +case REVERSE: + return "REVERSE"; + } + return NULL; +} +const char *getGppwm_channel_e(gppwm_channel_e value){ +switch(value) { +case GPPWM_Clt: + return "GPPWM_Clt"; +case GPPWM_FuelLoad: + return "GPPWM_FuelLoad"; +case GPPWM_Iat: + return "GPPWM_Iat"; +case GPPWM_IgnLoad: + return "GPPWM_IgnLoad"; +case GPPWM_Map: + return "GPPWM_Map"; +case GPPWM_Tps: + return "GPPWM_Tps"; + } + return NULL; +} +const char *getGppwm_compare_mode_e(gppwm_compare_mode_e value){ +switch(value) { +case GPPWM_GreaterThan: + return "GPPWM_GreaterThan"; +case GPPWM_LessThan: + return "GPPWM_LessThan"; + } + return NULL; +} +const char *getHip_state_e(hip_state_e value){ +switch(value) { +case IS_INTEGRATING: + return "IS_INTEGRATING"; +case IS_SENDING_SPI_COMMAND: + return "IS_SENDING_SPI_COMMAND"; +case NOT_READY: + return "NOT_READY"; +case READY_TO_INTEGRATE: + return "READY_TO_INTEGRATE"; +case WAITING_FOR_ADC_TO_SKIP: + return "WAITING_FOR_ADC_TO_SKIP"; +case WAITING_FOR_RESULT_ADC: + return "WAITING_FOR_RESULT_ADC"; + } + return NULL; +} +const char *getIdle_mode_e(idle_mode_e value){ +switch(value) { +case Force_4_bytes_size_idle_mode: + return "Force_4_bytes_size_idle_mode"; +case IM_AUTO: + return "IM_AUTO"; +case IM_MANUAL: + return "IM_MANUAL"; + } + return NULL; +} +const char *getIdle_state_e(idle_state_e value){ +switch(value) { +case BLIP: + return "BLIP"; +case Force_4bytes_size_idle_state_e: + return "Force_4bytes_size_idle_state_e"; +case INIT: + return "INIT"; +case PID_UPPER: + return "PID_UPPER"; +case PID_VALUE: + return "PID_VALUE"; +case RPM_DEAD_ZONE: + return "RPM_DEAD_ZONE"; +case TPS_THRESHOLD: + return "TPS_THRESHOLD"; + } + return NULL; +} +const char *getIgnition_mode_e(ignition_mode_e value){ +switch(value) { +case Force_4_bytes_size_ignition_mode: + return "Force_4_bytes_size_ignition_mode"; +case IM_INDIVIDUAL_COILS: + return "IM_INDIVIDUAL_COILS"; +case IM_ONE_COIL: + return "IM_ONE_COIL"; +case IM_TWO_COILS: + return "IM_TWO_COILS"; +case IM_WASTED_SPARK: + return "IM_WASTED_SPARK"; + } + return NULL; +} +const char *getInjection_mode_e(injection_mode_e value){ +switch(value) { +case Force_4_bytes_size_injection_mode: + return "Force_4_bytes_size_injection_mode"; +case IM_BATCH: + return "IM_BATCH"; +case IM_SEQUENTIAL: + return "IM_SEQUENTIAL"; +case IM_SIMULTANEOUS: + return "IM_SIMULTANEOUS"; +case IM_SINGLE_POINT: + return "IM_SINGLE_POINT"; + } + return NULL; +} +const char *getInjector_compensation_mode_e(injector_compensation_mode_e value){ +switch(value) { +case ICM_FixedRailPressure: + return "ICM_FixedRailPressure"; +case ICM_None: + return "ICM_None"; +case ICM_SensedRailPressure: + return "ICM_SensedRailPressure"; + } + return NULL; +} +const char *getInjector_pressure_type_e(injector_pressure_type_e value){ +switch(value) { +case IPT_High: + return "IPT_High"; +case IPT_Low: + return "IPT_Low"; + } + return NULL; +} +const char *getLaunchActivationMode_e(launchActivationMode_e value){ +switch(value) { +case ALWAYS_ACTIVE_LAUNCH: + return "ALWAYS_ACTIVE_LAUNCH"; +case CLUTCH_INPUT_LAUNCH: + return "CLUTCH_INPUT_LAUNCH"; +case Force_4bytes_size_launchActivationMode_e: + return "Force_4bytes_size_launchActivationMode_e"; +case SWITCH_INPUT_LAUNCH: + return "SWITCH_INPUT_LAUNCH"; + } + return NULL; +} +const char *getLog_format_e(log_format_e value){ +switch(value) { +case Force_4_bytes_size_log_format: + return "Force_4_bytes_size_log_format"; +case LF_NATIVE: + return "LF_NATIVE"; +case LM_MLV: + return "LM_MLV"; + } + return NULL; +} +const char *getMaf_sensor_type_e(maf_sensor_type_e value){ +switch(value) { +case Bosch0280218004: + return "Bosch0280218004"; +case Bosch0280218037: + return "Bosch0280218037"; +case CUSTOM: + return "CUSTOM"; +case DensoTODO: + return "DensoTODO"; +case Internal_ForceMyEnumIntSize_maf_sensor: + return "Internal_ForceMyEnumIntSize_maf_sensor"; + } + return NULL; +} +const char *getOperation_mode_e(operation_mode_e value){ +switch(value) { +case FOUR_STROKE_CAM_SENSOR: + return "FOUR_STROKE_CAM_SENSOR"; +case FOUR_STROKE_CRANK_SENSOR: + return "FOUR_STROKE_CRANK_SENSOR"; +case FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR: + return "FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR"; +case FOUR_STROKE_THREE_TIMES_CRANK_SENSOR: + return "FOUR_STROKE_THREE_TIMES_CRANK_SENSOR"; +case Force_4_bytes_size_operation_mode_e: + return "Force_4_bytes_size_operation_mode_e"; +case OM_NONE: + return "OM_NONE"; +case TWO_STROKE: + return "TWO_STROKE"; + } + return NULL; +} +const char *getPin_input_mode_e(pin_input_mode_e value){ +switch(value) { +case PI_DEFAULT: + return "PI_DEFAULT"; +case PI_PULLDOWN: + return "PI_PULLDOWN"; +case PI_PULLUP: + return "PI_PULLUP"; + } + return NULL; +} +const char *getPin_mode_e(pin_mode_e value){ +switch(value) { +case PO_DEFAULT: + return "PO_DEFAULT"; +case PO_OPENDRAIN: + return "PO_OPENDRAIN"; +case PO_PULLDOWN: + return "PO_PULLDOWN"; +case PO_PULLUP: + return "PO_PULLUP"; + } + return NULL; +} +const char *getPin_output_mode_e(pin_output_mode_e value){ +switch(value) { +case OM_DEFAULT: + return "OM_DEFAULT"; +case OM_INVERTED: + return "OM_INVERTED"; +case OM_OPENDRAIN: + return "OM_OPENDRAIN"; +case OM_OPENDRAIN_INVERTED: + return "OM_OPENDRAIN_INVERTED"; + } + return NULL; +} +const char *getSensor_chart_e(sensor_chart_e value){ +switch(value) { +case Internal_ForceMyEnumIntSize_sensor_chart: + return "Internal_ForceMyEnumIntSize_sensor_chart"; +case SC_AUX_FAST1: + return "SC_AUX_FAST1"; +case SC_DETAILED_RPM: + return "SC_DETAILED_RPM"; +case SC_MAP: + return "SC_MAP"; +case SC_OFF: + return "SC_OFF"; +case SC_RPM_ACCEL: + return "SC_RPM_ACCEL"; +case SC_TRIGGER: + return "SC_TRIGGER"; + } + return NULL; +} +const char *getSpi_device_e(spi_device_e value){ +switch(value) { +case SPI_DEVICE_1: + return "SPI_DEVICE_1"; +case SPI_DEVICE_2: + return "SPI_DEVICE_2"; +case SPI_DEVICE_3: + return "SPI_DEVICE_3"; +case SPI_DEVICE_4: + return "SPI_DEVICE_4"; +case SPI_NONE: + return "SPI_NONE"; + } + return NULL; +} +const char *getSpi_speed_e(spi_speed_e value){ +switch(value) { +case _150KHz: + return "_150KHz"; +case _1_25MHz: + return "_1_25MHz"; +case _2_5MHz: + return "_2_5MHz"; +case _5MHz: + return "_5MHz"; + } + return NULL; +} +const char *getTChargeMode_e(tChargeMode_e value){ +switch(value) { +case Force_4bytes_size_tChargeMode_e: + return "Force_4bytes_size_tChargeMode_e"; +case TCHARGE_MODE_AIR_INTERP: + return "TCHARGE_MODE_AIR_INTERP"; +case TCHARGE_MODE_RPM_TPS: + return "TCHARGE_MODE_RPM_TPS"; + } + return NULL; +} +const char *getTiming_mode_e(timing_mode_e value){ +switch(value) { +case Internal_ForceMyEnumIntSize_timing_mode: + return "Internal_ForceMyEnumIntSize_timing_mode"; +case TM_DYNAMIC: + return "TM_DYNAMIC"; +case TM_FIXED: + return "TM_FIXED"; + } + return NULL; +} +const char *getTle8888_mode_e(tle8888_mode_e value){ +switch(value) { +case TL_AUTO: + return "TL_AUTO"; +case TL_HALL: + return "TL_HALL"; +case TL_MANUAL: + return "TL_MANUAL"; +case TL_SEMI_AUTO: + return "TL_SEMI_AUTO"; + } + return NULL; +} +const char *getTrigger_event_e(trigger_event_e value){ +switch(value) { +case SHAFT_3RD_FALLING: + return "SHAFT_3RD_FALLING"; +case SHAFT_3RD_RISING: + return "SHAFT_3RD_RISING"; +case SHAFT_PRIMARY_FALLING: + return "SHAFT_PRIMARY_FALLING"; +case SHAFT_PRIMARY_RISING: + return "SHAFT_PRIMARY_RISING"; +case SHAFT_SECONDARY_FALLING: + return "SHAFT_SECONDARY_FALLING"; +case SHAFT_SECONDARY_RISING: + return "SHAFT_SECONDARY_RISING"; + } + return NULL; +} +const char *getTrigger_type_e(trigger_type_e value){ +switch(value) { +case Force_4_bytes_size_trigger_type: + return "Force_4_bytes_size_trigger_type"; +case TT_1_16: + return "TT_1_16"; +case TT_2JZ_1_12: + return "TT_2JZ_1_12"; +case TT_2JZ_3_34: + return "TT_2JZ_3_34"; +case TT_36_2_2_2: + return "TT_36_2_2_2"; +case TT_3_1_CAM: + return "TT_3_1_CAM"; +case TT_52: + return "TT_52"; +case TT_60_2_VW: + return "TT_60_2_VW"; +case TT_CHRYSLER_NGC_36_2_2: + return "TT_CHRYSLER_NGC_36_2_2"; +case TT_DAIHATSU: + return "TT_DAIHATSU"; +case TT_DODGE_NEON_1995: + return "TT_DODGE_NEON_1995"; +case TT_DODGE_NEON_1995_ONLY_CRANK: + return "TT_DODGE_NEON_1995_ONLY_CRANK"; +case TT_DODGE_NEON_2003_CAM: + return "TT_DODGE_NEON_2003_CAM"; +case TT_DODGE_NEON_2003_CRANK: + return "TT_DODGE_NEON_2003_CRANK"; +case TT_DODGE_RAM: + return "TT_DODGE_RAM"; +case TT_DODGE_STRATUS: + return "TT_DODGE_STRATUS"; +case TT_FIAT_IAW_P8: + return "TT_FIAT_IAW_P8"; +case TT_FORD_ASPIRE: + return "TT_FORD_ASPIRE"; +case TT_FORD_ST170: + return "TT_FORD_ST170"; +case TT_GM_60_2_2_2: + return "TT_GM_60_2_2_2"; +case TT_GM_7X: + return "TT_GM_7X"; +case TT_GM_LS_24: + return "TT_GM_LS_24"; +case TT_HONDA_1_24: + return "TT_HONDA_1_24"; +case TT_HONDA_1_4_24: + return "TT_HONDA_1_4_24"; +case TT_HONDA_4_24: + return "TT_HONDA_4_24"; +case TT_HONDA_4_24_1: + return "TT_HONDA_4_24_1"; +case TT_HONDA_ACCORD_1_24_SHIFTED: + return "TT_HONDA_ACCORD_1_24_SHIFTED"; +case TT_HONDA_CBR_600: + return "TT_HONDA_CBR_600"; +case TT_HONDA_K_12_1: + return "TT_HONDA_K_12_1"; +case TT_JEEP_18_2_2_2: + return "TT_JEEP_18_2_2_2"; +case TT_JEEP_4_CYL: + return "TT_JEEP_4_CYL"; +case TT_MAZDA_DOHC_1_4: + return "TT_MAZDA_DOHC_1_4"; +case TT_MAZDA_MIATA_NA: + return "TT_MAZDA_MIATA_NA"; +case TT_MAZDA_MIATA_NB1: + return "TT_MAZDA_MIATA_NB1"; +case TT_MAZDA_MIATA_VVT_TEST: + return "TT_MAZDA_MIATA_VVT_TEST"; +case TT_MAZDA_SOHC_4: + return "TT_MAZDA_SOHC_4"; +case TT_MIATA_VVT: + return "TT_MIATA_VVT"; +case TT_MITSUBISHI: + return "TT_MITSUBISHI"; +case TT_NISSAN_SR20VE: + return "TT_NISSAN_SR20VE"; +case TT_NISSAN_SR20VE_360: + return "TT_NISSAN_SR20VE_360"; +case TT_ONE: + return "TT_ONE"; +case TT_ONE_PLUS_ONE: + return "TT_ONE_PLUS_ONE"; +case TT_RENIX_44_2_2: + return "TT_RENIX_44_2_2"; +case TT_RENIX_66_2_2_2: + return "TT_RENIX_66_2_2_2"; +case TT_ROVER_K: + return "TT_ROVER_K"; +case TT_SUBARU_7_6: + return "TT_SUBARU_7_6"; +case TT_SUBARU_7_WITHOUT_6: + return "TT_SUBARU_7_WITHOUT_6"; +case TT_SUBARU_SVX: + return "TT_SUBARU_SVX"; +case TT_TOOTHED_WHEEL: + return "TT_TOOTHED_WHEEL"; +case TT_TOOTHED_WHEEL_36_1: + return "TT_TOOTHED_WHEEL_36_1"; +case TT_TOOTHED_WHEEL_36_2: + return "TT_TOOTHED_WHEEL_36_2"; +case TT_TOOTHED_WHEEL_60_2: + return "TT_TOOTHED_WHEEL_60_2"; +case TT_TRI_TACH: + return "TT_TRI_TACH"; +case TT_UNUSED: + return "TT_UNUSED"; +case TT_VVT_BOSCH_QUICK_START: + return "TT_VVT_BOSCH_QUICK_START"; +case TT_VVT_JZ: + return "TT_VVT_JZ"; +case TT_VVT_MIATA_NB2: + return "TT_VVT_MIATA_NB2"; + } + return NULL; +} +const char *getTrigger_value_e(trigger_value_e value){ +switch(value) { +case TV_FALL: + return "TV_FALL"; +case TV_RISE: + return "TV_RISE"; + } + return NULL; +} +const char *getTrigger_wheel_e(trigger_wheel_e value){ +switch(value) { +case T_CHANNEL_3: + return "T_CHANNEL_3"; +case T_NONE: + return "T_NONE"; +case T_PRIMARY: + return "T_PRIMARY"; +case T_SECONDARY: + return "T_SECONDARY"; + } + return NULL; +} +const char *getUart_device_e(uart_device_e value){ +switch(value) { +case UART_DEVICE_1: + return "UART_DEVICE_1"; +case UART_DEVICE_2: + return "UART_DEVICE_2"; +case UART_DEVICE_3: + return "UART_DEVICE_3"; +case UART_DEVICE_4: + return "UART_DEVICE_4"; +case UART_NONE: + return "UART_NONE"; + } + return NULL; +} +const char *getVe_override_e(ve_override_e value){ +switch(value) { +case VE_MAP: + return "VE_MAP"; +case VE_None: + return "VE_None"; +case VE_TPS: + return "VE_TPS"; + } + return NULL; +} +const char *getVvt_mode_e(vvt_mode_e value){ +switch(value) { +case Force_4_bytes_size_vvt_mode: + return "Force_4_bytes_size_vvt_mode"; +case MIATA_NB2: + return "MIATA_NB2"; +case VVT_2JZ: + return "VVT_2JZ"; +case VVT_4_1: + return "VVT_4_1"; +case VVT_BOSCH_QUICK_START: + return "VVT_BOSCH_QUICK_START"; +case VVT_FIRST_HALF: + return "VVT_FIRST_HALF"; +case VVT_FORD_ST170: + return "VVT_FORD_ST170"; +case VVT_INACTIVE: + return "VVT_INACTIVE"; +case VVT_SECOND_HALF: + return "VVT_SECOND_HALF"; + } + return NULL; +} diff --git a/firmware/config/boards/subaru_eg33/config/controllers/algo/auto_generated_enums.h b/firmware/config/boards/subaru_eg33/config/controllers/algo/auto_generated_enums.h new file mode 100644 index 0000000000..e72938f327 --- /dev/null +++ b/firmware/config/boards/subaru_eg33/config/controllers/algo/auto_generated_enums.h @@ -0,0 +1,59 @@ +// was generated automatically by rusEfi tool from rusefi_hw_enums.h // was generated automatically by rusEfi tool from rusefi_enums.h // by enum2string.jar tool on Sun Nov 22 13:52:01 MSK 2020 +// see also gen_config_and_enums.bat + + + +#include "rusefi_enums.h" +#include "rusefi_hw_enums.h" +#pragma once +const char *getPidAutoTune_AutoTunerState(PidAutoTune_AutoTunerState value); +const char *getPidAutoTune_Peak(PidAutoTune_Peak value); +const char *getAdc_channel_e(adc_channel_e value); +const char *getAdc_channel_mode_e(adc_channel_mode_e value); +const char *getAfr_override_e(afr_override_e value); +const char *getAir_pressure_sensor_type_e(air_pressure_sensor_type_e value); +const char *getAntiLagActivationMode_e(antiLagActivationMode_e value); +const char *getBoostType_e(boostType_e value); +const char *getBrain_pin_diag_e(brain_pin_diag_e value); +const char *getBrain_pin_e(brain_pin_e value); +const char *getCan_baudrate_e(can_baudrate_e value); +const char *getCan_nbc_e(can_nbc_e value); +const char *getCan_vss_nbc_e(can_vss_nbc_e value); +const char *getChamber_style_e(chamber_style_e value); +const char *getCranking_ignition_mode_e(cranking_ignition_mode_e value); +const char *getDebug_mode_e(debug_mode_e value); +const char *getDisplay_mode_e(display_mode_e value); +const char *getEgo_sensor_e(ego_sensor_e value); +const char *getEngine_load_mode_e(engine_load_mode_e value); +const char *getEngine_type_e(engine_type_e value); +const char *getEtb_function_e(etb_function_e value); +const char *getGear_e(gear_e value); +const char *getGppwm_channel_e(gppwm_channel_e value); +const char *getGppwm_compare_mode_e(gppwm_compare_mode_e value); +const char *getHip_state_e(hip_state_e value); +const char *getIdle_mode_e(idle_mode_e value); +const char *getIdle_state_e(idle_state_e value); +const char *getIgnition_mode_e(ignition_mode_e value); +const char *getInjection_mode_e(injection_mode_e value); +const char *getInjector_compensation_mode_e(injector_compensation_mode_e value); +const char *getInjector_pressure_type_e(injector_pressure_type_e value); +const char *getLaunchActivationMode_e(launchActivationMode_e value); +const char *getLog_format_e(log_format_e value); +const char *getMaf_sensor_type_e(maf_sensor_type_e value); +const char *getOperation_mode_e(operation_mode_e value); +const char *getPin_input_mode_e(pin_input_mode_e value); +const char *getPin_mode_e(pin_mode_e value); +const char *getPin_output_mode_e(pin_output_mode_e value); +const char *getSensor_chart_e(sensor_chart_e value); +const char *getSpi_device_e(spi_device_e value); +const char *getSpi_speed_e(spi_speed_e value); +const char *getTChargeMode_e(tChargeMode_e value); +const char *getTiming_mode_e(timing_mode_e value); +const char *getTle8888_mode_e(tle8888_mode_e value); +const char *getTrigger_event_e(trigger_event_e value); +const char *getTrigger_type_e(trigger_type_e value); +const char *getTrigger_value_e(trigger_value_e value); +const char *getTrigger_wheel_e(trigger_wheel_e value); +const char *getUart_device_e(uart_device_e value); +const char *getVe_override_e(ve_override_e value); +const char *getVvt_mode_e(vvt_mode_e value); diff --git a/firmware/config/boards/subaru_eg33/config/gen_config.sh b/firmware/config/boards/subaru_eg33/config/gen_config.sh new file mode 100755 index 0000000000..75d22ab7a6 --- /dev/null +++ b/firmware/config/boards/subaru_eg33/config/gen_config.sh @@ -0,0 +1,49 @@ +#/!bin/sh +# This batch files reads rusefi_config.txt and produses firmware persistent configuration headers +# the storage section of rusefi.ini is updated as well + +BOARDNAME=subaru_eg33 +SHORT_BOARDNAME=${BOARDNAME}_f7 +BOARD_DIR=config/boards/${BOARDNAME} +BUILD_DIR=build_${BOARDNAME} + +mkdir -p ${BUILD_DIR} + +echo This batch files reads rusefi_config.txt and produses firmware persistent configuration headers +echo the storage section of rusefi_${BOARDNAME}.ini is updated as well + +java \ + -DSystemOut.name=gen_config_subaru_eg33_board \ + -cp ../java_tools/ConfigDefinition.jar \ + com.rusefi.board_generator.BoardReader \ + -yaml config/boards/${BOARDNAME}/mapping.yaml \ + -firmware_path . \ + -output_file tunerstudio/generated/${BOARDNAME}_prefix.txt \ + -enumInputFile controllers/algo/rusefi_enums.h \ + -enumInputFile ${BOARD_DIR}/rusefi_hw_enums.h \ + > gen_config_${BOARDNAME}_1.log + +[ $? -eq 0 ] || { echo "ERROR generating TunerStudio config for ${BOARDNAME}"; exit 1; } + +java \ + -DSystemOut.name=gen_config_subaru_eg33 \ + -jar ../java_tools/ConfigDefinition.jar \ + -definition integration/rusefi_config.txt \ + -tool ${BOARD_DIR}/config/gen_config.sh \ + -ts_destination tunerstudio \ + -cache ${SHORT_BOARDNAME} \ + -cache_zip_file tunerstudio/generated/cache.zip \ + -firing_order controllers/algo/firing_order.h \ + -with_c_defines false \ + -initialize_to_zero false \ + -ts_output_name generated/rusefi_${SHORT_BOARDNAME}.ini \ + -c_defines ${BOARD_DIR}/config/controllers/algo/rusefi_generated.h \ + -c_destination ${BOARD_DIR}/config/controllers/algo/engine_configuration_generated_structures.h \ + -signature tunerstudio/generated/signature_${SHORT_BOARDNAME}.txt \ + -signature_destination controllers/generated/signature_${SHORT_BOARDNAME}.h \ + -enumInputFile controllers/algo/rusefi_enums.h \ + -prepend tunerstudio/generated/${BOARDNAME}_prefix.txt \ + -prepend config/boards/${BOARDNAME}/prepend.txt \ + > gen_config_${BOARDNAME}_2.log + +[ $? -eq 0 ] || { echo "ERROR generating TunerStudio config for ${BOARDNAME}"; exit 1; } diff --git a/firmware/config/boards/subaru_eg33/config/gen_enum_to_string.sh b/firmware/config/boards/subaru_eg33/config/gen_enum_to_string.sh new file mode 100755 index 0000000000..de45ed6725 --- /dev/null +++ b/firmware/config/boards/subaru_eg33/config/gen_enum_to_string.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +echo This batch files reads rusefi_enums.h and produses auto_generated_enums.* files + +#cd ../../../.. +#cd .. + +BOARD=subaru_eg33 + +java -DSystemOut.name=gen_enum_to_string \ + -jar ../java_tools/enum2string.jar \ + -inputPath . \ + -outputPath config/boards/${BOARD}/config/controllers/algo \ + -enumInputFile controllers/algo/rusefi_enums.h \ + -enumInputFile config/boards/${BOARD}/rusefi_hw_enums.h diff --git a/firmware/config/boards/subaru_eg33/config/tunerstudio/subaru_eg33_prefix.txt b/firmware/config/boards/subaru_eg33/config/tunerstudio/subaru_eg33_prefix.txt new file mode 100644 index 0000000000..c722fd0db4 --- /dev/null +++ b/firmware/config/boards/subaru_eg33/config/tunerstudio/subaru_eg33_prefix.txt @@ -0,0 +1,4 @@ + #define output_pin_e_enum "NONE","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID"," - Self Shutdown","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","D17 - FAN 1","D03 - FAN 2","C16 - Tacho out","C14 - FPump modulator","D23 - FPump relay","D22 - EGR control","D19 - CE indicator","C15 - AUX1 out","D18 - Auxillary air valve","D06 - Absorber purge","D02 - IDLE open","D01 - IDLE close","XP2 - AUX0 out","XP2 - AUX1 out","B08 - AC clutch","D20 - Charge valve","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID" + #define adc_channel_e_enum "TP - AIN 0","int - IGN1 current","int - IGN2 current","B05 - MAF Ain","INVALID","INVALID","A02 - Battery Ain","int - Knock","A05 - Oxyg #2 Ain","A04 - EGR t Ait","--- - Atm P Ain","A18 - AUX0 Ain","B02 - TPS Ain","int - MC33972 DIN","A03 - Coolant t Ain","A06 - Oxyg #1 Ain","NONE" + #define brain_input_pin_e_enum "NONE","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","B11 - Speed Din (GPIO)","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","A08 - Crank #2","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","C01 - Crank #1","INVALID","A07 - Cam","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","B11 - Speed Din (MC33972)","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID" + #define switch_input_pin_e_enum "NONE","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","TP - SP1 Din","TP - SP2 Din","TP - SP3 Din","INVALID","C10 - Starter Din","C12 - Memory SW Din","C13 - Test SW Din","D04 - California ID Din","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","C09 - Air Condition request Din","B12 - IGN Din","INVALID","B10 - N pos Din","B09 - P pos Din","A20 - Torque Ctrl Din","A19 - AC Ctrl Din","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID" diff --git a/firmware/config/boards/subaru_eg33/efifeatures.h b/firmware/config/boards/subaru_eg33/efifeatures.h new file mode 100644 index 0000000000..54caadde50 --- /dev/null +++ b/firmware/config/boards/subaru_eg33/efifeatures.h @@ -0,0 +1,145 @@ +/** + * @file boards/subaru_eg33/efifeatures.h + * + * @brief In this header we can override efifeatures.h. + * + * @date Feb 06, 2021 + * @author Andrey Gusakov, 2021 + */ + +#include "../../stm32f7ems/efifeatures.h" + +#ifndef EFIFEATURES_SUBARUEG33_H_ +#define EFIFEATURES_SUBARUEG33_H_ + +/* LEDs */ +#undef LED_ERROR_BRAIN_PIN_MODE +#define LED_ERROR_BRAIN_PIN_MODE INVERTED_OUTPUT +#undef LED_WARNING_BRAIN_PIN_MODE +#define LED_WARNING_BRAIN_PIN_MODE INVERTED_OUTPUT +#undef LED_RUNING_BRAIN_PIN_MODE +#define LED_RUNING_BRAIN_PIN_MODE INVERTED_OUTPUT + +/* debug console */ +#undef EFI_USE_UART_FOR_CONSOLE +#define EFI_USE_UART_FOR_CONSOLE TRUE +#undef EFI_CONSOLE_SERIAL_DEVICE +#define EFI_CONSOLE_SERIAL_DEVICE (&SD1) + +/* TunerStudio binary protocol */ +/* do not use UART device for console */ +#undef TS_UART_DEVICE + +/* do not use serial device for console */ +#undef TS_SERIAL_DEVICE + +#undef BOARD_TLE6240_COUNT +#define BOARD_TLE6240_COUNT 1 + +#define TLE6240_RESET_PORT GPIOH +#define TLE6240_RESET_PAD 6 +#define TLE6240_DIRECT_IO \ + /* IN1..3 grounded */ \ + [0] = {.port = NULL, .pad = 0}, \ + [1] = {.port = NULL, .pad = 0}, \ + /* IN3 - D_TACH_OUT */ \ + [2] = {.port = GPIOG, .pad = 2},\ + /* IN4 - grounded */ \ + [3] = {.port = NULL, .pad = 0}, \ + /* IN9..10 grounded */ \ + [4] = {.port = NULL, .pad = 15},\ + [5] = {.port = NULL, .pad = 14},\ + /* IN11 - D_IDLE_OPEN */ \ + [6] = {.port = GPIOC, .pad = 6},\ + /* IN12 - D_IDLE_CLOSE */ \ + [7] = {.port = GPIOC, .pad = 8} + +#undef BOARD_MC33972_COUNT +#define BOARD_MC33972_COUNT 1 + +#undef BOARD_MC33810_COUNT +#define BOARD_MC33810_COUNT 2 + +#undef BOARD_TLE8888_COUNT +#define BOARD_TLE8888_COUNT 0 + +#undef EFI_RTC +#define EFI_RTC FALSE + +#undef EFI_POTENTIOMETER +#define EFI_POTENTIOMETER FALSE + +#undef EFI_MAX_31855 +#define EFI_MAX_31855 FALSE + +#undef EFI_HD44780_LCD +#define EFI_HD44780_LCD FALSE + +#undef EFI_IDLE_CONTROL +#define EFI_IDLE_CONTROL TRUE + +#undef EFI_USB_SERIAL +#define EFI_USB_SERIAL TRUE + +#undef EFI_FUEL_PUMP +#define EFI_FUEL_PUMP TRUE + +#undef MMC_CARD_SPI +#define MMC_CARD_SPI SPID1 + +#define ADC_CHANNEL_VREF ADC_CHANNEL_IN14 + +#undef EFI_UART_GPS +#define EFI_UART_GPS FALSE + +#undef EFI_BLUETOOTH_SETUP +#define EFI_BLUETOOTH_SETUP FALSE + +#undef SERIAL_SPEED +#define SERIAL_SPEED 115200 + +#ifdef EFI_CONSOLE_SERIAL_DEVICE + #undef EFI_CONSOLE_TX_PORT + #define EFI_CONSOLE_TX_PORT GPIOA + #undef EFI_CONSOLE_TX_PIN + #define EFI_CONSOLE_TX_PIN 9 + #undef EFI_CONSOLE_RX_PORT + #define EFI_CONSOLE_RX_PORT GPIOA + #undef EFI_CONSOLE_RX_PIN + #define EFI_CONSOLE_RX_PIN 10 + #undef EFI_CONSOLE_AF + #define EFI_CONSOLE_AF 7 +#endif + +#undef TS_SERIAL_AF +#define TS_SERIAL_AF 8 + +/* no console switch */ +#undef CONSOLE_MODE_SWITCH_PORT +#undef CONSOLE_MODE_SWITCH_PIN +#define GET_CONSOLE_MODE_VALUE() (FALSE) + +/* no reset switch */ +#undef CONFIG_RESET_SWITCH_PORT +#undef CONFIG_RESET_SWITCH_PIN + +#undef ADC_VCC +#define ADC_VCC 2.5f + +#undef EFI_MAIN_RELAY_CONTROL +#define EFI_MAIN_RELAY_CONTROL FALSE + +#undef EFI_MEMS +#define EFI_MEMS FALSE + +#undef EFI_IDLE_PID_CIC +#define EFI_IDLE_PID_CIC TRUE + +#define RPM_LOW_THRESHOLD 8 // RPM=8 is an empirical lower sensitivity threshold of MAX9926 for 60-2 +#define NO_RPM_EVENTS_TIMEOUT_SECS 5 // (RPM < 12) + +#define EFI_PRINT_ERRORS_AS_WARNINGS TRUE + +#define EFI_NARROW_EGO_AVERAGING TRUE + +#endif /* EFIFEATURES_SUBARUEG33_H_ */ diff --git a/firmware/config/boards/subaru_eg33/halconf.h b/firmware/config/boards/subaru_eg33/halconf.h new file mode 100644 index 0000000000..2ee1963336 --- /dev/null +++ b/firmware/config/boards/subaru_eg33/halconf.h @@ -0,0 +1,41 @@ +/** + * @file boards/subarue_eg33/halconf.h + * + * @brief In this header we can override halconf.h. + * + * @date Feb 06, 2021 + * @author Andrey Gusakov, 2021 + */ + +#include "mcuconf.h" +#include "../../stm32f7ems/halconf.h" + +#ifndef _HALCONF_SUBARUEG33_H_ +#define _HALCONF_SUBARUEG33_H_ + +#undef HAL_USE_PAL +#define HAL_USE_PAL TRUE +#undef PAL_USE_CALLBACKS +#define PAL_USE_CALLBACKS TRUE +#undef HAL_TRIGGER_USE_PAL +#define HAL_TRIGGER_USE_PAL TRUE + +#undef HAL_USE_I2C +#define HAL_USE_I2C FALSE + +#undef HAL_USE_SERIAL +#define HAL_USE_SERIAL TRUE + +//#if TS_UART_DMA_MODE +#undef HAL_USE_UART +#define HAL_USE_UART FALSE +#undef UART_USE_WAIT +#define UART_USE_WAIT FALSE +//#else +//#define HAL_USE_UART FALSE +//#endif + +#undef HAL_USE_USB_MSD +#define HAL_USE_USB_MSD FALSE + +#endif /* _HALCONF_SUBARUEG33_H_ */ diff --git a/firmware/config/boards/subaru_eg33/make.sh b/firmware/config/boards/subaru_eg33/make.sh new file mode 100755 index 0000000000..f3600f2445 --- /dev/null +++ b/firmware/config/boards/subaru_eg33/make.sh @@ -0,0 +1,15 @@ +#!/bin/bash +export PROJECT_BOARD=subaru_eg33 +export PROJECT_CPU=ARCH_STM32F7 +export MCU=cortex-m7 +export EXTRA_PARAMS="-DSHORT_BOARD_NAME=subaru_eg33_f7 -DDUMMY -DEFI_ENABLE_ASSERTS=FALSE -DCH_DBG_ENABLE_ASSERTS=FALSE -DCH_DBG_ENABLE_STACK_CHECK=FALSE -DCH_DBG_FILL_THREADS=FALSE -DCH_DBG_THREADS_PROFILING=FALSE" +export DEFAULT_ENGINE_TYPE="-DDEFAULT_ENGINE_TYPE=SUBARUEG33_DEFAULTS" +#echo $EXTRA_PARAMS +#export DEBUG_LEVEL_OPT="-O0" +#export USE_BOOTLOADER=yes + +#export LDSCRIPT="config/boards/NUCLEO_F767/STM32F76xxI.ld" +#bash config/boards/common_make.sh + +#CROSS_COMPILE=../../toolchain/gcc-arm-none-eabi-8-2018-q4-major/bin/arm-none-eabi- make $* +CROSS_COMPILE=../../toolchain/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi- make $* \ No newline at end of file diff --git a/firmware/config/boards/subaru_eg33/mapping.yaml b/firmware/config/boards/subaru_eg33/mapping.yaml new file mode 100644 index 0000000000..e2ee2d3771 --- /dev/null +++ b/firmware/config/boards/subaru_eg33/mapping.yaml @@ -0,0 +1,92 @@ +outputs: + # MCU + GPIOH_7: " - Self Shutdown" + # TLE6240 + TLE6240_PIN_1: "D17 - FAN 1" + TLE6240_PIN_2: "D03 - FAN 2" + TLE6240_PIN_3: "C16 - Tacho out" + TLE6240_PIN_4: "C14 - FPump modulator" + TLE6240_PIN_5: "D23 - FPump relay" + TLE6240_PIN_6: "D22 - EGR control" + TLE6240_PIN_7: "D19 - CE indicator" + TLE6240_PIN_8: "C15 - AUX1 out" + TLE6240_PIN_9: "D18 - Auxillary air valve" + TLE6240_PIN_10: "D06 - Absorber purge" + TLE6240_PIN_11: "D02 - IDLE open" + TLE6240_PIN_12: "D01 - IDLE close" + TLE6240_PIN_13: "XP2 - AUX0 out" + TLE6240_PIN_14: "XP2 - AUX1 out" + TLE6240_PIN_15: "B08 - AC clutch" + TLE6240_PIN_16: "D20 - Charge valve" + # MC33810s + MC33810_0_PIN_1: "D13 - INJ 1" + MC33810_0_PIN_2: "D11 - INJ 3" + MC33810_0_PIN_3: "A01 - INJ 5" + MC33810_0_PIN_4: "XP2 - INJ 7" + MC33810_0_PIN_5: "D07 - IGN 1" + MC33810_0_PIN_6: "D09 - IGN 3" + MC33810_0_PIN_7: "XP2 - IGN 7 (HP)" + MC33810_0_PIN_8: "D21 - IGN 5" + MC33810_1_PIN_1: "D12 - INJ 2" + MC33810_1_PIN_2: "D26 - INJ 4" + MC33810_1_PIN_3: "A12 - INJ 6" + MC33810_1_PIN_4: "XP6 - INJ 8" + MC33810_1_PIN_5: "XP6 - IGN 8 (HP)" + MC33810_1_PIN_6: "D16 - IGN 6" + MC33810_1_PIN_7: "D08 - IGN 2" + MC33810_1_PIN_8: "D10 - IGN 4" + +switch_inputs: + MC33972_PIN_1: "TP - SP1 Din" + MC33972_PIN_2: "TP - SP2 Din" + MC33972_PIN_3: "TP - SP3 Din" + MC33972_PIN_5: "C10 - Starter Din" + MC33972_PIN_6: "C12 - Memory SW Din" + MC33972_PIN_7: "C13 - Test SW Din" + MC33972_PIN_8: "D04 - California ID Din" + MC33972_PIN_16: "C09 - Air Condition request Din" + MC33972_PIN_17: "B12 - IGN Din" + MC33972_PIN_19: "B10 - N pos Din" + MC33972_PIN_20: "B09 - P pos Din" + MC33972_PIN_21: "A20 - Torque Ctrl Din" + MC33972_PIN_22: "A19 - AC Ctrl Din" + +event_inputs: + GPIOH_10: "C01 - Crank #1" + GPIOE_9: "A08 - Crank #2" + GPIOH_12: "A07 - Cam" + GPIOD_14: "B11 - Speed Din (GPIO)" + MC33972_PIN_18: "B11 - Speed Din (MC33972)" + +analog_inputs: + EFI_ADC_0: "TP - AIN 0" + EFI_ADC_1: "int - IGN1 current" + EFI_ADC_2: "int - IGN2 current" + EFI_ADC_3: "B05 - MAF Ain" +# EFI_ADC_4: "n.u." + EFI_ADC_6: "A02 - Battery Ain" + EFI_ADC_7: "int - Knock" + EFI_ADC_8: "A05 - Oxyg #2 Ain" + EFI_ADC_9: "A04 - EGR t Ait" + EFI_ADC_10: "--- - Atm P Ain" + EFI_ADC_11: "A18 - AUX0 Ain" + EFI_ADC_12: "B02 - TPS Ain" + EFI_ADC_13: "int - MC33972 DIN" + EFI_ADC_14: "A03 - Coolant t Ain" + EFI_ADC_15: "A06 - Oxyg #1 Ain" +# EFI_ADC3_4: "XP2 - OPT0" +# EFI_ADC3_5: "n.u." +# EFI_ADC3_6: "n.u." +# EFI_ADC3_7: "n.u." +# EFI_ADC3_8: "n.u." +# EFI_ADC3_9: "XP6 - OPT3" +# EFI_ADC3_14: "XP6 - OPT2" +# EFI_ADC3_15: "XP2 - OPT1" +# MC33972_PIN_4: "A03 - Coolant t Ain" +# MC33972_PIN_9: "A04 - EGR t Ain" +# MC33972_PIN_10: "A06 - Oxyg #1" +# MC33972_PIN_11: "A05 - Oxyg #2" +# MC33972_PIN_12: "--- - Atm P Ain" +# MC33972_PIN_13: "A18 - AUX0 Ain" +# MC33972_PIN_14: "B02 - TPS Ain" +# MC33972_PIN_15: "B05 - MAF Ain" \ No newline at end of file diff --git a/firmware/config/boards/subaru_eg33/mcuconf.h b/firmware/config/boards/subaru_eg33/mcuconf.h new file mode 100644 index 0000000000..5d7c7a021e --- /dev/null +++ b/firmware/config/boards/subaru_eg33/mcuconf.h @@ -0,0 +1,94 @@ +/** + * @file boards/subarue-eg33/mcuconf.h + * + * @brief In this header we can override mcuconf.h. + * + * @date Feb 06, 2021 + * @author Andrey Gusakov, 2021 + */ + +#include "../../stm32f7ems/mcuconf.h" + +#ifndef _MCUCONF_SUBARUEG33_H_ +#define _MCUCONF_SUBARUEG33_H_ + +/* clocks adjust for 25 MHz ocs */ +#undef STM32_PLLM_VALUE +#define STM32_PLLM_VALUE 25 + +//#undef CORTEX_ENABLE_WFI_IDLE +#define CORTEX_ENABLE_WFI_IDLE FALSE + +//#undef STM32_LSE_ENABLED +//#define STM32_LSE_ENABLED FALSE + +#undef STM32_RTCSEL +#define STM32_RTCSEL STM32_RTCSEL_HSEDIV // STM32_RTCSEL_LSI + +/* serials and uarts */ +#undef STM32_SERIAL_USE_USART1 +#undef STM32_UART_USE_USART1 +//#if TS_UART_DMA_MODE +//#define STM32_SERIAL_USE_UART1 FALSE +//#else +#define STM32_SERIAL_USE_USART1 TRUE +#define STM32_UART_USE_USART1 FALSE +//#endif + +/* enable serial driver for USART2 to make usbconsole.c happy: + * as '#define USB_SERIAL_DRIVER SD2' in usbconsole.h and + * sdStart(&USB_SERIAL_DRIVER, NULL); is called unconditionaly */ +#undef STM32_SERIAL_USE_USART2 +#undef STM32_UART_USE_USART2 +#define STM32_SERIAL_USE_USART2 TRUE +#define STM32_UART_USE_USART2 FALSE + +#undef STM32_SERIAL_USE_USART3 +#undef STM32_UART_USE_USART3 +#define STM32_SERIAL_USE_USART3 FALSE +#define STM32_UART_USE_USART3 FALSE + +#undef STM32_UART_USE_USART3 +#define STM32_UART_USE_USART3 FALSE + +#undef STM32_UART_USE_UART4 +#define STM32_UART_USE_UART4 FALSE + +#undef STM32_USB_USE_OTG1 +#define STM32_USB_USE_OTG1 TRUE + +#undef STM32_USB_USE_USB1 +#define STM32_USB_USE_USB1 TRUE + +#undef STM32_I2C_USE_I2C1 +#define STM32_I2C_USE_I2C1 FALSE + +#undef STM32_SPI_USE_SPI2 +#define STM32_SPI_USE_SPI2 FALSE + +#undef STM32_SPI_USE_SPI4 +#define STM32_SPI_USE_SPI4 TRUE + +#undef STM32_SPI_USE_SPI5 +#define STM32_SPI_USE_SPI5 TRUE + +#undef STM32_ADC_USE_ADC3 +#define STM32_ADC_USE_ADC3 TRUE + +/* default STM32_DMA_STREAM_ID(2, 4) used by ADC1 */ +#undef STM32_SPI_SPI5_TX_DMA_STREAM +#define STM32_SPI_SPI5_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 6) + +/* To remove futher possible conflict */ +#undef STM32_SPI_SPI6_RX_DMA_STREAM + +#undef STM32_ICU_USE_TIM3 +#define STM32_ICU_USE_TIM3 TRUE + +#undef STM32_CAN_USE_CAN2 +#define STM32_CAN_USE_CAN2 FALSE + +//#undef STM32_CAN_CAN1_IRQ_PRIORITY +//#define STM32_CAN_CAN1_IRQ_PRIORITY 4 + +#endif /* _MCUCONF_SUBARUEG33_H_ */ diff --git a/firmware/config/boards/subaru_eg33/prepend.txt b/firmware/config/boards/subaru_eg33/prepend.txt new file mode 100644 index 0000000000..09ff57dcd3 --- /dev/null +++ b/firmware/config/boards/subaru_eg33/prepend.txt @@ -0,0 +1,18 @@ +//TODO: understand this. + +#define ts_show_hip9011 true +#define ts_show_cj125 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 true +#define ts_show_analog_divider false +#define ts_show_spi true +#define ts_show_sd_card true +#define ts_show_can_pins true +#define ts_show_tunerstudio_port false + +#define show_test_presets false +#define show_Frankenso_presets false +#define show_Proteus_presets false diff --git a/firmware/config/boards/subaru_eg33/readme.txt b/firmware/config/boards/subaru_eg33/readme.txt new file mode 100644 index 0000000000..c8c464ae69 --- /dev/null +++ b/firmware/config/boards/subaru_eg33/readme.txt @@ -0,0 +1,4 @@ +subaru EG33 board. + +https://github.com/dron0gus/rusefi +https://rusefi.com/forum/viewtopic.php?p=35502 diff --git a/firmware/config/boards/subaru_eg33/rusefi_hw_enums.h b/firmware/config/boards/subaru_eg33/rusefi_hw_enums.h new file mode 100644 index 0000000000..a3012705d3 --- /dev/null +++ b/firmware/config/boards/subaru_eg33/rusefi_hw_enums.h @@ -0,0 +1,294 @@ +/* + * @file rusefi_hw_enums.h + * + * @date Jun 2, 2019 + * @author Andrey Belomutskiy, (c) 2012-2020 + */ + +#pragma once + +// todo: migrate/unify with pin_output_mode_e? rename? something is messy here +// this enum is currently only used for SPI pins +typedef enum __attribute__ ((__packed__)) { +// todo: here we have a rare example of stm32-specific enum, todo: make this not stm32 specific? + PO_DEFAULT = 0, + PO_OPENDRAIN = 4, // PAL_STM32_OTYPE_OPENDRAIN + PO_PULLUP = 32, // PAL_STM32_PUDR_PULLUP + PO_PULLDOWN = 64 // PAL_STM32_PUPDR_PULLDOWN +} pin_mode_e; + +/** + * Hardware pin. This enum is platform-specific. + */ +typedef enum __attribute__ ((__packed__)) { + GPIO_UNASSIGNED = 0, + GPIO_INVALID = 1, + + GPIOA_0 = 2, + GPIOA_1 = 3, + GPIOA_2 = 4, + GPIOA_3 = 5, + GPIOA_4 = 6, + GPIOA_5 = 7, + GPIOA_6 = 8, + GPIOA_7 = 9, + GPIOA_8 = 10, + GPIOA_9 = 11, + GPIOA_10 = 12, + GPIOA_11 = 13, + GPIOA_12 = 14, + GPIOA_13 = 15, + GPIOA_14 = 16, + GPIOA_15 = 17, + + GPIOB_0 = 18, + GPIOB_1 = 19, + GPIOB_2 = 20, + GPIOB_3 = 21, + GPIOB_4 = 22, + GPIOB_5 = 23, + GPIOB_6 = 24, + GPIOB_7 = 25, + GPIOB_8 = 26, + GPIOB_9 = 27, + GPIOB_10 = 28, + GPIOB_11 = 29, + GPIOB_12 = 30, + GPIOB_13 = 31, + GPIOB_14 = 32, + GPIOB_15 = 33, + + GPIOC_0 = 34, + GPIOC_1 = 35, + GPIOC_2 = 36, + GPIOC_3 = 37, + GPIOC_4 = 38, + GPIOC_5 = 39, + GPIOC_6 = 40, + GPIOC_7 = 41, + GPIOC_8 = 42, + GPIOC_9 = 43, + GPIOC_10 = 44, + GPIOC_11 = 45, + GPIOC_12 = 46, + GPIOC_13 = 47, + GPIOC_14 = 48, + GPIOC_15 = 49, + + GPIOD_0 = 50, + GPIOD_1 = 51, + GPIOD_2 = 52, + GPIOD_3 = 53, + GPIOD_4 = 54, + GPIOD_5 = 55, + GPIOD_6 = 56, + GPIOD_7 = 57, + GPIOD_8 = 58, + GPIOD_9 = 59, + GPIOD_10 = 60, + GPIOD_11 = 61, + GPIOD_12 = 62, + GPIOD_13 = 63, + GPIOD_14 = 64, + GPIOD_15 = 65, + + GPIOE_0 = 66, + GPIOE_1 = 67, + GPIOE_2 = 68, + GPIOE_3 = 69, + GPIOE_4 = 70, + GPIOE_5 = 71, + GPIOE_6 = 72, + GPIOE_7 = 73, + GPIOE_8 = 74, + GPIOE_9 = 75, + GPIOE_10 = 76, + GPIOE_11 = 77, + GPIOE_12 = 78, + GPIOE_13 = 79, + GPIOE_14 = 80, + GPIOE_15 = 81, + + GPIOF_0 = 82, + GPIOF_1 = 83, + GPIOF_2 = 84, + GPIOF_3 = 85, + GPIOF_4 = 86, + GPIOF_5 = 87, + GPIOF_6 = 88, + GPIOF_7 = 89, + GPIOF_8 = 90, + GPIOF_9 = 91, + GPIOF_10 = 92, + GPIOF_11 = 93, + GPIOF_12 = 94, + GPIOF_13 = 95, + GPIOF_14 = 96, + GPIOF_15 = 97, + + GPIOG_0 = 98, + GPIOG_1 = 99, + GPIOG_2 = 100, + GPIOG_3 = 101, + GPIOG_4 = 102, + GPIOG_5 = 103, + GPIOG_6 = 104, + GPIOG_7 = 105, + GPIOG_8 = 106, + GPIOG_9 = 107, + GPIOG_10 = 108, + GPIOG_11 = 109, + GPIOG_12 = 110, + GPIOG_13 = 111, + GPIOG_14 = 112, + GPIOG_15 = 113, + + GPIOH_0 = 114, + GPIOH_1 = 115, + GPIOH_2 = 116, + GPIOH_3 = 117, + GPIOH_4 = 118, + GPIOH_5 = 119, + GPIOH_6 = 120, + GPIOH_7 = 121, + GPIOH_8 = 122, + GPIOH_9 = 123, + GPIOH_10 = 124, + GPIOH_11 = 125, + GPIOH_12 = 126, + GPIOH_13 = 127, + GPIOH_14 = 128, + GPIOH_15 = 129, + + GPIOI_0 = 130, + GPIOI_1 = 131, + GPIOI_2 = 132, + GPIOI_3 = 133, + GPIOI_4 = 134, + GPIOI_5 = 135, + GPIOI_6 = 136, + GPIOI_7 = 137, + GPIOI_8 = 138, + GPIOI_9 = 139, + GPIOI_10 = 140, + GPIOI_11 = 141, + GPIOI_12 = 142, + GPIOI_13 = 143, + GPIOI_14 = 144, + GPIOI_15 = 145, + + TLE6240_PIN_1 = 146, + TLE6240_PIN_2 = 147, + TLE6240_PIN_3 = 148, + TLE6240_PIN_4 = 149, + TLE6240_PIN_5 = 150, + TLE6240_PIN_6 = 151, + TLE6240_PIN_7 = 152, + TLE6240_PIN_8 = 153, + TLE6240_PIN_9 = 154, + TLE6240_PIN_10 = 155, + TLE6240_PIN_11 = 156, + TLE6240_PIN_12 = 157, + TLE6240_PIN_13 = 158, + TLE6240_PIN_14 = 159, + TLE6240_PIN_15 = 160, + TLE6240_PIN_16 = 161, + + MC33972_PIN_1 = 162, + MC33972_PIN_2 = 163, + MC33972_PIN_3 = 164, + MC33972_PIN_4 = 165, + MC33972_PIN_5 = 166, + MC33972_PIN_6 = 167, + MC33972_PIN_7 = 168, + MC33972_PIN_8 = 169, + MC33972_PIN_9 = 170, + MC33972_PIN_10 = 171, + MC33972_PIN_11 = 172, + MC33972_PIN_12 = 173, + MC33972_PIN_13 = 174, + MC33972_PIN_14 = 175, + MC33972_PIN_15 = 176, + MC33972_PIN_16 = 177, + MC33972_PIN_17 = 178, + MC33972_PIN_18 = 179, + MC33972_PIN_19 = 180, + MC33972_PIN_20 = 181, + MC33972_PIN_21 = 182, + MC33972_PIN_22 = 183, + + MC33810_0_OUT_0 = 184, + MC33810_0_OUT_1 = 185, + MC33810_0_OUT_2 = 186, + MC33810_0_OUT_3 = 187, + MC33810_0_GD_0 = 188, + MC33810_0_GD_1 = 189, + MC33810_0_GD_2 = 190, + MC33810_0_GD_3 = 191, + + MC33810_1_OUT_0 = 192, + MC33810_1_OUT_1 = 193, + MC33810_1_OUT_2 = 194, + MC33810_1_OUT_3 = 195, + MC33810_1_GD_0 = 196, + MC33810_1_GD_1 = 197, + MC33810_1_GD_2 = 198, + MC33810_1_GD_3 = 199, +} brain_pin_e; + +/* Plase keep updating these defines */ +#define BRAIN_PIN_ONCHIP_LAST GPIOI_15 +#define BRAIN_PIN_ONCHIP_PINS (BRAIN_PIN_ONCHIP_LAST - GPIOA_0 + 1) +#define BRAIN_PIN_LAST MC33810_1_GD_3 +#define BRAIN_PIN_TOTAL_PINS (BRAIN_PIN_LAST - GPIOA_0 + 1) +/* Plase keep updating these defines */ + +/* diagnostic for brain pins + * can be combination of few bits + * defined as bit mask */ +typedef enum __attribute__ ((__packed__)) +{ + PIN_OK = 0, + PIN_OPEN = 0x01, + PIN_SHORT_TO_GND = 0x02, + PIN_SHORT_TO_BAT = 0x04, + PIN_OVERLOAD = 0x08, + PIN_DRIVER_OVERTEMP = 0x10, + PIN_INVALID = 0x80 +} brain_pin_diag_e; + +typedef enum __attribute__ ((__packed__)) { + EFI_ADC_NONE = 0, + + EFI_ADC_0 = 1, + EFI_ADC_1 = 2, + EFI_ADC_2 = 3, + EFI_ADC_3 = 4, + EFI_ADC_4 = 5, + EFI_ADC_5 = 6, + EFI_ADC_6 = 7, + EFI_ADC_7 = 8, + EFI_ADC_8 = 9, + EFI_ADC_9 = 10, + EFI_ADC_10 = 11, + EFI_ADC_11 = 12, + EFI_ADC_12 = 13, + EFI_ADC_13 = 14, + EFI_ADC_14 = 15, + EFI_ADC_15 = 16, + + EFI_ADC3_4 = 17, // PF6 + EFI_ADC3_5 = 18, // PF7 + EFI_ADC3_6 = 19, // PF8 + EFI_ADC3_7 = 20, // PF9 + EFI_ADC3_8 = 21, // PF10 + EFI_ADC3_9 = 22, // PF3 + EFI_ADC3_14 = 23, // PF4 + EFI_ADC3_15 = 24, // PF5 + + EFI_ADC_TEMP_SENSOR = 25, // Internal temp sensor + + EFI_ADC_LAST_CHANNEL = 26, // Please keep this in sync with the last valid channel index! + + EFI_ADC_ERROR = 50, +} adc_channel_e; diff --git a/firmware/config/engines/subaru.cpp b/firmware/config/engines/subaru.cpp index 24c8766ce5..bfaca21e56 100644 --- a/firmware/config/engines/subaru.cpp +++ b/firmware/config/engines/subaru.cpp @@ -62,3 +62,60 @@ void setSubaruEJ18_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) { } + +/* + * Subaru SVX (Alcyone SVX) + */ + +void setSubaruEG33Defaults(DECLARE_ENGINE_PARAMETER_SIGNATURE) { + setOperationMode(engineConfiguration, FOUR_STROKE_CAM_SENSOR); + + engineConfiguration->trigger.type = TT_SUBARU_SVX; + engineConfiguration->useOnlyRisingEdgeForTrigger = true; + + engineConfiguration->specs.cylindersCount = 6; + engineConfiguration->specs.firingOrder = FO_1_6_3_2_5_4; + + engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; + engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; + engineConfiguration->injectionMode = IM_SEQUENTIAL; + + /* TODO: */ + engineConfiguration->globalTriggerAngleOffset = 114; // the end of 19th tooth? + + /* TODO: */ + //engineConfiguration->fuelAlgorithm = LM_REAL_MAF; + engineConfiguration->fuelAlgorithm = LM_ALPHA_N; + + engineConfiguration->specs.displacement = 3.30; + engineConfiguration->injector.flow = 250; + + engineConfiguration->cranking.baseFuel = 5; // ??? + engineConfiguration->crankingChargeAngle = 70; + engineConfiguration->cranking.rpm = 400; + + engineConfiguration->rpmHardLimit = 6500; + + engineConfiguration->idleStepperReactionTime = 10; + engineConfiguration->stepperDirectionPinMode = OM_INVERTED; + engineConfiguration->useLinearCltSensor = true; + + engineConfiguration->canReadEnabled = true; + engineConfiguration->canWriteEnabled = false; + + /* TODO: */ + //engineConfiguration->tpsMin = convertVoltageTo10bitADC(0.250); + //engineConfiguration->tpsMax = convertVoltageTo10bitADC(4.538); + //engineConfiguration->tpsMax = convertVoltageTo10bitADC(5.000); + engineConfiguration->tpsErrorDetectionTooLow = -10; // -10% open + engineConfiguration->tpsErrorDetectionTooHigh = 110; // 110% open + + engineConfiguration->mapMinBufferLength = 4; + + /* idle configuration */ + engineConfiguration->manIdlePosition = 30; + engineConfiguration->idle.solenoidFrequency = 250; + + /* Check this */ + engineConfiguration->tachPulsePerRev = 2; +} diff --git a/firmware/config/engines/subaru.h b/firmware/config/engines/subaru.h index 951ceaea0d..7b1c6a959c 100644 --- a/firmware/config/engines/subaru.h +++ b/firmware/config/engines/subaru.h @@ -10,3 +10,4 @@ void setSubaru2003Wrx(DECLARE_CONFIG_PARAMETER_SIGNATURE); void setSubaruEJ20GDefaults(DECLARE_CONFIG_PARAMETER_SIGNATURE); void setSubaruEJ18_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE); +void setSubaruEG33Defaults(DECLARE_ENGINE_PARAMETER_SIGNATURE); diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 5b82a1f9e7..46293ca2bc 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -1375,6 +1375,11 @@ void resetConfigurationExt(Logging * logger, configuration_callback_t boardCallb setTest33816EngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE); break; #endif // HW_FRANKENSO +#ifdef HW_SUBARU_EG33 + case SUBARUEG33_DEFAULTS: + setSubaruEG33Defaults(PASS_CONFIG_PARAMETER_SIGNATURE); + break; +#endif //HW_SUBARU_EG33 default: firmwareError(CUSTOM_UNEXPECTED_ENGINE_TYPE, "Unexpected engine type: %d", engineType); } diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index c36432a9ec..1f193e990a 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -191,6 +191,7 @@ typedef enum { HELLEN_NB2 = ET_HELLEN_NB2, + SUBARUEG33_DEFAULTS = 70, /** * this configuration has as few pins configured as possible diff --git a/firmware/controllers/generated/signature_subaru_eg33_f7.h b/firmware/controllers/generated/signature_subaru_eg33_f7.h new file mode 100644 index 0000000000..7fa6daebca --- /dev/null +++ b/firmware/controllers/generated/signature_subaru_eg33_f7.h @@ -0,0 +1,8 @@ +// +// was generated automatically by rusEfi tool ConfigDefinition.jar based on config/boards/subaru_eg33/config/gen_config.sh integration/rusefi_config.txt +// + +#define SIGNATURE_BOARD subaru_eg33_f7 +#define SIGNATURE_DATE 2020.09.08 +#define SIGNATURE_HASH 1078744669 +#define TS_SIGNATURE "rusEFI 2020.09.08.subaru_eg33_f7.1078744669" diff --git a/firmware/gen_config.sh b/firmware/gen_config.sh index 6f13dd1c33..a64ab32f43 100755 --- a/firmware/gen_config.sh +++ b/firmware/gen_config.sh @@ -9,7 +9,7 @@ rm -f gen_config_board.log bash gen_config_default.sh [ $? -eq 0 ] || { echo "ERROR generating default"; exit 1; } -for BOARD in "hellen/hellen72 hellen72" "microrusefi mre_f7" "microrusefi mre_f4" "frankenso frankenso_na6" "prometheus prometheus_469" "prometheus prometheus_405" "proteus proteus_f7" "proteus proteus_f4"; do +for BOARD in "hellen/hellen72 hellen72" "microrusefi mre_f7" "microrusefi mre_f4" "frankenso frankenso_na6" "prometheus prometheus_469" "prometheus prometheus_405" "proteus proteus_f7" "proteus proteus_f4" "subaru_eg33 subaru_eg33_f7"; do BOARD_NAME="${BOARD% *}" BOARD_SHORT_NAME="${BOARD#* }" bash gen_config_board.sh $BOARD_NAME $BOARD_SHORT_NAME