rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions
gm_ls_4.cpp File Reference

Functions

void setGmLs4 ()
 

Function Documentation

◆ setGmLs4()

void setGmLs4 ( )

Definition at line 15 of file gm_ls_4.cpp.

15 {
16 strcpy(engineConfiguration->engineMake, ENGINE_MAKE_GM);
17 strcpy(engineConfiguration->engineCode, "gen4");
19 engineConfiguration->vvtMode[0] = VVT_BOSCH_QUICK_START;
20
22
25
31
32
33#if HW_PROTEUS
35
36 setPPSInputs(PROTEUS_IN_ANALOG_VOLT_2, PROTEUS_IN_ANALOG_VOLT_11);
37 setTPS1Inputs(PROTEUS_IN_ANALOG_VOLT_4, PROTEUS_IN_ANALOG_VOLT_3);
38
39// todo: tps
40#endif //HW_PROTEUS
41
42#if defined(HW_HELLEN_8CHAN)
43 engineConfiguration->injectionPins[4] = Gpio::MM176_INJ5;
44 engineConfiguration->injectionPins[5] = Gpio::MM176_INJ6;
45 engineConfiguration->injectionPins[6] = Gpio::MM176_INJ7;
46 engineConfiguration->injectionPins[7] = Gpio::MM176_INJ8;
47 engineConfiguration->ignitionPins[4] = Gpio::MM176_IGN5;
48 engineConfiguration->ignitionPins[5] = Gpio::MM176_IGN6;
49 engineConfiguration->ignitionPins[6] = Gpio::MM176_IGN7;
50 engineConfiguration->ignitionPins[7] = Gpio::MM176_IGN8;
51
52 engineConfiguration->vvtPins[0] = Gpio::MM176_OUT_PWM1; // 8D - VVT 1
53 engineConfiguration->map.sensor.hwChannel = MM176_IN_CRANK_ANALOG;
54 engineConfiguration->triggerInputPins[0] = Gpio::MM176_IN_D4; // 9A
58#endif
59
60#ifdef HW_HELLEN_UAEFI
61 engineConfiguration->injectionPins[6] = Gpio::MM100_OUT_PWM1;
62 engineConfiguration->injectionPins[7] = Gpio::MM100_INJ8;
63
64 engineConfiguration->ignitionMode = IM_WASTED_SPARK;
65 // cylinders 1 and 6
66 engineConfiguration->ignitionPins[0] = Gpio::MM100_IGN1;
67 // cylinders 2 and 3
68 engineConfiguration->ignitionPins[1] = Gpio::MM100_IGN2;
73 // cylinders 7 and 4
74 engineConfiguration->ignitionPins[6] = Gpio::MM100_IGN4;
75 // cylinders 8 and 5
76 engineConfiguration->ignitionPins[7] = Gpio::MM100_IGN3;
77
78
79 engineConfiguration->triggerInputPins[0] = Gpio::MM100_IN_D1; // HALL1
81
82 engineConfiguration->camInputs[0] = Gpio::MM100_IN_D2; // HALL2
84
85#endif
86
87 engineConfiguration->fuelReferencePressure = 400; // 400 kPa, 58 psi
88 engineConfiguration->injectorCompensationMode = ICM_FixedRailPressure;
90
98
101 engineConfiguration->firingOrder = FO_1_8_7_2_6_5_4_3;
103 engineConfiguration->map.sensor.type = MT_GM_1_BAR;
104
107
108// see https://github.com/rusefi/rusefi_documentation/tree/master/OEM-Docs/GM/Tahoe-2011
109 strncpy(config->luaScript, R"(
110
111function getBitRange(data, bitIndex, bitWidth)
112 byteIndex = bitIndex >> 3
113 shift = bitIndex - byteIndex * 8
114 value = data[1 + byteIndex]
115 if (shift + bitWidth > 8) then
116 value = value + data[2 + byteIndex] * 256
117 end
118 mask = (1 << bitWidth) - 1
119 return (value >> shift) & mask
120end
121
122hexstr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F" }
123
124function toHexString(num)
125 if num == 0 then
126 return '0'
127 end
128
129 local result = ""
130 while num > 0 do
131 local n = num % 16
132 result = hexstr[n + 1] ..result
133 num = math.floor(num / 16)
134 end
135 return result
136end
137
138function arrayToString(arr)
139 local str = ""
140 local index = 1
141 while arr[index] ~= nil do
142 str = str.." "..toHexString(arr[index])
143 index = index + 1
144 end
145 return str
146end
147
148STARTER_OUTPUT_INDEX = 0
149startPwm(STARTER_OUTPUT_INDEX, 100, 0)
150
151-- 201
152ECMEngineStatus = 0xC9
153IGN_STATUS = 0x1f1
154-- 0x514
155VIN_Part1 = 1300
156-- 04E1
157VIN_Part2 = 1249
158
159setTickRate(100)
160
161function canIgnStatus(bus, id, dlc, data)
162 crankingBits = getBitRange(data, 2, 2)
163 isCranking = (crankingBits == 2)
164-- need special considerations to append boolean print('crankingBits ' .. crankingBits .. ', isCranking ' .. isCranking)
165 print('crankingBits ' .. crankingBits)
166end
167
168function printAny(bus, id, dlc, data)
169 print('packet ' .. id)
170end
171
172canRxAdd(IGN_STATUS, canIgnStatus)
173-- canRxAddMask(0, 0xFFFFFFF, printAny)
174
175-- todo: take VIN from configuration? encode VIN?
176canVin1 = { 0x47, 0x4E, 0x4C, 0x43, 0x32, 0x45, 0x30, 0x34 }
177canVin2 = { 0x42, 0x52, 0x32, 0x31, 0x36, 0x33, 0x36, 0x36 }
178dataECMEngineStatus = { 0x84, 0x09, 0x99, 0x0A, 0x00, 0x40, 0x08, 0x00 }
179
180-- todo: smarter loop code :)
181canVin1[1] = vin(1)
182canVin1[2] = vin(2)
183canVin1[3] = vin(3)
184canVin1[4] = vin(4)
185canVin1[5] = vin(5)
186canVin1[6] = vin(6)
187canVin1[7] = vin(7)
188canVin1[8] = vin(8)
189
190canVin2[1] = vin(9)
191canVin2[2] = vin(10)
192canVin2[3] = vin(11)
193canVin2[4] = vin(12)
194canVin2[5] = vin(13)
195canVin2[6] = vin(14)
196canVin2[7] = vin(15)
197canVin2[8] = vin(16)
198
199function onTick()
200 txCan(1, VIN_Part1, 0, canVin1)
201 txCan(1, VIN_Part2, 0, canVin2)
202
203 -- good enough for fuel module!
204 txCan(1, ECMEngineStatus, 0, dataECMEngineStatus)
205
206 if isCranking then
207 setPwmDuty(STARTER_OUTPUT_INDEX, 1)
208 else
209 setPwmDuty(STARTER_OUTPUT_INDEX, 0)
210 end
211end
212
213 )", efi::size(config->luaScript));
214
215 setPPSCalibration(0.51, 2.11, 1.01, 4.23);
216 setTPS1Calibration(880, 129, 118, 870);
217}
@ Unassigned
void setTPS1Calibration(uint16_t tpsMin, uint16_t tpsMax)
void setPPSInputs(adc_channel_e pps1, adc_channel_e pps2)
void setTPS1Inputs(adc_channel_e tps1, adc_channel_e tps2)
void setPPSCalibration(float primaryUp, float primaryDown, float secondaryUp, float secondaryDown)
void setLeftRightBanksNeedBetterName()
static constexpr persistent_config_s * config
static constexpr engine_configuration_s * engineConfiguration
brain_input_pin_e triggerInputPins[TRIGGER_INPUT_PIN_COUNT]

Referenced by applyEngineType(), and hellen_gm_e67_boardDefaultConfiguration().

Here is the call graph for this function:
Here is the caller graph for this function:

Go to the source code of this file.