diff --git a/firmware/config/engines/ford_1995_inline_6.cpp b/firmware/config/engines/ford_1995_inline_6.cpp index c74b2db9d8..5c941d5dac 100644 --- a/firmware/config/engines/ford_1995_inline_6.cpp +++ b/firmware/config/engines/ford_1995_inline_6.cpp @@ -108,9 +108,7 @@ void setFordInline6(engine_configuration_s *engineConfiguration, board_configura boardConfiguration->triggerInputPins[0] = GPIOA_8; boardConfiguration->triggerInputPins[1] = GPIOA_5; boardConfiguration->logicAnalyzerPins[0] = GPIOC_6; - boardConfiguration->logicAnalyzerPins[1] = GPIOE_7; - - + boardConfiguration->logicAnalyzerPins[1] = GPIOE_5; } #endif /* EFI_SUPPORT_1995_FORD_INLINE_6 */ diff --git a/firmware/config/engines/ford_escort_gt.cpp b/firmware/config/engines/ford_escort_gt.cpp index 955ba84fa9..112e79a75b 100644 --- a/firmware/config/engines/ford_escort_gt.cpp +++ b/firmware/config/engines/ford_escort_gt.cpp @@ -27,6 +27,30 @@ static void setDefaultCrankingFuel(engine_configuration_s *engineConfiguration) engineConfiguration->crankingSettings.fuelAtMinTempMs = 6; } +static void commonMiataNa(engine_configuration_s *engineConfiguration, board_configuration_s *boardConfiguration) { + engineConfiguration->triggerConfig.triggerType = TT_MAZDA_MIATA_NA; + + engineConfiguration->ignitionMode = IM_WASTED_SPARK; + + // Frankenstein: high side #1 is PE8 + // Frankenstein: high side #2 is PE10 + // Frankenstein: high side #3 is PE12 + // Frankenstein: high side #4 is PE14 + // Frankenstein: high side #5 is PC9 + // Frankenstein: high side #6 is PC7 + + boardConfiguration->ignitionPins[0] = GPIOE_12; // Frankenstein: high side #3 + boardConfiguration->ignitionPins[1] = GPIOE_14; // Frankenstein: high side #4 + boardConfiguration->ignitionPins[2] = GPIO_NONE; + boardConfiguration->ignitionPins[3] = GPIO_NONE; + boardConfiguration->ignitionPinMode = OM_DEFAULT; + + setDefaultCrankingFuel(engineConfiguration); + + boardConfiguration->triggerSimulatorPinModes[0] = OM_OPENDRAIN; + boardConfiguration->triggerSimulatorPinModes[1] = OM_OPENDRAIN; +} + static void common079721_2351(engine_configuration_s *engineConfiguration, board_configuration_s *boardConfiguration) { engineConfiguration->digitalChartSize = 150; @@ -59,23 +83,10 @@ static void common079721_2351(engine_configuration_s *engineConfiguration, board } void setMiata1990(engine_configuration_s *engineConfiguration, board_configuration_s *boardConfiguration) { - engineConfiguration->triggerConfig.triggerType = TT_MAZDA_MIATA_NA; - common079721_2351(engineConfiguration, boardConfiguration); + commonMiataNa(engineConfiguration, boardConfiguration); - // Frankenstein: high side #1 is PE8 - // Frankenstein: high side #2 is PE10 - // Frankenstein: high side #3 is PE12 - // Frankenstein: high side #4 is PE14 - // Frankenstein: high side #5 is PC9 - // Frankenstein: high side #6 is PC7 - - boardConfiguration->ignitionPins[0] = GPIOE_12; // Frankenstein: high side #3 - boardConfiguration->ignitionPins[1] = GPIOE_14; // Frankenstein: high side #4 - boardConfiguration->ignitionPins[2] = GPIO_NONE; - boardConfiguration->ignitionPins[3] = GPIO_NONE; - boardConfiguration->ignitionPinMode = OM_DEFAULT; // Frankenstein: low side - inj #1: PC14 // Frankenstein: low side - inj #2: PC15 @@ -143,7 +154,9 @@ void setFordEscortGt(engine_configuration_s *engineConfiguration, board_configur * set_engine_type 20 */ void setMiata1994(engine_configuration_s *engineConfiguration, board_configuration_s *boardConfiguration) { - engineConfiguration->triggerConfig.triggerType = TT_MAZDA_MIATA_NA; + + commonMiataNa(engineConfiguration, boardConfiguration); + engineConfiguration->displacement = 1.839; boardConfiguration->triggerSimulatorPins[0] = GPIOD_2; // 2G - YEL/BLU @@ -158,11 +171,10 @@ void setMiata1994(engine_configuration_s *engineConfiguration, board_configurati boardConfiguration->is_enabled_spi_2 = false; boardConfiguration->is_enabled_spi_3 = false; - setDefaultCrankingFuel(engineConfiguration); } void setMiata1996(engine_configuration_s *engineConfiguration, board_configuration_s *boardConfiguration) { + commonMiataNa(engineConfiguration, boardConfiguration); - setDefaultCrankingFuel(engineConfiguration); } diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index b74e650481..b7ce034d98 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -334,7 +334,7 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_ boardConfiguration->triggerInputPins[0] = GPIOC_6; boardConfiguration->triggerInputPins[1] = GPIOA_5; boardConfiguration->logicAnalyzerPins[0] = GPIOA_8; - boardConfiguration->logicAnalyzerPins[1] = GPIOE_7; + boardConfiguration->logicAnalyzerPins[1] = GPIOE_7; // todo: E7 is not timer input, that's a bug! boardConfiguration->idleThreadPeriod = 100; boardConfiguration->consoleLoopPeriod = 200; diff --git a/firmware/hw_layer/wave_analyzer_hw.c b/firmware/hw_layer/wave_analyzer_hw.c index 767a90d403..795580d500 100644 --- a/firmware/hw_layer/wave_analyzer_hw.c +++ b/firmware/hw_layer/wave_analyzer_hw.c @@ -88,11 +88,35 @@ static uint32_t getAlternateFunctions(ICUDriver *driver) { return 0xffffffff; } +icuchannel_t getInputCaptureChannel(brain_pin_e hwPin) { + switch (hwPin) { + case GPIOA_5: + case GPIOA_8: + case GPIOC_6: + case GPIOE_5: + case GPIOE_9: + return ICU_CHANNEL_1; + + case GPIOE_6: + case GPIOE_11: + return ICU_CHANNEL_2; + default: + firmwareError("Unexpected hw pin in getInputCaptureChannel %d", hwPin); + return ICU_CHANNEL_1; + } +} + ICUDriver * getInputCaptureDriver(brain_pin_e hwPin) { #if STM32_ICU_USE_TIM1 if (hwPin == GPIOA_8) { return &ICUD1; } + if (hwPin == GPIOE_9) { + return &ICUD1; + } + if (hwPin == GPIOE_11) { + return &ICUD1; + } #endif #if STM32_ICU_USE_TIM2 if (hwPin == GPIOA_5) { @@ -105,7 +129,7 @@ ICUDriver * getInputCaptureDriver(brain_pin_e hwPin) { } #endif #if STM32_ICU_USE_TIM9 - if (hwPin == GPIOE_7) { + if (hwPin == GPIOE_5) { return &ICUD9; } #endif