From 63f18a852bc3db91d004d81ccb79c285f75007ef Mon Sep 17 00:00:00 2001 From: rusefillc Date: Wed, 20 Dec 2023 15:42:20 -0500 Subject: [PATCH] more on board ID --- firmware/config/boards/board_id.cpp | 5 ++++- firmware/config/boards/hellen/hellen_board_id.cpp | 13 ++++++++----- firmware/config/engines/custom_engine.cpp | 3 ++- firmware/libfirmware | 2 +- firmware/rusefi.cpp | 5 +++-- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/firmware/config/boards/board_id.cpp b/firmware/config/boards/board_id.cpp index 99c991331d..1de3b71799 100644 --- a/firmware/config/boards/board_id.cpp +++ b/firmware/config/boards/board_id.cpp @@ -23,9 +23,12 @@ board_id_t getBoardId() { } #endif -#if HW_HELLEN +#if defined(HW_HELLEN_SKIP_BOARD_TYPE) + return (board_id_t)STATIC_BOARD_ID; +#elif HW_HELLEN return (board_id_t)engine->engineState.hellenBoardId; #elif STATIC_BOARD_ID +// should STATIC_BOARD_ID simply have priority over hellen board id? what's the use-case of HW_HELLEN with STATIC_BOARD_ID? return (board_id_t)STATIC_BOARD_ID; #else return 0; diff --git a/firmware/config/boards/hellen/hellen_board_id.cpp b/firmware/config/boards/hellen/hellen_board_id.cpp index ac15b5c54a..c31bddf93a 100644 --- a/firmware/config/boards/hellen/hellen_board_id.cpp +++ b/firmware/config/boards/hellen/hellen_board_id.cpp @@ -53,14 +53,17 @@ #include "hellen_board_id.h" /* We use known standard E24 series resistor values (1%) to find the closest match. - The 16 major values should have a guarateed spacing of 15% in a row (1% R tolerance + 10% C tolerance) + The 16 major values should have a guaranteed spacing of 15% in a row (1% R tolerance + 10% C tolerance) These should match the values in the gen_board_id script! */ #include "hellen_board_id_resistors.h" //#define HELLEN_BOARD_ID_DEBUG -#if EFI_PROD_CODE +// todo: error: this use of "defined" may not be portable [-Werror=expansion-to-defined ?! +// huh? #define HELLEN_BOARD_ID_CODE_NEEDED (defined( HELLEN_BOARD_ID_PIN_1) && !defined(HW_HELLEN_SKIP_BOARD_TYPE)) + +#if EFI_PROD_CODE && defined( HELLEN_BOARD_ID_PIN_1) && !defined(HW_HELLEN_SKIP_BOARD_TYPE) static void hellenBoardIdInputCallback(void *arg, efitick_t nowNt) { UNUSED(arg); @@ -74,7 +77,7 @@ static void hellenBoardIdInputCallback(void *arg, efitick_t nowNt) { chSemSignalI(&state->boardId_wake); // no need to call chSchRescheduleS() because we're inside the ISR } -#endif /* EFI_PROD_CODE */ +#endif /* EFI_PROD_CODE && HELLEN_BOARD_ID_CODE_NEEDED */ // Newton's numerical method (x is R and y is C, or vice-versa) float HellenBoardIdSolver::solve(float Tc1, float Tc2, float x0, float y, float deltaX) { @@ -173,7 +176,7 @@ float HellenBoardIdFinderBase::calc(float Tc1_us, float Tc2_us, float Rest, floa template bool HellenBoardIdFinder::measureChargingTimes(int i, float & Tc1_us, float & Tc2_us) { -#if EFI_PROD_CODE +#if EFI_PROD_CODE && defined( HELLEN_BOARD_ID_PIN_1) && !defined(HW_HELLEN_SKIP_BOARD_TYPE) chSemReset(&state.boardId_wake, 0); // full charge/discharge time, and also 'timeout' time @@ -305,7 +308,7 @@ bool HellenBoardIdFinder::measureChargingTimesAveraged(int i, float & T int detectHellenBoardId() { int boardId = -1; -#ifdef HELLEN_BOARD_ID_PIN_1 +#if defined( HELLEN_BOARD_ID_PIN_1) && !defined(HW_HELLEN_SKIP_BOARD_TYPE) efiPrintf("Starting Hellen Board ID detection..."); efitick_t beginNt = getTimeNowNt(); diff --git a/firmware/config/engines/custom_engine.cpp b/firmware/config/engines/custom_engine.cpp index 138d3a9451..bd874f6b96 100644 --- a/firmware/config/engines/custom_engine.cpp +++ b/firmware/config/engines/custom_engine.cpp @@ -915,12 +915,13 @@ end } void detectBoardType() { -#if HW_HELLEN && !defined(HW_HELLEN_SKIP_BOARD_TYPE) +#if HW_HELLEN #if !EFI_UNIT_TEST detectHellenBoardType(); #endif /* EFI_UNIT_TEST */ #endif //HW_HELLEN // todo: add board ID detection? + // see hellen128 which has/had alternative i2c board id? } void fuelBenchMode() { diff --git a/firmware/libfirmware b/firmware/libfirmware index 065ed8f653..eb55df14ce 160000 --- a/firmware/libfirmware +++ b/firmware/libfirmware @@ -1 +1 @@ -Subproject commit 065ed8f653ae31b716bcee3fbc835d61ca5a1121 +Subproject commit eb55df14ce87c0ed400f47ee754c9843135711d7 diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index a1a3bef5e0..c131a6c71f 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -96,8 +96,8 @@ * * @section config Persistent Configuration * - * Definition of configuration data structure: - * integration/rusefi_config.txt + * Definition of configuration data structure: + * integration/rusefi_config.txt * This file has a lot of information and instructions in its comment header. * Please note that due to TunerStudio protocol it's important to have the total structure size in sync between the firmware and TS .ini file - * just to make sure that this is not forgotten the size of the structure is hard-coded as PAGE_0_SIZE constant. There is always some 'unused' fields added in advance so that @@ -201,6 +201,7 @@ void runRusEfi() { // Perform hardware initialization that doesn't need configuration initHardwareNoConfig(); + // at the moment that's always hellen board ID detectBoardType(); #if EFI_ETHERNET