From f9d032dfac22441d11d872b1f7ec99e28a165235 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Fri, 22 May 2015 08:05:16 -0400 Subject: [PATCH] auto-sync --- firmware/config/engines/bmw_e34.cpp | 4 +- .../config/engines/citroenBerlingoTU3JP.cpp | 4 +- firmware/config/engines/custom_engine.cpp | 4 +- firmware/config/engines/dodge_neon.cpp | 6 +-- firmware/config/engines/dodge_ram.cpp | 4 +- .../config/engines/ford_1995_inline_6.cpp | 4 +- firmware/config/engines/ford_aspire.cpp | 2 +- firmware/config/engines/honda_accord.cpp | 4 +- firmware/config/engines/mazda_626.cpp | 2 +- firmware/config/engines/mazda_miata.cpp | 8 ++-- firmware/config/engines/mazda_miata_nb.cpp | 4 +- firmware/config/engines/mitsubishi.cpp | 2 +- .../controllers/algo/engine_configuration.cpp | 4 +- ...ngine_configuration_generated_structures.h | 36 +++++++++++++--- firmware/controllers/algo/rusefi_generated.h | 3 ++ firmware/controllers/sensors/thermistors.cpp | 41 +++++++++++-------- firmware/controllers/settings.cpp | 17 ++++---- firmware/integration/rusefi_config.txt | 11 ++--- unit_tests/test_sensors.cpp | 16 +++++--- 19 files changed, 109 insertions(+), 67 deletions(-) diff --git a/firmware/config/engines/bmw_e34.cpp b/firmware/config/engines/bmw_e34.cpp index 935adde6b7..89f61b1903 100644 --- a/firmware/config/engines/bmw_e34.cpp +++ b/firmware/config/engines/bmw_e34.cpp @@ -149,9 +149,9 @@ void setBmwE34(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->hasCltSensor = true; engineConfiguration->hasIatSensor = true; setThermistorConfiguration(&engineConfiguration->clt, -10, 9300, 20, 2500, 80, 335); - engineConfiguration->iat.bias_resistor = 2200; + engineConfiguration->iat.config.bias_resistor = 2200; setThermistorConfiguration(&engineConfiguration->iat, -10, 9300, 20, 2500, 80, 335); - engineConfiguration->clt.bias_resistor = 2200; + engineConfiguration->clt.config.bias_resistor = 2200; // /** // * This saves a couple of ticks in trigger emulation methods diff --git a/firmware/config/engines/citroenBerlingoTU3JP.cpp b/firmware/config/engines/citroenBerlingoTU3JP.cpp index 86db9034e9..eee6859940 100644 --- a/firmware/config/engines/citroenBerlingoTU3JP.cpp +++ b/firmware/config/engines/citroenBerlingoTU3JP.cpp @@ -184,13 +184,13 @@ void setCitroenBerlingoTU3JPConfiguration(DECLARE_ENGINE_PARAMETER_F) { */ engineConfiguration->iatAdcChannel = EFI_ADC_13; setThermistorConfiguration(&engineConfiguration->iat, -20.0, 15600.0, 23.0, 2250.0, 92.0, 240.0); - engineConfiguration->iat.bias_resistor = 2660; + engineConfiguration->iat.config.bias_resistor = 2660; /** * CLT */ engineConfiguration->cltAdcChannel = EFI_ADC_11; setThermistorConfiguration(&engineConfiguration->clt, -20.0, 28680.0, 25.0, 2796.0, 100.0, 177.0); - engineConfiguration->clt.bias_resistor = 2660; + engineConfiguration->iat.config.bias_resistor = 2660; /** * vBatt */ diff --git a/firmware/config/engines/custom_engine.cpp b/firmware/config/engines/custom_engine.cpp index 023c26ca9d..b481b39f36 100644 --- a/firmware/config/engines/custom_engine.cpp +++ b/firmware/config/engines/custom_engine.cpp @@ -42,9 +42,9 @@ void setCustomEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->afr.hwChannel = EFI_ADC_13; setCommonNTCSensor(&engineConfiguration->clt); - engineConfiguration->clt.bias_resistor = 2700; + engineConfiguration->clt.config.bias_resistor = 2700; setCommonNTCSensor(&engineConfiguration->iat); - engineConfiguration->iat.bias_resistor = 2700; + engineConfiguration->iat.config.bias_resistor = 2700; /** diff --git a/firmware/config/engines/dodge_neon.cpp b/firmware/config/engines/dodge_neon.cpp index d84ccdc57b..8469e9b694 100644 --- a/firmware/config/engines/dodge_neon.cpp +++ b/firmware/config/engines/dodge_neon.cpp @@ -179,7 +179,7 @@ void setDodgeNeon1995EngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { boardConfiguration->ignitionPinMode = OM_DEFAULT; setThermistorConfiguration(&engineConfiguration->clt, 0, 32500, 30, 7550, 100, 700); - engineConfiguration->clt.bias_resistor = 2700; + engineConfiguration->clt.config.bias_resistor = 2700; engineConfiguration->sensorChartFrequency = 7; } @@ -306,10 +306,10 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { setDodgeSensor(&engineConfiguration->clt); - engineConfiguration->clt.bias_resistor = 10000; + engineConfiguration->clt.config.bias_resistor = 10000; setDodgeSensor(&engineConfiguration->iat); - engineConfiguration->iat.bias_resistor = 10000; + engineConfiguration->iat.config.bias_resistor = 10000; /** * MAP PA6 diff --git a/firmware/config/engines/dodge_ram.cpp b/firmware/config/engines/dodge_ram.cpp index 55822927ec..d9367730f1 100644 --- a/firmware/config/engines/dodge_ram.cpp +++ b/firmware/config/engines/dodge_ram.cpp @@ -82,9 +82,9 @@ void setDodgeRam1996(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->vbattDividerCoeff = 9.6; setDodgeSensor(&engineConfiguration->clt); - engineConfiguration->clt.bias_resistor = 2700; + engineConfiguration->clt.config.bias_resistor = 2700; setDodgeSensor(&engineConfiguration->iat); - engineConfiguration->iat.bias_resistor = 2700; + engineConfiguration->iat.config.bias_resistor = 2700; } diff --git a/firmware/config/engines/ford_1995_inline_6.cpp b/firmware/config/engines/ford_1995_inline_6.cpp index c07e198599..be1e909102 100644 --- a/firmware/config/engines/ford_1995_inline_6.cpp +++ b/firmware/config/engines/ford_1995_inline_6.cpp @@ -54,10 +54,10 @@ void setFordInline6(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->injectionAngle = 207.269999; setThermistorConfiguration(&engineConfiguration->clt, -10.0, 160310.0, 60.0, 7700.0, 120.0, 1180.0); - engineConfiguration->clt.bias_resistor = 2700; + engineConfiguration->clt.config.bias_resistor = 2700; setThermistorConfiguration(&engineConfiguration->iat, -10.0, 160310.0, 60.0, 7700.0, 120.0, 1180.0); - engineConfiguration->iat.bias_resistor = 2700; + engineConfiguration->iat.config.bias_resistor = 2700; // 12ch analog board pinout: // input channel 3 is PA7, that's ADC7 diff --git a/firmware/config/engines/ford_aspire.cpp b/firmware/config/engines/ford_aspire.cpp index 91812b6786..aec16aba72 100644 --- a/firmware/config/engines/ford_aspire.cpp +++ b/firmware/config/engines/ford_aspire.cpp @@ -90,7 +90,7 @@ void setFordAspireEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { * 1K Ohm @ 49C */ setThermistorConfiguration(&engineConfiguration->clt, -20, 18000, 23.8889, 2100, 48.8889, 1000); - engineConfiguration->clt.bias_resistor = 3300; // that's my custom resistor value! + engineConfiguration->clt.config.bias_resistor = 3300; // that's my custom resistor value! engineConfiguration->cranking.baseFuel = 3; diff --git a/firmware/config/engines/honda_accord.cpp b/firmware/config/engines/honda_accord.cpp index a0cba6bff5..2d5385f62c 100644 --- a/firmware/config/engines/honda_accord.cpp +++ b/firmware/config/engines/honda_accord.cpp @@ -58,10 +58,10 @@ static void setHondaAccordConfigurationCommon(DECLARE_ENGINE_PARAMETER_F) { * 100 Ohm @ 120C */ setCommonNTCSensor(&engineConfiguration->clt); - engineConfiguration->clt.bias_resistor = 1500; // same as OEM ECU + engineConfiguration->clt.config.bias_resistor = 1500; // same as OEM ECU setCommonNTCSensor(&engineConfiguration->iat); - engineConfiguration->iat.bias_resistor = 1500; // same as OEM ECU + engineConfiguration->iat.config.bias_resistor = 1500; // same as OEM ECU // set_cranking_charge_angle 35 engineConfiguration->crankingChargeAngle = 70; diff --git a/firmware/config/engines/mazda_626.cpp b/firmware/config/engines/mazda_626.cpp index 8ef2d6fb4c..d9ae7e7298 100644 --- a/firmware/config/engines/mazda_626.cpp +++ b/firmware/config/engines/mazda_626.cpp @@ -59,7 +59,7 @@ void setMazda626EngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { setCommonNTCSensor(&engineConfiguration->clt); // http://i.imgur.com/2hI67yW.jpg setThermistorConfiguration(&engineConfiguration->iat, 13, 56000, 50, 9000, 80.0, 2700); - engineConfiguration->iat.bias_resistor = 18000; + engineConfiguration->iat.config.bias_resistor = 18000; commonFrankensoAnalogInputs(engineConfiguration); // engineConfiguration->map.sensor.hwChannel = EFI_ADC_4; diff --git a/firmware/config/engines/mazda_miata.cpp b/firmware/config/engines/mazda_miata.cpp index 8019abb165..c7b2d7075a 100644 --- a/firmware/config/engines/mazda_miata.cpp +++ b/firmware/config/engines/mazda_miata.cpp @@ -161,9 +161,9 @@ static void commonMiataNa(DECLARE_ENGINE_PARAMETER_F) { boardConfiguration->triggerSimulatorPinModes[1] = OM_OPENDRAIN; setCommonNTCSensor(&engineConfiguration->clt); - engineConfiguration->clt.bias_resistor = 2700; + engineConfiguration->clt.config.bias_resistor = 2700; setCommonNTCSensor(&engineConfiguration->iat); - engineConfiguration->iat.bias_resistor = 2700; + engineConfiguration->iat.config.bias_resistor = 2700; } @@ -341,9 +341,9 @@ void setFordEscortGt(DECLARE_ENGINE_PARAMETER_F) { commonFrankensoAnalogInputs(engineConfiguration); setCommonNTCSensor(&engineConfiguration->clt); - engineConfiguration->clt.bias_resistor = 2700; + engineConfiguration->clt.config.bias_resistor = 2700; setCommonNTCSensor(&engineConfiguration->iat); - engineConfiguration->iat.bias_resistor = 2700; + engineConfiguration->iat.config.bias_resistor = 2700; engineConfiguration->hasTpsSensor = false; engineConfiguration->tpsAdcChannel = EFI_ADC_NONE; diff --git a/firmware/config/engines/mazda_miata_nb.cpp b/firmware/config/engines/mazda_miata_nb.cpp index 6bcd4efd78..8c452d13ce 100644 --- a/firmware/config/engines/mazda_miata_nb.cpp +++ b/firmware/config/engines/mazda_miata_nb.cpp @@ -30,10 +30,10 @@ void setMazdaMiataNbEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->specs.firingOrder = FO_1_THEN_3_THEN_4_THEN2; setThermistorConfiguration(&engineConfiguration->clt, 0, 32500, 30, 7550, 100, 700); - engineConfiguration->clt.bias_resistor = 2700; + engineConfiguration->clt.config.bias_resistor = 2700; setThermistorConfiguration(&engineConfiguration->iat, -10, 160310, 60, 7700, 120.00, 1180); - engineConfiguration->iat.bias_resistor = 2700; + engineConfiguration->iat.config.bias_resistor = 2700; engineConfiguration->tpsAdcChannel = EFI_ADC_3; // 15 is the old value engineConfiguration->vbattAdcChannel = EFI_ADC_0; // 1 is the old value diff --git a/firmware/config/engines/mitsubishi.cpp b/firmware/config/engines/mitsubishi.cpp index f7539fbfee..e384026b94 100644 --- a/firmware/config/engines/mitsubishi.cpp +++ b/firmware/config/engines/mitsubishi.cpp @@ -53,7 +53,7 @@ void setMitsubishiConfiguration(DECLARE_ENGINE_PARAMETER_F) { setCommonNTCSensor(&engineConfiguration->clt); - engineConfiguration->clt.bias_resistor = 2700; + engineConfiguration->clt.config.bias_resistor = 2700; // Frankenstein: low side - out #1: PC14 // Frankenstein: low side - out #2: PC15 diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index a82b3975bb..b9aa9ea4a2 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -283,11 +283,11 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_F) { setDefaultIatTimingCorrection(PASS_ENGINE_PARAMETER_F); setThermistorConfiguration(&engineConfiguration->clt, 0, 9500, 23.8889, 2100, 48.8889, 1000); - engineConfiguration->clt.bias_resistor = 1500; + engineConfiguration->clt.config.bias_resistor = 1500; setThermistorConfiguration(&engineConfiguration->iat, 32, 9500, 75, 2100, 120, 1000); // todo: this value is way off! I am pretty sure temp coeffs are off also - engineConfiguration->iat.bias_resistor = 2700; + engineConfiguration->iat.config.bias_resistor = 2700; engineConfiguration->rpmHardLimit = 7000; engineConfiguration->cranking.rpm = 550; diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index 1d92fc9a87..030264c53a 100644 --- a/firmware/controllers/algo/engine_configuration_generated_structures.h +++ b/firmware/controllers/algo/engine_configuration_generated_structures.h @@ -1,4 +1,4 @@ -// this section was generated by config_definition.jar on Thu May 21 19:13:37 EDT 2015 +// this section was generated by config_definition.jar on Fri May 22 07:17:51 EDT 2015 // begin #include "rusefi_types.h" typedef struct { @@ -73,7 +73,7 @@ typedef struct { } MAP_sensor_config_s; /** - * @brief Thermistor curve parameters + * @brief Thermistor known values */ typedef struct { @@ -106,18 +106,42 @@ typedef struct { * offset 24 */ float bias_resistor; + /** total size 28*/ +} thermistor_conf_s; + +/** + * @brief Thermistor curve parameters + +*/ +typedef struct { /** - * offset 28 + * offset 0 */ float s_h_a; /** - * offset 32 + * offset 4 */ float s_h_b; /** - * offset 36 + * offset 8 */ float s_h_c; + /** total size 12*/ +} thermistor_curve_s; + +/** + * @brief Thermistor curve parameters + +*/ +typedef struct { + /** + * offset 0 + */ + thermistor_conf_s config; + /** + * offset 28 + */ + thermistor_curve_s curve; /** total size 40*/ } ThermistorConf; @@ -1302,4 +1326,4 @@ typedef struct { } persistent_config_s; // end -// this section was generated by config_definition.jar on Thu May 21 19:13:37 EDT 2015 +// this section was generated by config_definition.jar on Fri May 22 07:17:51 EDT 2015 diff --git a/firmware/controllers/algo/rusefi_generated.h b/firmware/controllers/algo/rusefi_generated.h index 0a109e7ec7..179a750294 100644 --- a/firmware/controllers/algo/rusefi_generated.h +++ b/firmware/controllers/algo/rusefi_generated.h @@ -87,6 +87,7 @@ #define clt_resistance_3_offset_hex 114 #define clt_bias_resistor_offset 280 #define clt_bias_resistor_offset_hex 118 +#define clt_curve_offset 284 #define clt_s_h_a_offset 284 #define clt_s_h_b_offset 288 #define clt_s_h_b_offset_hex 120 @@ -108,6 +109,8 @@ #define iat_resistance_3_offset 316 #define iat_bias_resistor_offset 320 #define iat_bias_resistor_offset_hex 140 +#define iat_curve_offset 324 +#define iat_curve_offset_hex 144 #define iat_s_h_a_offset 324 #define iat_s_h_a_offset_hex 144 #define iat_s_h_b_offset 328 diff --git a/firmware/controllers/sensors/thermistors.cpp b/firmware/controllers/sensors/thermistors.cpp index 4f940037e5..8909883bfb 100644 --- a/firmware/controllers/sensors/thermistors.cpp +++ b/firmware/controllers/sensors/thermistors.cpp @@ -51,7 +51,8 @@ float convertResistanceToKelvinTemperature(float resistance, ThermistorConf *the return 0.0f; } float logR = logf(resistance); - return 1 / (thermistor->s_h_a + thermistor->s_h_b * logR + thermistor->s_h_c * logR * logR * logR); + thermistor_curve_s * curve = &thermistor->curve; + return 1 / (curve->s_h_a + curve->s_h_b * logR + curve->s_h_c * logR * logR * logR); } float convertCelsiustoF(float tempC) { @@ -80,7 +81,9 @@ float getKelvinTemperature(float resistance, ThermistorConf *thermistor) { float getResistance(Thermistor *thermistor) { float voltage = getVoltageDivided("term", thermistor->channel); efiAssert(thermistor->config != NULL, "thermistor config is null", NAN); - float resistance = getR2InVoltageDividor(voltage, _5_VOLTS, thermistor->config->bias_resistor); + thermistor_conf_s *tc = &thermistor->config->config; + + float resistance = getR2InVoltageDividor(voltage, _5_VOLTS, tc->bias_resistor); return resistance; } @@ -120,8 +123,9 @@ float getCoolantTemperature(DECLARE_ENGINE_PARAMETER_F) { return temperature; } -void setThermistorConfiguration(ThermistorConf * tc, float tempC1, float r1, float tempC2, float r2, float tempC3, +void setThermistorConfiguration(ThermistorConf * thermistor, float tempC1, float r1, float tempC2, float r2, float tempC3, float r3) { + thermistor_conf_s *tc = &thermistor->config; tc->tempC_1 = tempC1; tc->resistance_1 = r1; @@ -134,19 +138,20 @@ void setThermistorConfiguration(ThermistorConf * tc, float tempC1, float r1, flo void prepareThermistorCurve(ThermistorConf * config) { efiAssertVoid(config!=NULL, "therm config"); - float T1 = config->tempC_1 + KELV; - float T2 = config->tempC_2 + KELV; - float T3 = config->tempC_3 + KELV; + thermistor_conf_s *tc = &config->config; + float T1 = tc->tempC_1 + KELV; + float T2 = tc->tempC_2 + KELV; + float T3 = tc->tempC_3 + KELV; scheduleMsg(logger, "T1=%..100000f/T2=%..100000f/T3=%..100000f", T1, T2, T3); - float L1 = logf(config->resistance_1); - if (L1 == config->resistance_1) { + float L1 = logf(tc->resistance_1); + if (L1 == tc->resistance_1) { firmwareError("log is broken?"); } - float L2 = logf(config->resistance_2); - float L3 = logf(config->resistance_3); - scheduleMsg(logger, "R1=%..100000f/R2=%..100000f/R3=%..100000f", config->resistance_1, config->resistance_2, - config->resistance_3); + float L2 = logf(tc->resistance_2); + float L3 = logf(tc->resistance_3); + scheduleMsg(logger, "R1=%..100000f/R2=%..100000f/R3=%..100000f", tc->resistance_1, tc->resistance_2, + tc->resistance_3); scheduleMsg(logger, "L1=%..100000f/L2=%..100000f/L3=%..100000f", L1, L2, L3); float Y1 = 1 / T1; @@ -160,12 +165,14 @@ void prepareThermistorCurve(ThermistorConf * config) { scheduleMsg(logger, "U2=%..100000f/U3=%..100000f", U2, U3); - config->s_h_c = (U3 - U2) / (L3 - L2) * pow(L1 + L2 + L3, -1); - config->s_h_b = U2 - config->s_h_c * (L1 * L1 + L1 * L2 + L2 * L2); - config->s_h_a = Y1 - (config->s_h_b + L1 * L1 * config->s_h_c) * L1; + thermistor_curve_s * curve = &config->curve; - scheduleMsg(logger, "s_h_c=%..100000f/s_h_b=%..100000f/s_h_a=%..100000f", config->s_h_c, config->s_h_b, - config->s_h_a); + curve->s_h_c = (U3 - U2) / (L3 - L2) * pow(L1 + L2 + L3, -1); + curve->s_h_b = U2 - curve->s_h_c * (L1 * L1 + L1 * L2 + L2 * L2); + curve->s_h_a = Y1 - (curve->s_h_b + L1 * L1 * curve->s_h_c) * L1; + + scheduleMsg(logger, "s_h_c=%..100000f/s_h_b=%..100000f/s_h_a=%..100000f", curve->s_h_c, curve->s_h_b, + curve->s_h_a); } diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index b7b4a9ec06..4f70dae4ea 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -374,15 +374,18 @@ static void printThermistor(const char *msg, Thermistor *thermistor) { float t = getTemperatureC(thermistor); + thermistor_conf_s *tc = &thermistor->config->config; + scheduleMsg(&logger, "%s volts=%f Celsius=%f sensorR=%f on channel %d", msg, voltage, t, r, adcChannel); scheduleMsg(&logger, "@%s", getPinNameByAdcChannel(adcChannel, pinNameBuffer)); scheduleMsg(&logger, "C=%f/R=%f C=%f/R=%f C=%f/R=%f", - thermistor->config->tempC_1, thermistor->config->resistance_1, - thermistor->config->tempC_2, thermistor->config->resistance_2, - thermistor->config->tempC_3, thermistor->config->resistance_3); + tc->tempC_1, tc->resistance_1, + tc->tempC_2, tc->resistance_2, + tc->tempC_3, tc->resistance_3); - scheduleMsg(&logger, "bias resistor=%fK A=%..100000f B=%..100000f C=%..100000f", thermistor->config->bias_resistor / 1000, - thermistor->config->s_h_a, thermistor->config->s_h_b, thermistor->config->s_h_c); + thermistor_curve_s * curve = &thermistor->config->curve; + scheduleMsg(&logger, "bias resistor=%fK A=%..100000f B=%..100000f C=%..100000f", tc->bias_resistor / 1000, + curve->s_h_a, curve->s_h_b, curve->s_h_c); scheduleMsg(&logger, "=============================="); } @@ -530,7 +533,7 @@ static void setGlobalFuelCorrection(float value) { } static void setCltBias(float value) { - engineConfiguration->clt.bias_resistor = value; + engineConfiguration->clt.config.bias_resistor = value; } static void setFanSetting(float onTempC, float offTempC) { @@ -543,7 +546,7 @@ static void setFanSetting(float onTempC, float offTempC) { } static void setIatBias(float value) { - engineConfiguration->iat.bias_resistor = value; + engineConfiguration->iat.config.bias_resistor = value; } static void setVBattDivider(float value) { diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 5295821718..ec86889afe 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -100,8 +100,7 @@ float[MAP_WINDOW_SIZE] samplingWindow;@brief MAP averaging angle duration, by RP air_pressure_sensor_config_s sensor end_struct - -struct_no_prefix thermistor_conf_s @brief Thermistor curve parameters +struct_no_prefix thermistor_conf_s @brief Thermistor known values float tempC_1;these values are in Celcuus;"*C", 1, 0, -40, 200, 1 float tempC_2;;"*C", 1, 0, -40, 200, 1 float tempC_3;;"*C", 1, 0, -40, 200, 1 @@ -112,13 +111,15 @@ float resistance_3;;"Ohm", 1, 0, 0, 200000, 1 float bias_resistor;;"Ohm", 1, 0, 0, 200000, 1 end_struct -struct ThermistorConf @brief Thermistor curve parameters - thermistor_conf_s config; - +struct_no_prefix thermistor_curve_s @brief Thermistor curve parameters float s_h_a; float s_h_b; float s_h_c; +end_struct +struct ThermistorConf @brief Thermistor curve parameters + thermistor_conf_s config; + thermistor_curve_s curve; end_struct custom engine_type_e 4 bits, S32, @OFFSET@, [0:2], "AUDI_AAN", "DODGE_NEON_1995", "FORD_ASPIRE_1996", "FORD_FIESTA", "NISSAN_PRIMERA", "HONDA_ACCORD", "FORD_INLINE_6_1995", "GY6_139QMB" diff --git a/unit_tests/test_sensors.cpp b/unit_tests/test_sensors.cpp index 136b1b4c57..9c10ba2205 100644 --- a/unit_tests/test_sensors.cpp +++ b/unit_tests/test_sensors.cpp @@ -91,9 +91,11 @@ void testSensors(void) { prepareThermistorCurve(&tc); - assertEquals(-0.003, tc.s_h_a); - assertEquals(0.001, tc.s_h_b); - assertEquals(0.0, tc.s_h_c); + thermistor_curve_s * curve = &tc.curve; + + assertEquals(-0.003, curve->s_h_a); + assertEquals(0.001, curve->s_h_b); + assertEquals(0.0, curve->s_h_c); float t = convertResistanceToKelvinTemperature(2100, &tc); assertEquals(75 + KELV, t); @@ -104,9 +106,11 @@ void testSensors(void) { setThermistorConfiguration(&tc, 0, 32500, 30, 7550, 100, 700); prepareThermistorCurve(&tc); - assertEqualsM("A", 0.0009, tc.s_h_a); - assertEqualsM("B", 0.0003, tc.s_h_b); - assertEquals(0.0, tc.s_h_c); + thermistor_curve_s * curve = &tc.curve; + + assertEqualsM("A", 0.0009, curve->s_h_a); + assertEqualsM("B", 0.0003, curve->s_h_b); + assertEquals(0.0, curve->s_h_c); float t = convertResistanceToKelvinTemperature(38000, &tc); assertEquals(-2.7983, t - KELV); }