rusefi-1/firmware/config/engines/hyundai.cpp

65 lines
1.5 KiB
C++
Raw Normal View History

2021-10-11 09:37:24 -07:00
/*
* @file hyundai.cpp
*
* @date Oct 11, 2021
* @author Andrey Belomutskiy, (c) 2012-2021
*/
2022-07-17 22:56:58 -07:00
#include "pch.h"
2021-10-11 09:37:24 -07:00
#include "hyundai.h"
2021-10-11 11:22:35 -07:00
2022-01-05 10:49:38 -08:00
static void commonGenesisCoupe() {
strncpy(config->luaScript, R"(
2022-01-08 16:46:00 -08:00
-- code outside of functions is invoked once on start-up
2022-01-05 10:49:38 -08:00
-- listen to CAN ID 0x4f0
canRxAdd(0x4f0)
-- todo: add payload logic
2022-01-08 16:46:00 -08:00
packet4f1 = { 0xFA, 0x54, 0x00, 0x0, 0x00, 0x51, 0x00, 0x00 }
2022-01-05 10:49:38 -08:00
function onCanRx(bus, id, dlc, data)
id11 = id % 2048
print('got CAN id=' .. id .. ' dlc=' .. dlc)
-- todo: add filtering logic if needed
rpm = getSensor("RPM")
-- handle nil RPM, todo: change firmware to avoid nil RPM
rpm = (rpm == nil and 0 or rpm)
if rpm > 800 then
-- at the moment we simply
2022-01-08 16:46:00 -08:00
txCan(1, 0x4f1, 0, packet4f1)
2022-01-05 10:49:38 -08:00
end
end
function onTick()
2022-01-08 16:46:00 -08:00
-- empty function onTick we are not doing anything periodically so far
2022-01-05 10:49:38 -08:00
end
)", efi::size(config->luaScript));
}
void setGenesisCoupeBK1() {
2022-01-05 10:49:38 -08:00
commonGenesisCoupe();
2021-10-11 11:22:35 -07:00
// 2010-2012 315cc at 43.5psi
// fuel system is fixed pressure 55psi
engineConfiguration->injector.flow = 354.19; // https://www.google.com/search?q=315*sqrt%2855%2F43.5%29
engineConfiguration->fuelReferencePressure = PSI2KPA(55);
}
void setGenesisCoupeBK2() {
2022-01-05 10:49:38 -08:00
commonGenesisCoupe();
2021-10-11 11:22:35 -07:00
// 2013+ 450cc at 43.5
// fuel system is fixed pressure 85psi
// flow rate P2 = flow rate P1 * sqrt(P2/P1)
engineConfiguration->injector.flow = 629.03; // https://www.google.com/search?q=450*sqrt%2885%2F43.5%29
engineConfiguration->fuelReferencePressure = PSI2KPA(85);
}