From 1930215c041159f47919077b8df2d7c7f4b464b9 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Wed, 15 Feb 2023 15:01:41 -0500 Subject: [PATCH] reducing hellen code duplication --- .../boards/hellen/alphax-2chan/board_configuration.cpp | 3 +-- .../boards/hellen/alphax-4chan/board_configuration.cpp | 3 +-- .../boards/hellen/alphax-8chan/board_configuration.cpp | 3 +-- .../config/boards/hellen/harley81/board_configuration.cpp | 3 +-- .../boards/hellen/hellen-gm-e67/board_configuration.cpp | 3 +-- .../boards/hellen/hellen-nb1/board_configuration.cpp | 3 +-- .../boards/hellen/hellen121nissan/board_configuration.cpp | 3 +-- .../boards/hellen/hellen121vag/board_configuration.cpp | 3 +-- .../hellen/hellen154hyundai/board_configuration.cpp | 3 +-- .../hellen/hellen64_miataNA6_94/board_configuration.cpp | 3 +-- .../config/boards/hellen/hellen72/board_configuration.cpp | 3 +-- .../config/boards/hellen/hellen81/board_configuration.cpp | 3 +-- .../boards/hellen/hellenNA8_96/board_configuration.cpp | 3 +-- firmware/config/boards/hellen_meta.h | 8 ++++++++ 14 files changed, 21 insertions(+), 26 deletions(-) diff --git a/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp b/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp index 03990d9aad..7e6e867218 100644 --- a/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp +++ b/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp @@ -106,8 +106,7 @@ void setBoardConfigOverrides() { setHellenSdCardSpi1(); } - engineConfiguration->clt.config.bias_resistor = 4700; - engineConfiguration->iat.config.bias_resistor = 4700; + setDefaultHellenAtPullUps(); setHellenCan(); } diff --git a/firmware/config/boards/hellen/alphax-4chan/board_configuration.cpp b/firmware/config/boards/hellen/alphax-4chan/board_configuration.cpp index 8043cd9136..7a5a8a3388 100644 --- a/firmware/config/boards/hellen/alphax-4chan/board_configuration.cpp +++ b/firmware/config/boards/hellen/alphax-4chan/board_configuration.cpp @@ -146,8 +146,7 @@ void setBoardConfigOverrides() { setHellenSdCardSpi2(); - engineConfiguration->clt.config.bias_resistor = 4700; - engineConfiguration->iat.config.bias_resistor = 4700; + setDefaultHellenAtPullUps(); setHellenCan(); } diff --git a/firmware/config/boards/hellen/alphax-8chan/board_configuration.cpp b/firmware/config/boards/hellen/alphax-8chan/board_configuration.cpp index 8a63b01443..be7ed8ec14 100644 --- a/firmware/config/boards/hellen/alphax-8chan/board_configuration.cpp +++ b/firmware/config/boards/hellen/alphax-8chan/board_configuration.cpp @@ -154,8 +154,7 @@ void setBoardConfigOverrides() { setHellenSdCardSpi2(); - engineConfiguration->clt.config.bias_resistor = 4700; - engineConfiguration->iat.config.bias_resistor = 4700; + setDefaultHellenAtPullUps(); setHellenCan(); } diff --git a/firmware/config/boards/hellen/harley81/board_configuration.cpp b/firmware/config/boards/hellen/harley81/board_configuration.cpp index 1f40353ebd..f8ce17ec73 100644 --- a/firmware/config/boards/hellen/harley81/board_configuration.cpp +++ b/firmware/config/boards/hellen/harley81/board_configuration.cpp @@ -111,8 +111,7 @@ void setBoardConfigOverrides() { setHellenSdCardSpi2(); - engineConfiguration->clt.config.bias_resistor = 4700; - engineConfiguration->iat.config.bias_resistor = 4700; + setDefaultHellenAtPullUps(); engineConfiguration->canTxPin = Gpio::D1; engineConfiguration->canRxPin = Gpio::D0; diff --git a/firmware/config/boards/hellen/hellen-gm-e67/board_configuration.cpp b/firmware/config/boards/hellen/hellen-gm-e67/board_configuration.cpp index daabb42bfa..422f25d550 100644 --- a/firmware/config/boards/hellen/hellen-gm-e67/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen-gm-e67/board_configuration.cpp @@ -83,8 +83,7 @@ void setBoardConfigOverrides() { setupVbatt(); setHellenSdCardSpi2(); - engineConfiguration->clt.config.bias_resistor = 4700; - engineConfiguration->iat.config.bias_resistor = 4700; + setDefaultHellenAtPullUps(); setHellenCan(); diff --git a/firmware/config/boards/hellen/hellen-nb1/board_configuration.cpp b/firmware/config/boards/hellen/hellen-nb1/board_configuration.cpp index aa2fcc8bed..f8fbdac8d0 100644 --- a/firmware/config/boards/hellen/hellen-nb1/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen-nb1/board_configuration.cpp @@ -74,8 +74,7 @@ void setBoardConfigOverrides() { setHellenSdCardSpi2(); - engineConfiguration->clt.config.bias_resistor = 4700; - engineConfiguration->iat.config.bias_resistor = 4700; + setDefaultHellenAtPullUps(); setHellenCan(); diff --git a/firmware/config/boards/hellen/hellen121nissan/board_configuration.cpp b/firmware/config/boards/hellen/hellen121nissan/board_configuration.cpp index 724c8e84ba..7ddbf6a739 100644 --- a/firmware/config/boards/hellen/hellen121nissan/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen121nissan/board_configuration.cpp @@ -84,8 +84,7 @@ void setBoardConfigOverrides() { engineConfiguration->etbIo[0].controlPin = Gpio::D13; // ETB_EN out_pwm1 engineConfiguration->etb_use_two_wires = true; - engineConfiguration->clt.config.bias_resistor = 4700; - engineConfiguration->iat.config.bias_resistor = 4700; + setDefaultHellenAtPullUps(); } /** diff --git a/firmware/config/boards/hellen/hellen121vag/board_configuration.cpp b/firmware/config/boards/hellen/hellen121vag/board_configuration.cpp index 185d790f00..c19608fd91 100644 --- a/firmware/config/boards/hellen/hellen121vag/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen121vag/board_configuration.cpp @@ -79,8 +79,7 @@ void setBoardConfigOverrides() { setHellenSdCardSpi3(); - engineConfiguration->clt.config.bias_resistor = 4700; - engineConfiguration->iat.config.bias_resistor = 4700; + setDefaultHellenAtPullUps(); setHellenCan(); } diff --git a/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp b/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp index 26df191e17..c36e24ea10 100644 --- a/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp @@ -75,8 +75,7 @@ void setBoardConfigOverrides() { setHellenSdCardSpi2(); - engineConfiguration->clt.config.bias_resistor = 4700; - engineConfiguration->iat.config.bias_resistor = 4700; + setDefaultHellenAtPullUps(); // trigger inputs engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; diff --git a/firmware/config/boards/hellen/hellen64_miataNA6_94/board_configuration.cpp b/firmware/config/boards/hellen/hellen64_miataNA6_94/board_configuration.cpp index 9a583b34ff..a163dc9d9f 100644 --- a/firmware/config/boards/hellen/hellen64_miataNA6_94/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen64_miataNA6_94/board_configuration.cpp @@ -74,8 +74,7 @@ void setBoardConfigOverrides() { setHellenSdCardSpi2(); - engineConfiguration->clt.config.bias_resistor = 4700; - engineConfiguration->iat.config.bias_resistor = 4700; + setDefaultHellenAtPullUps(); engineConfiguration->canTxPin = H176_CAN_TX; engineConfiguration->canRxPin = H176_CAN_RX; diff --git a/firmware/config/boards/hellen/hellen72/board_configuration.cpp b/firmware/config/boards/hellen/hellen72/board_configuration.cpp index d2533175f8..3f5fd9f4f7 100644 --- a/firmware/config/boards/hellen/hellen72/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen72/board_configuration.cpp @@ -82,8 +82,7 @@ void setBoardConfigOverrides() { engineConfiguration->etbIo[0].controlPin = H144_OUT_PWM2; // ETB_EN engineConfiguration->etb_use_two_wires = true; - engineConfiguration->clt.config.bias_resistor = 4700; - engineConfiguration->iat.config.bias_resistor = 4700; + setDefaultHellenAtPullUps(); setHellenCan(); } diff --git a/firmware/config/boards/hellen/hellen81/board_configuration.cpp b/firmware/config/boards/hellen/hellen81/board_configuration.cpp index 8ca06ea0d1..dc1e7d4aeb 100644 --- a/firmware/config/boards/hellen/hellen81/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen81/board_configuration.cpp @@ -89,8 +89,7 @@ void setBoardConfigOverrides() { setHellenSdCardSpi3(); #endif - engineConfiguration->clt.config.bias_resistor = 4700; - engineConfiguration->iat.config.bias_resistor = 4700; + setDefaultHellenAtPullUps(); setHellenCan(); } diff --git a/firmware/config/boards/hellen/hellenNA8_96/board_configuration.cpp b/firmware/config/boards/hellen/hellenNA8_96/board_configuration.cpp index 666866b79f..7926dc735e 100644 --- a/firmware/config/boards/hellen/hellenNA8_96/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellenNA8_96/board_configuration.cpp @@ -74,8 +74,7 @@ void setBoardConfigOverrides() { setHellenSdCardSpi2(); - engineConfiguration->clt.config.bias_resistor = 4700; - engineConfiguration->iat.config.bias_resistor = 4700; + setDefaultHellenAtPullUps(); setHellenCan(); diff --git a/firmware/config/boards/hellen_meta.h b/firmware/config/boards/hellen_meta.h index 01a945f8e3..e7decb19ba 100644 --- a/firmware/config/boards/hellen_meta.h +++ b/firmware/config/boards/hellen_meta.h @@ -239,3 +239,11 @@ static void setHellenSdCardSpi3() { engineConfiguration->sdCardCsPin = H_SPI3_CS; engineConfiguration->is_enabled_spi_3 = true; } + +// *pullups* files CLT R211 IAT R213 +#define HELLEN_DEFAULT_AT_PULLUP 4700 + +static void setDefaultHellenAtPullUps(){ + engineConfiguration->clt.config.bias_resistor = HELLEN_DEFAULT_AT_PULLUP; + engineConfiguration->iat.config.bias_resistor = HELLEN_DEFAULT_AT_PULLUP; +}