From cf8ddde1ceee9add089dbe97d29ab674faafdc43 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 28 Feb 2019 21:09:31 -0500 Subject: [PATCH] #699 --- firmware/controllers/algo/rusefi_enums.h | 9 ++++++--- unit_tests/boards.cpp | 2 +- unit_tests/boards.h | 8 +++----- unit_tests/engine_test_helper.cpp | 6 +++--- unit_tests/tests/test_engine_math.cpp | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 910d4b06d9..6068a6b751 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -557,9 +557,7 @@ typedef enum { * Frankenso analog #12 PC4 ADC14 */ -typedef enum -//__attribute__ ((__packed__)) -{ +typedef enum __attribute__ ((__packed__)) { EFI_ADC_0 = 0, // PA0 EFI_ADC_1 = 1, // PA1 EFI_ADC_2 = 2, // PA2 @@ -580,6 +578,11 @@ typedef enum // todo: bad choice of value since now we have ADC_CHANNEL_SENSOR and could end up with 17 and 18 also EFI_ADC_NONE = 16, EFI_ADC_ERROR = 17, +#if EFI_UNIT_TEST + TEST_MAF_CHANNEL = 113, + TEST_CLT_CHANNEL = 114, + TEST_IAT_CHANNEL = 115, +#endif } adc_channel_e; typedef enum { diff --git a/unit_tests/boards.cpp b/unit_tests/boards.cpp index 6c278d2c95..e69b0dab8f 100644 --- a/unit_tests/boards.cpp +++ b/unit_tests/boards.cpp @@ -11,7 +11,7 @@ float testMafValue = 0; float testCltValue = 0; float testIatValue = 0; -float getVoltageDivided(const char *msg, int channel) { +float getVoltageDivided(const char *msg, adc_channel_e channel) { switch(channel) { case TEST_MAF_CHANNEL: return testMafValue; diff --git a/unit_tests/boards.h b/unit_tests/boards.h index f692d79728..2d99a228d6 100644 --- a/unit_tests/boards.h +++ b/unit_tests/boards.h @@ -8,13 +8,11 @@ #ifndef BOARDS_H_ #define BOARDS_H_ +#include "rusefi_enums.h" + #define ADC_CHANNEL_VREF 0 -#define TEST_MAF_CHANNEL 10000013 -#define TEST_CLT_CHANNEL 10000014 -#define TEST_IAT_CHANNEL 10000015 - -float getVoltageDivided(const char *msg, int); +float getVoltageDivided(const char *msg, adc_channel_e); float getVoltage(const char *msg, int channel); int getAdcValue(const char *msg, int channel); diff --git a/unit_tests/engine_test_helper.cpp b/unit_tests/engine_test_helper.cpp index 0d1cb7c238..3e9c7dc0a9 100644 --- a/unit_tests/engine_test_helper.cpp +++ b/unit_tests/engine_test_helper.cpp @@ -62,9 +62,9 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persiste resetConfigurationExt(NULL, engineType PASS_ENGINE_PARAMETER_SUFFIX); prepareShapes(PASS_ENGINE_PARAMETER_SIGNATURE); - engine->engineConfigurationPtr->mafAdcChannel = (adc_channel_e)TEST_MAF_CHANNEL; - engine->engineConfigurationPtr->clt.adcChannel = (adc_channel_e)TEST_CLT_CHANNEL; - engine->engineConfigurationPtr->iat.adcChannel = (adc_channel_e)TEST_IAT_CHANNEL; + engine->engineConfigurationPtr->mafAdcChannel = TEST_MAF_CHANNEL; + engine->engineConfigurationPtr->clt.adcChannel = TEST_CLT_CHANNEL; + engine->engineConfigurationPtr->iat.adcChannel = TEST_IAT_CHANNEL; testCltValue = 1.492964; testIatValue = 4.03646; diff --git a/unit_tests/tests/test_engine_math.cpp b/unit_tests/tests/test_engine_math.cpp index 5ef892583a..769a3cae41 100644 --- a/unit_tests/tests/test_engine_math.cpp +++ b/unit_tests/tests/test_engine_math.cpp @@ -15,7 +15,7 @@ #include "advance_map.h" TEST(misc, structSize) { -// ASSERT_EQ(1, sizeof(adc_channel_e)) << "small enum size"; + ASSERT_EQ(1, sizeof(adc_channel_e)) << "small enum size"; ASSERT_EQ(1, sizeof(pin_input_mode_e)) << "small enum size"; ASSERT_EQ(1, sizeof(pin_output_mode_e)) << "small enum size"; // ASSERT_EQ(1, sizeof(brain_pin_e)) << "small enum size";