This commit is contained in:
rusefillc 2022-09-18 17:20:42 -04:00
parent 8f3b680b2a
commit 90e8ffa215
1 changed files with 31 additions and 10 deletions

View File

@ -32,7 +32,11 @@ static void commonPassatB6() {
engineConfiguration->ignitionPins[i] = Gpio::Unassigned;
}
engineConfiguration->canNbcType = CAN_BUS_NBC_VAG;
// engineConfiguration->canNbcType = CAN_BUS_NBC_VAG;
engineConfiguration->enableAemXSeries = true;
engineConfiguration->afr.hwChannel = EFI_ADC_4;
// Injectors flow 1214 cc/min at 100 bar pressure
engineConfiguration->injector.flow = 1214;
@ -178,6 +182,22 @@ canRxAdd(BRAKE_2)
fuelCounter = 0
function setBitRange(data, totalBitIndex, bitWidth, value)
local byteIndex = totalBitIndex >> 3
local bitInByteIndex = totalBitIndex - byteIndex * 8
if (bitInByteIndex + bitWidth > 8) then
bitsToHandleNow = 8 - bitInByteIndex
setBitRange(data, totalBitIndex + bitsToHandleNow, bitWidth - bitsToHandleNow, value >> bitsToHandleNow)
bitWidth = bitsToHandleNow
end
mask = (1 << bitWidth) - 1
data[1 + byteIndex] = data[1 + byteIndex] & (~(mask << bitInByteIndex))
maskedValue = value & mask
shiftedValue = maskedValue << bitInByteIndex
data[1 + byteIndex] = data[1 + byteIndex] | shiftedValue
end
function setTwoBytes(data, offset, value)
data[offset + 1] = value % 255
data[offset + 2] = (value >> 8) % 255
@ -242,6 +262,8 @@ setTickRate(100)
everySecondTimer = Timer.new()
canMotorInfoCounter = 0
counter = 0
function onTick()
counter = (counter + 1) % 16
@ -284,8 +306,8 @@ function onTick()
mcu_standby()
end
if everySecondTimer:getElapsedSeconds() > 1 then
everySecondTimer:reset()
if everySecondTimer : getElapsedSeconds() > 1 then
everySecondTimer : reset()
fuelCounter = fuelCounter + 20
@ -295,7 +317,6 @@ function onTick()
end
end
)", efi::size(config->luaScript));
#endif