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 8 and 5
68 engineConfiguration->ignitionPins[1] = Gpio::MM100_IGN3;
73 // cylinders 7 and 4
74 engineConfiguration->ignitionPins[6] = Gpio::MM100_IGN4;
75 // cylinders 2 and 3
76 engineConfiguration->ignitionPins[7] = Gpio::MM100_IGN2;
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
93 engineConfiguration->firingOrder = FO_1_8_7_2_6_5_4_3;
95 engineConfiguration->map.sensor.type = MT_GM_1_BAR;
96
99
100// see https://github.com/rusefi/rusefi_documentation/tree/master/OEM-Docs/GM/Tahoe-2011
101 strncpy(config->luaScript, R"(
102
103function getBitRange(data, bitIndex, bitWidth)
104 byteIndex = bitIndex >> 3
105 shift = bitIndex - byteIndex * 8
106 value = data[1 + byteIndex]
107 if (shift + bitWidth > 8) then
108 value = value + data[2 + byteIndex] * 256
109 end
110 mask = (1 << bitWidth) - 1
111 return (value >> shift) & mask
112end
113
114hexstr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F" }
115
116function toHexString(num)
117 if num == 0 then
118 return '0'
119 end
120
121 local result = ""
122 while num > 0 do
123 local n = num % 16
124 result = hexstr[n + 1] ..result
125 num = math.floor(num / 16)
126 end
127 return result
128end
129
130function arrayToString(arr)
131 local str = ""
132 local index = 1
133 while arr[index] ~= nil do
134 str = str.." "..toHexString(arr[index])
135 index = index + 1
136 end
137 return str
138end
139
140STARTER_OUTPUT_INDEX = 0
141startPwm(STARTER_OUTPUT_INDEX, 100, 0)
142
143-- 201
144ECMEngineStatus = 0xC9
145IGN_STATUS = 0x1f1
146-- 0x514
147VIN_Part1 = 1300
148-- 04E1
149VIN_Part2 = 1249
150
151setTickRate(100)
152
153function canIgnStatus(bus, id, dlc, data)
154 crankingBits = getBitRange(data, 2, 2)
155 isCranking = (crankingBits == 2)
156-- need special considerations to append boolean print('crankingBits ' .. crankingBits .. ', isCranking ' .. isCranking)
157 print('crankingBits ' .. crankingBits)
158end
159
160function printAny(bus, id, dlc, data)
161 print('packet ' .. id)
162end
163
164canRxAdd(IGN_STATUS, canIgnStatus)
165-- canRxAddMask(0, 0xFFFFFFF, printAny)
166
167-- todo: take VIN from configuration? encode VIN?
168canVin1 = { 0x47, 0x4E, 0x4C, 0x43, 0x32, 0x45, 0x30, 0x34 }
169canVin2 = { 0x42, 0x52, 0x32, 0x31, 0x36, 0x33, 0x36, 0x36 }
170dataECMEngineStatus = { 0x84, 0x09, 0x99, 0x0A, 0x00, 0x40, 0x08, 0x00 }
171
172-- todo: smarter loop code :)
173canVin1[1] = vin(1)
174canVin1[2] = vin(2)
175canVin1[3] = vin(3)
176canVin1[4] = vin(4)
177canVin1[5] = vin(5)
178canVin1[6] = vin(6)
179canVin1[7] = vin(7)
180canVin1[8] = vin(8)
181
182canVin2[1] = vin(9)
183canVin2[2] = vin(10)
184canVin2[3] = vin(11)
185canVin2[4] = vin(12)
186canVin2[5] = vin(13)
187canVin2[6] = vin(14)
188canVin2[7] = vin(15)
189canVin2[8] = vin(16)
190
191function onTick()
192 txCan(1, VIN_Part1, 0, canVin1)
193 txCan(1, VIN_Part2, 0, canVin2)
194
195 -- good enough for fuel module!
196 txCan(1, ECMEngineStatus, 0, dataECMEngineStatus)
197
198 if isCranking then
199 setPwmDuty(STARTER_OUTPUT_INDEX, 1)
200 else
201 setPwmDuty(STARTER_OUTPUT_INDEX, 0)
202 end
203end
204
205 )", efi::size(config->luaScript));
206
207 setPPSCalibration(0.51, 2.11, 1.01, 4.23);
208 setTPS1Calibration(880, 129, 118, 870);
209}
@ 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.