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 8707eb65a3..e46636ff6d 100644 --- a/firmware/config/boards/hellen/hellen-gm-e67/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen-gm-e67/board_configuration.cpp @@ -176,8 +176,6 @@ void setBoardDefaultConfiguration() { engineConfiguration->throttlePedalSecondaryWOTVoltage = 0.0; engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; - // would not hurt just in case no cam - engineConfiguration->twoWireBatchInjection = true; engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; engineConfiguration->injectionMode = IM_SEQUENTIAL; @@ -186,58 +184,4 @@ void setBoardDefaultConfiguration() { engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH; // ? engineConfiguration->malfunctionIndicatorPin = Gpio::G4; //1E - Check Engine Light - strncpy(config->luaScript, R"( - -function getBitRange(data, bitIndex, bitWidth) - byteIndex = bitIndex >> 3 - shift = bitIndex - byteIndex * 8 - value = data[1 + byteIndex] - if (shift + bitWidth > 8) then - value = value + data[2 + byteIndex] * 256 - end - mask = (1 << bitWidth) - 1 - return (value >> shift) & mask -end - -STARTER_OUTPUT_INDEX = 0 -startPwm(STARTER_OUTPUT_INDEX, 100, 0) - --- 201 -ECMEngineStatus = 0xC9 -IGN_STATUS = 0x1f1 --- 0x514 -VIN_Part1 = 1300 --- 04E1 -VIN_Part2 = 1249 - -setTickRate(100) - -function canIgnStatus(bus, id, dlc, data) - crankingBits = getBitRange(data, 2, 2) - isCranking = (crankingBits == 2) - print('crankingBits ' .. crankingBits .. ', isCranking ' .. isCranking) -end - -canRxAdd(IGN_STATUS, canIgnStatus) - --- todo: take VIN from configuration? encode VIN? -canVin1 = { 0x47, 0x4E, 0x4C, 0x43, 0x32, 0x45, 0x30, 0x34 } -canVin2 = { 0x42, 0x52, 0x32, 0x31, 0x36, 0x33, 0x36, 0x36 } -dataECMEngineStatus = { 0x84, 0x09, 0x99, 0x0A, 0x00, 0x40, 0x08, 0x00 } - -function onTick() - txCan(1, VIN_Part1, 0, canVin1) - txCan(1, VIN_Part2, 0, canVin2) - - -- good enough for fuel module! - txCan(1, ECMEngineStatus, 0, dataECMEngineStatus) - - if isCranking then - setPwmDuty(STARTER_OUTPUT_INDEX, 1) - else - setPwmDuty(STARTER_OUTPUT_INDEX, 0) - end -end - - )", efi::size(config->luaScript)); } diff --git a/firmware/config/engines/gm_ls_4.cpp b/firmware/config/engines/gm_ls_4.cpp index dc4705c6fd..0e7cf832e2 100644 --- a/firmware/config/engines/gm_ls_4.cpp +++ b/firmware/config/engines/gm_ls_4.cpp @@ -9,6 +9,10 @@ void setGmLs4() { engineConfiguration->globalTriggerAngleOffset = 86; + // would not hurt just in case no cam + engineConfiguration->twoWireBatchInjection = true; + + engineConfiguration->fuelReferencePressure = 400; // 400 kPa, 58 psi engineConfiguration->injectorCompensationMode = ICM_FixedRailPressure; engineConfiguration->injector.flow = 440; @@ -23,4 +27,65 @@ void setGmLs4() { engineConfiguration->tChargeAirIncrLimit = 5; engineConfiguration->tChargeAirDecrLimit = 15; + + strncpy(config->luaScript, R"( + +function getBitRange(data, bitIndex, bitWidth) + byteIndex = bitIndex >> 3 + shift = bitIndex - byteIndex * 8 + value = data[1 + byteIndex] + if (shift + bitWidth > 8) then + value = value + data[2 + byteIndex] * 256 + end + mask = (1 << bitWidth) - 1 + return (value >> shift) & mask +end + +STARTER_OUTPUT_INDEX = 0 +startPwm(STARTER_OUTPUT_INDEX, 100, 0) + +-- 201 +ECMEngineStatus = 0xC9 +IGN_STATUS = 0x1f1 +-- 0x514 +VIN_Part1 = 1300 +-- 04E1 +VIN_Part2 = 1249 + +setTickRate(100) + +function canIgnStatus(bus, id, dlc, data) + crankingBits = getBitRange(data, 2, 2) + isCranking = (crankingBits == 2) + print('crankingBits ' .. crankingBits .. ', isCranking ' .. isCranking) +end + +canRxAdd(IGN_STATUS, canIgnStatus) + +-- todo: take VIN from configuration? encode VIN? +canVin1 = { 0x47, 0x4E, 0x4C, 0x43, 0x32, 0x45, 0x30, 0x34 } +canVin2 = { 0x42, 0x52, 0x32, 0x31, 0x36, 0x33, 0x36, 0x36 } +dataECMEngineStatus = { 0x84, 0x09, 0x99, 0x0A, 0x00, 0x40, 0x08, 0x00 } + +function onTick() + txCan(1, VIN_Part1, 0, canVin1) + txCan(1, VIN_Part2, 0, canVin2) + + -- good enough for fuel module! + txCan(1, ECMEngineStatus, 0, dataECMEngineStatus) + + if isCranking then + setPwmDuty(STARTER_OUTPUT_INDEX, 1) + else + setPwmDuty(STARTER_OUTPUT_INDEX, 0) + end +end + + )", efi::size(config->luaScript)); + +} + +void setProteusGmLs4() { + setGmLs4(); + } diff --git a/firmware/config/engines/gm_ls_4.h b/firmware/config/engines/gm_ls_4.h index 0033b3c8b8..a035c7cc7b 100644 --- a/firmware/config/engines/gm_ls_4.h +++ b/firmware/config/engines/gm_ls_4.h @@ -1,7 +1,7 @@ /* * gm_ls_4.h * - * Created on: 25 îêò. 2022 ã. + * Created on: 25 ���. 2022 �. * Author: Huge */ @@ -10,3 +10,4 @@ #include "engine_configuration.h" void setGmLs4(); +void setProteusGmLs4(); diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index b19b4b8b88..18c1f4cdcf 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -870,6 +870,9 @@ void resetConfigurationExt(configuration_callback_t boardCallback, engine_type_e break; #endif // HW_MICRO_RUSEFI #if HW_PROTEUS + case PROTEUS_GM_LS_4: + setProteusGmLs4(); + break; case PROTEUS_VW_B6: setProteusVwPassatB6(); break; diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 865d074784..cf14628100 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -1959,6 +1959,7 @@ cmd_set_engine_type_microRusEFI_Miata_NB2_MAP = "@@TS_IO_TEST_COMMAND_char@@@@t cmd_set_engine_type_microRusEFI_VW_B6 = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_SET_ENGINE_TYPE_16_hex@@@@engine_type_e_MRE_VW_B6_16_hex@@" cmd_set_engine_type_Proteus_VW_B6 = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_SET_ENGINE_TYPE_16_hex@@@@engine_type_e_PROTEUS_VW_B6_16_hex@@" +cmd_set_engine_type_PROTEUS_GM_LS_4 = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_SET_ENGINE_TYPE_16_hex@@@@engine_type_e_PROTEUS_GM_LS_4_16_hex@@" cmd_set_engine_type_microRusEFI_MRE_BODY_CONTROL = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_SET_ENGINE_TYPE_16_hex@@@@engine_type_e_MRE_BODY_CONTROL_16_hex@@" cmd_set_engine_type_MRE_SECONDARY_CAN = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_SET_ENGINE_TYPE_16_hex@@@@engine_type_e_MRE_SECONDARY_CAN_16_hex@@" @@ -2010,6 +2011,7 @@ cmd_set_engine_type_Frankenso_Miata_NB2 = "@@TS_IO_TEST_COMMAND_char@@@@ts_co cmd_set_engine_type_Proteus_M73 = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_SET_ENGINE_TYPE_16_hex@@@@engine_type_e_PROTEUS_BMW_M73_16_hex@@" cmd_set_engine_type_PROTEUS_VW_B6 = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_SET_ENGINE_TYPE_16_hex@@@@engine_type_e_PROTEUS_VW_B6_16_hex@@" +cmd_set_engine_type_PROTEUS_GM_LS_4 = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_SET_ENGINE_TYPE_16_hex@@@@engine_type_e_PROTEUS_GM_LS_4_16_hex@@" cmd_set_engine_type_PROTEUS_HONDA_K = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_SET_ENGINE_TYPE_16_hex@@@@engine_type_e_PROTEUS_HONDA_K_16_hex@@" cmd_set_engine_type_PROTEUS_HONDA_OBD2A = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_SET_ENGINE_TYPE_16_hex@@@@engine_type_e_PROTEUS_HONDA_OBD2A_16_hex@@" cmd_set_engine_type_PROTEUS_MIATA_NB2 = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_SET_ENGINE_TYPE_16_hex@@@@engine_type_e_PROTEUS_MIATA_NB2_16_hex@@"