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 17 of file gm_ls_4.cpp.

17 {
18 strcpy(engineConfiguration->engineMake, ENGINE_MAKE_GM);
19 strcpy(engineConfiguration->engineCode, "gen4");
21 engineConfiguration->vvtMode[0] = VVT_BOSCH_QUICK_START;
22
27
28
31
37
38
39#if HW_PROTEUS
41
42 setPPSInputs(PROTEUS_IN_ANALOG_VOLT_2, PROTEUS_IN_ANALOG_VOLT_11);
43 setTPS1Inputs(PROTEUS_IN_ANALOG_VOLT_4, PROTEUS_IN_ANALOG_VOLT_3);
44
45// todo: tps
46#endif //HW_PROTEUS
47
48#if defined(HW_HELLEN_8CHAN)
49 engineConfiguration->injectionPins[4] = Gpio::MM176_INJ5;
50 engineConfiguration->injectionPins[5] = Gpio::MM176_INJ6;
51 engineConfiguration->injectionPins[6] = Gpio::MM176_INJ7;
52 engineConfiguration->injectionPins[7] = Gpio::MM176_INJ8;
53 engineConfiguration->ignitionPins[4] = Gpio::MM176_IGN5;
54 engineConfiguration->ignitionPins[5] = Gpio::MM176_IGN6;
55 engineConfiguration->ignitionPins[6] = Gpio::MM176_IGN7;
56 engineConfiguration->ignitionPins[7] = Gpio::MM176_IGN8;
57
58 engineConfiguration->vvtPins[0] = Gpio::MM176_OUT_PWM1; // 8D - VVT 1
59 engineConfiguration->map.sensor.hwChannel = MM176_IN_CRANK_ANALOG;
60 engineConfiguration->triggerInputPins[0] = Gpio::MM176_IN_D4; // 9A
64#endif
65
66#ifdef HW_HELLEN_UAEFI121
68 // cylinders 1 and 6
69 // cylinders 2 and 3
74 // cylinders 7 and 4
75 engineConfiguration->ignitionPins[6] = Gpio::MM100_IGN4;
76 // cylinders 8 and 5
77 engineConfiguration->ignitionPins[7] = Gpio::MM100_IGN3;
79#endif
80
81#ifdef HW_HELLEN_SUPER_UAEFI
82 engineConfiguration->triggerInputPins[0] = Gpio::MM100_IN_D2; // HALL2
83
85 engineConfiguration->map.sensor.hwChannel = MM100_IN_MAP1_ANALOG;
86
87 engineConfiguration->injectionPins[6] = Gpio::MM100_INJ7;
88 engineConfiguration->injectionPins[7] = Gpio::MM100_INJ8;
89
94 // cylinders 7 and 4
95 engineConfiguration->ignitionPins[6] = Gpio::MM100_IGN4;
96 // cylinders 8 and 5
97 engineConfiguration->ignitionPins[7] = Gpio::MM100_IGN5;
99#endif
100
101#ifdef HW_HELLEN_UAEFI
102 engineConfiguration->injectionPins[6] = Gpio::MM100_OUT_PWM1;
103 engineConfiguration->injectionPins[7] = Gpio::MM100_INJ8;
104
105 engineConfiguration->ignitionMode = IM_WASTED_SPARK;
106 // cylinders 1 and 6
107 engineConfiguration->ignitionPins[0] = Gpio::MM100_IGN1;
108 // cylinders 2 and 3
109 engineConfiguration->ignitionPins[1] = Gpio::MM100_IGN2;
114 // cylinders 7 and 4
115 engineConfiguration->ignitionPins[6] = Gpio::MM100_IGN4;
116 // cylinders 8 and 5
117 engineConfiguration->ignitionPins[7] = Gpio::MM100_IGN3;
118
119
120 engineConfiguration->triggerInputPins[0] = Gpio::MM100_IN_D1; // HALL1
122
123 engineConfiguration->camInputs[0] = Gpio::MM100_IN_D2; // HALL2
125
126#endif
127
128 engineConfiguration->fuelReferencePressure = 400; // 400 kPa, 58 psi
129 engineConfiguration->injectorCompensationMode = ICM_FixedRailPressure;
131
139
142 engineConfiguration->firingOrder = FO_1_8_7_2_6_5_4_3;
144 engineConfiguration->map.sensor.type = MT_GM_1_BAR;
145
148
149// see https://github.com/rusefi/rusefi_documentation/tree/master/OEM-Docs/GM/Tahoe-2011
150 setLuaScript( R"(
151
152function getBitRange(data, bitIndex, bitWidth)
153 byteIndex = bitIndex >> 3
154 shift = bitIndex - byteIndex * 8
155 value = data[1 + byteIndex]
156 if (shift + bitWidth > 8) then
157 value = value + data[2 + byteIndex] * 256
158 end
159 mask = (1 << bitWidth) - 1
160 return (value >> shift) & mask
161end
162
163hexstr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F" }
164
165function toHexString(num)
166 if num == 0 then
167 return '0'
168 end
169
170 local result = ""
171 while num > 0 do
172 local n = num % 16
173 result = hexstr[n + 1] ..result
174 num = math.floor(num / 16)
175 end
176 return result
177end
178
179function arrayToString(arr)
180 local str = ""
181 local index = 1
182 while arr[index] ~= nil do
183 str = str.." "..toHexString(arr[index])
184 index = index + 1
185 end
186 return str
187end
188
189STARTER_OUTPUT_INDEX = 0
190startPwm(STARTER_OUTPUT_INDEX, 100, 0)
191
192-- 201
193ECMEngineStatus = 0xC9
194IGN_STATUS = 0x1f1
195-- 0x514
196VIN_Part1 = 1300
197-- 04E1
198VIN_Part2 = 1249
199
200setTickRate(100)
201
202function canIgnStatus(bus, id, dlc, data)
203 crankingBits = getBitRange(data, 2, 2)
204 isCranking = (crankingBits == 2)
205-- need special considerations to append boolean print('crankingBits ' .. crankingBits .. ', isCranking ' .. isCranking)
206 print('crankingBits ' .. crankingBits)
207end
208
209function printAny(bus, id, dlc, data)
210 print('packet ' .. id)
211end
212
213canRxAdd(IGN_STATUS, canIgnStatus)
214-- canRxAddMask(0, 0xFFFFFFF, printAny)
215
216-- todo: take VIN from configuration? encode VIN?
217canVin1 = { 0x47, 0x4E, 0x4C, 0x43, 0x32, 0x45, 0x30, 0x34 }
218canVin2 = { 0x42, 0x52, 0x32, 0x31, 0x36, 0x33, 0x36, 0x36 }
219dataECMEngineStatus = { 0x84, 0x09, 0x99, 0x0A, 0x00, 0x40, 0x08, 0x00 }
220
221-- todo: smarter loop code :)
222canVin1[1] = vin(1)
223canVin1[2] = vin(2)
224canVin1[3] = vin(3)
225canVin1[4] = vin(4)
226canVin1[5] = vin(5)
227canVin1[6] = vin(6)
228canVin1[7] = vin(7)
229canVin1[8] = vin(8)
230
231canVin2[1] = vin(9)
232canVin2[2] = vin(10)
233canVin2[3] = vin(11)
234canVin2[4] = vin(12)
235canVin2[5] = vin(13)
236canVin2[6] = vin(14)
237canVin2[7] = vin(15)
238canVin2[8] = vin(16)
239
240function onTick()
241 txCan(1, VIN_Part1, 0, canVin1)
242 txCan(1, VIN_Part2, 0, canVin2)
243
244 -- good enough for fuel module!
245 txCan(1, ECMEngineStatus, 0, dataECMEngineStatus)
246
247 if isCranking then
248 setPwmDuty(STARTER_OUTPUT_INDEX, 1)
249 else
250 setPwmDuty(STARTER_OUTPUT_INDEX, 0)
251 end
252end
253
254 )");
255
256 setPPSCalibration(0.51, 2.11, 1.01, 4.23);
257 setTPS1Calibration(880, 129, 118, 870);
258}
@ 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 engine_configuration_s * engineConfiguration
void setLuaScript(const char *luaScript)
Definition settings.cpp:761
brain_input_pin_e triggerInputPins[TRIGGER_INPUT_PIN_COUNT]
void setGmCltSensor(ThermistorConf *thermistorConf)

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.