39 {
41
47
52
55
62
63
65
68
70
72
74
77
80
84
88
90
91#ifdef HW_HELLEN_4K_GDI
93
94#endif
95
96#ifdef HW_HELLEN_4CHAN
100
106#endif
107
108#if defined(HW_HELLEN_4CHAN) || EFI_UNIT_TEST
110#endif
111
112#if HW_PROTEUS && EFI_PROD_CODE
116
117
119
125
126
130
132
133
136#endif
138
139#if HW_PROTEUS || HW_HELLEN_4CHAN
140 strncpy(
config->
luaScript, GET_BIT_RANGE_LSB TWO_BYTES_LSB PRINT_ARRAY SET_TWO_BYTES_LSB HYUNDAI_SUM_NIBBLES R
"(
141
142GDI4_BASE_ADDRESS = 0xBB20
143GDI_CHANGE_ADDRESS = GDI4_BASE_ADDRESS + 0x10
144
145GDI4_CAN_SET_TAG = 0x78
146local data_set_settings = { GDI4_CAN_SET_TAG, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
147
148FIXED_POINT = 128
149
150setTickRate(100)
151
152function onCanConfiguration3(bus, id, dlc, data)
153 -- print("Received configuration3 "..arrayToString(data))
154 pumpPeak = getTwoBytesLSB(data, 6, 1 / 128)
155 print("GDI4 says PumpPeakCurrent ".. pumpPeak)
156 setLuaGauge(1, pumpPeak)
157end
158
159function onCanVersion(bus, id, dlc, data)
160 year = data[1] * 100 + data[2]
161 month = data[3]
162 day = data[4]
163-- print ("GDI4 firmware " ..year ..'/' ..month ..'/' ..day)
164end
165
166canRxAdd(GDI4_BASE_ADDRESS + 3, onCanConfiguration3)
167canRxAdd(GDI4_BASE_ADDRESS + 5, onCanVersion)
168
169
170EMS_DCT11_128 = 0x80
171EMS_DCT12_129 = 0x81
172EMS_H12_399 = 0x18f
173EMS6_608 = 0x260
174EMS5_672 = 0x2a0
175EMS11_790 = 0x316
176EMS12_809 = 0x329
177EMS9_898 = 0x382
178EMS14_1349 = 0x545
179
180counter = 0
181
182payLoad128 = { 0x00, 0x17, 0x70, 0x0F, 0x1B, 0x2C, 0x1B, 0x75 }
183payLoad129 = { 0x40, 0x84, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x75 }
184payLoad399 = { 0x00, 0x30, 0x1d, 0x00, 0x00, 0x63, 0x00, 0x00 }
185payLoad608 = { 0x05, 0x1d, 0x00, 0x30, 0x01, 0xa5, 0x7f, 0x31 }
186payLoad672 = { 0xe0, 0x00, 0x5f, 0x98, 0x39, 0x12, 0x9e, 0x08 }
187payLoad809 = { 0xd7, 0x7b, 0x7e, 0x0c, 0x11, 0x2c, 0x00, 0x10 }
188payLoad898 = { 0x40, 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x08 }
189payLoad1349 = { 0xCA, 0x16, 0x00, 0x8A, 0x75, 0xFF, 0x75, 0xFF }
190
191speedSensor = Sensor.new("VehicleSpeed")
192speedSensor : setTimeout(3000)
193
194function onCluPacket(bus, id, dlc, data)
195 speedKph = getBitRange(data, 8, 9) * 0.5
196-- print('onCAR_SPEED ' ..speedKph)
197 speedSensor : set(speedKph)
198end
199
200canRxAdd(1, 1264, onCluPacket)
201
202function onTick()
203 local RPMread = math.floor(getSensor("RPM") * 4)
204 local RPMhi = RPMread >> 8
205 local RPMlo = RPMread & 0xff
206
207 payLoad128[3] = RPMlo
208 payLoad128[4] = RPMhi
209
210 counter = (counter + 1) % 16
211
212 check128 = hyundaiSumNibbles(payLoad128, counter)
213 payLoad128[8] = check128 * 16 + counter
214 txCan(1, EMS_DCT11_128, 0, payLoad128)
215
216 check129 = hyundaiSumNibbles(payLoad129, counter)
217 payLoad129[8] = check129 * 16 + counter
218 txCan(1, EMS_DCT12_129, 0, payLoad129)
219
220 canRPMpayload = { 0x05, 0x1B, RPMlo, RPMhi, 0x1B, 0x2C, 0x00, 0x7F }
221
222 txCan(1, EMS11_790, 0, canRPMpayload)
223 txCan(1, EMS14_1349, 0, payLoad1349)
224
225 txCan(1, EMS_H12_399, 0, payLoad399)
226 txCan(1, EMS6_608, 0, payLoad608)
227 txCan(1, EMS5_672, 0, payLoad672)
228 txCan(1, EMS12_809, 0, payLoad809)
229 txCan(1, EMS9_898, 0, payLoad898)
230
231 pumpPeakCurrent = getCalibration("mc33_hpfp_i_peak")
232 pumpHoldCurrent = getCalibration("mc33_hpfp_i_hold")
233
234 TholdOff = getCalibration("mc33_t_hold_off")
235 THoldDuration = getCalibration("mc33_t_hold_tot")
236
237
238 setTwoBytesLsb(data_set_settings, 1, TholdOff)
239 setTwoBytesLsb(data_set_settings, 3, THoldDuration)
240 setTwoBytesLsb(data_set_settings, 5, pumpPeakCurrent * FIXED_POINT)
241-- print('Will be sending ' ..arrayToString(data_set_settings))
242 txCan(1, GDI_CHANGE_ADDRESS + 3, 1, data_set_settings)
243
244 setTwoBytesLsb(data_set_settings, 1, pumpHoldCurrent * FIXED_POINT)
245 setTwoBytesLsb(data_set_settings, 3, GDI4_BASE_ADDRESS)
246-- print('Will be sending ' ..arrayToString(data_set_settings))
247 txCan(1, GDI_CHANGE_ADDRESS + 4, 1, data_set_settings)
248end
249
251#endif
252
253}
void setHpfpLobeProfileAngle(int lobes)
void setCustomMap(float lowValue, float mapLowValueVoltage, float highValue, float mapHighValueVoltage)
static constexpr persistent_config_s * config
static void set201xHyundai()
air_pressure_sensor_config_s sensor
vehicle_info_t engineMake
output_pin_e hpfpValvePin
angle_t globalTriggerAngleOffset
scaled_channel< uint16_t, 100, 1 > gearRatio[TCU_GEAR_COUNT]
linear_sensor_s highPressureFuel
output_pin_e vvtPins[CAM_INPUTS_COUNT]
scaled_channel< uint8_t, 10, 1 > mc33_hpfp_i_hold
bool disableEtbWhenEngineStopped
vvt_mode_e vvtMode[CAMS_PER_BANK]
switch_input_pin_e acSwitch
pin_input_mode_e startStopButtonMode
output_pin_e starterControlPin
float etbIdleThrottleRange
output_pin_e tachOutputPin
float vvtOffsets[CAM_INPUTS_COUNT]
brain_input_pin_e triggerInputPins[TRIGGER_INPUT_PIN_COUNT]
vehicle_info_t engineCode
switch_input_pin_e startStopButtonPin
brain_input_pin_e camInputs[CAM_INPUTS_COUNT]
scaled_channel< uint8_t, 10, 1 > mc33_hpfp_i_peak
bool boardUse2stepPullDown
void setCommonNTCSensorParameters(ThermistorConf *thermistorConf)