From 068f21c616b6f64a05030d987935d32938e20c56 Mon Sep 17 00:00:00 2001 From: Andrei Date: Thu, 13 Aug 2020 18:27:31 +0300 Subject: [PATCH] vss_exti untested --- .../boards/frankenso/compile_frankenso_pal.sh | 3 ++- firmware/config/boards/skeleton/efifeatures.h | 4 ++++ firmware/config/stm32f4ems/efifeatures.h | 4 ++++ firmware/hw_layer/vehicle_speed.cpp | 18 ++++++++++++++++++ simulator/simulator/efifeatures.h | 4 ++++ 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/firmware/config/boards/frankenso/compile_frankenso_pal.sh b/firmware/config/boards/frankenso/compile_frankenso_pal.sh index 4029692152..60c18776f1 100644 --- a/firmware/config/boards/frankenso/compile_frankenso_pal.sh +++ b/firmware/config/boards/frankenso/compile_frankenso_pal.sh @@ -6,7 +6,8 @@ export EXTRA_PARAMS="-DDUMMY \ -DDEFAULT_ENGINE_TYPE=MIATA_NA6_VAF \ -DSHORT_BOARD_NAME=frankenso_na6 \ -DHAL_TRIGGER_USE_PAL=TRUE \ - -DEFI_VEHICLE_SPEED=FALSE \ + -DHAL_VSS_USE_PAL=TRUE \ + -DEFI_ICU_INPUTS=FALSE \ -DHAL_USE_ICU=FALSE \ -DEFI_LOGIC_ANALYZER=FALSE \ -DFIRMWARE_ID=\\\"frankensoNA6\\\"" diff --git a/firmware/config/boards/skeleton/efifeatures.h b/firmware/config/boards/skeleton/efifeatures.h index dc99eb05dc..1dfe4d5092 100644 --- a/firmware/config/boards/skeleton/efifeatures.h +++ b/firmware/config/boards/skeleton/efifeatures.h @@ -110,6 +110,10 @@ #define HAL_TRIGGER_USE_PAL FALSE #endif /* HAL_TRIGGER_USE_PAL */ +#ifndef HAL_TRIGGER_USE_PAL +#define HAL_TRIGGER_USE_PAL FALSE +#endif /* HAL_TRIGGER_USE_PAL */ + // TunerStudio support. #define EFI_TUNER_STUDIO TRUE #define EFI_TUNER_STUDIO_VERBOSE TRUE // Debugging output diff --git a/firmware/config/stm32f4ems/efifeatures.h b/firmware/config/stm32f4ems/efifeatures.h index 8deb802cd7..3b92f3e923 100644 --- a/firmware/config/stm32f4ems/efifeatures.h +++ b/firmware/config/stm32f4ems/efifeatures.h @@ -73,6 +73,10 @@ #define HAL_TRIGGER_USE_PAL FALSE #endif /* HAL_TRIGGER_USE_PAL */ +#ifndef HAL_VSS_USE_PAL +#define HAL_VSS_USE_PAL FALSE +#endif /* HAL_VSS_USE_PAL */ + /** * TunerStudio support. */ diff --git a/firmware/hw_layer/vehicle_speed.cpp b/firmware/hw_layer/vehicle_speed.cpp index 7a81ccb08b..243ac16c02 100644 --- a/firmware/hw_layer/vehicle_speed.cpp +++ b/firmware/hw_layer/vehicle_speed.cpp @@ -11,6 +11,7 @@ #include "engine.h" #include "digital_input_icu.h" +#include "digital_input_exti.h" #include "pin_repository.h" #include "can_vss.h" @@ -70,17 +71,34 @@ bool hasVehicleSpeedSensor() { return CONFIG(vehicleSpeedSensorInputPin) != GPIO_UNASSIGNED; } +#if HAL_VSS_USE_PAL +static void vsExtiCallback(void *) { + vsAnaWidthCallback(); +} +#endif /* HAL_VSS_USE_PAL */ + void stopVSSPins(void) { +#if HAL_VSS_USE_PAL + efiExtiDisablePin(activeConfiguration.vehicleSpeedSensorInputPin); +#elif HAL_USE_ICU stopDigitalCapture("VSS", activeConfiguration.vehicleSpeedSensorInputPin); +#endif /* HAL_VSS_USE_PAL, HAL_USE_ICU */ } void startVSSPins(void) { if (!hasVehicleSpeedSensor()) return; +#if HAL_VSS_USE_PAL + ioline_t pal_line = PAL_LINE(getHwPort("vss", CONFIG(vehicleSpeedSensorInputPin)), getHwPin("vss", CONFIG(vehicleSpeedSensorInputPin))); + efiExtiEnablePin("VSS", CONFIG(vehicleSpeedSensorInputPin), PAL_EVENT_MODE_BOTH_EDGES, vsExtiCallback, (void *)pal_line); +#elif HAL_USE_ICU digital_input_s* vehicleSpeedInput = startDigitalCapture("VSS", CONFIG(vehicleSpeedSensorInputPin)); vehicleSpeedInput->widthListeners.registerCallback((VoidInt) vsAnaWidthCallback, NULL); +#else + #error "HAL_USE_ICU or HAL_VSS_USE_PAL should be enabled to use EFI_VEHICLE_SPEED" +#endif /* HAL_VSS_USE_PAL, HAL_USE_ICU */ } void initVehicleSpeed(Logging *l) { diff --git a/simulator/simulator/efifeatures.h b/simulator/simulator/efifeatures.h index d75503db9b..dcb9311a13 100644 --- a/simulator/simulator/efifeatures.h +++ b/simulator/simulator/efifeatures.h @@ -110,6 +110,10 @@ #define HAL_TRIGGER_USE_PAL FALSE #endif /* HAL_TRIGGER_USE_PAL */ +#ifndef HAL_VSS_USE_PAL +#define HAL_VSS_USE_PAL FALSE +#endif /* HAL_VSS_USE_PAL */ + #define EFI_UART_GPS FALSE #define EFI_HAS_RESET FALSE #define EXTREME_TERM_LOGGING FALSE