| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | #include "pch.h" | |||
| 2 | #include "gm_sbc.h" | |||
| 3 | #include "defaults.h" | |||
| 4 | ||||
| 5 | #ifdef HW_HELLEN | |||
| 6 | #include "hellen_meta.h" | |||
| 7 | #endif // HW_HELLEN | |||
| 8 | ||||
| 9 | #ifdef HW_HELLEN_8CHAN | |||
| 10 | #include "connectors/generated_board_pin_names.h" | |||
| 11 | #endif // HW_HELLEN_8CHAN | |||
| 12 | ||||
| 13 | #include "proteus_meta.h" | |||
| 14 | ||||
| 15 | ✗ | void setStepperHw() { | ||
| 16 | ✗ | engineConfiguration->useStepperIdle = true; | ||
| 17 | ✗ | engineConfiguration->useHbridgesToDriveIdleStepper = true; | ||
| 18 | ✗ | engineConfiguration->stepper_dc_use_two_wires = false; | ||
| 19 | ✗ | engineConfiguration->stepperDcInvertedPins = false; // or true? | ||
| 20 | ||||
| 21 | // for instance IWP069 | |||
| 22 | ✗ | engineConfiguration->injector.flow = 482.5; | ||
| 23 | ✗ | setPPSInputs(EFI_ADC_NONE, EFI_ADC_NONE); | ||
| 24 | ||||
| 25 | #ifdef HW_HELLEN_8CHAN | |||
| 26 | // using 8chan pinout for DC1: A26 (OUT_DC1+ AH pin "D") and A27 (OUT_DC1- AL pin "C") | |||
| 27 | engineConfiguration->stepperDcIo[0].controlPin = Gpio::H144_GP_IO4; // DC1_PWM | |||
| 28 | engineConfiguration->stepperDcIo[0].directionPin1 = Gpio::H144_GP_IO3; // DC1_DIR | |||
| 29 | engineConfiguration->stepperDcIo[0].directionPin2 = Gpio::Unassigned; | |||
| 30 | engineConfiguration->stepperDcIo[0].disablePin = Gpio::H144_GP_IO5; // ETB_DIS | |||
| 31 | // using 8chan pinout for DC2: A28 (OUT_DC2+ BL pin "A") and A29 (OUT_DC2- BH pin "B") | |||
| 32 | engineConfiguration->stepperDcIo[1].controlPin = Gpio::H144_UART8_TX; // DC2_PWM | |||
| 33 | engineConfiguration->stepperDcIo[1].directionPin1 = H_SPI3_CS; // DC2_DIR | |||
| 34 | engineConfiguration->stepperDcIo[1].directionPin2 = Gpio::Unassigned; | |||
| 35 | #endif // HW_HELLEN | |||
| 36 | ||||
| 37 | #ifdef HW_HELLEN_UAEFI | |||
| 38 | // TODO: all the copy-pasting here begs the question: "shall we rename etbIo to hBridgeIo and reuse for stepper"? | |||
| 39 | engineConfiguration->stepperDcIo[0].controlPin = Gpio::MM100_OUT_PWM3; | |||
| 40 | engineConfiguration->stepperDcIo[0].directionPin1 = Gpio::MM100_OUT_PWM4; | |||
| 41 | engineConfiguration->stepperDcIo[0].directionPin2 = Gpio::Unassigned; | |||
| 42 | engineConfiguration->stepperDcIo[0].disablePin = Gpio::MM100_SPI2_MISO; | |||
| 43 | ||||
| 44 | engineConfiguration->stepperDcIo[1].controlPin = Gpio::MM100_OUT_PWM5; | |||
| 45 | engineConfiguration->stepperDcIo[1].directionPin1 = Gpio::MM100_SPI2_MOSI; | |||
| 46 | engineConfiguration->stepperDcIo[1].directionPin2 = Gpio::MM100_USB1ID; | |||
| 47 | #endif // HW_HELLEN_UAEFI | |||
| 48 | ||||
| 49 | #ifdef HW_PROTEUS | |||
| 50 | // coil #1 = proteus pin 15 (DC2 positive) to BL pin "A", pin B to pin 8 (DC2 negative) | |||
| 51 | // PWM pin | |||
| 52 | ✗ | engineConfiguration->stepperDcIo[0].controlPin = Gpio::D13; | ||
| 53 | // DIR pin | |||
| 54 | ✗ | engineConfiguration->stepperDcIo[0].directionPin1 = Gpio::D9; | ||
| 55 | // Disable pin | |||
| 56 | ✗ | engineConfiguration->stepperDcIo[0].disablePin = Gpio::D8; | ||
| 57 | // Unused | |||
| 58 | ✗ | engineConfiguration->stepperDcIo[0].directionPin2 = Gpio::Unassigned; | ||
| 59 | ||||
| 60 | // coil #2 - proteus pin 7 (DC1 positive) to AH pin "D", pin C to pin 6 (DC1 negative) | |||
| 61 | // PWM pin | |||
| 62 | ✗ | engineConfiguration->stepperDcIo[1].controlPin = Gpio::D12; | ||
| 63 | // DIR pin | |||
| 64 | ✗ | engineConfiguration->stepperDcIo[1].directionPin1 = Gpio::D10; | ||
| 65 | // Disable pin | |||
| 66 | ✗ | engineConfiguration->stepperDcIo[1].disablePin = Gpio::D11; | ||
| 67 | // Unused | |||
| 68 | ✗ | engineConfiguration->stepperDcIo[1].directionPin2 = Gpio::Unassigned; | ||
| 69 | ||||
| 70 | #endif // HW_PROTEUS | |||
| 71 | ✗ | } | ||
| 72 | ||||
| 73 | ✗ | static void gmRailSensor() { | ||
| 74 | ✗ | engineConfiguration->highPressureFuel.v1 = 0.5; /* volts */; | ||
| 75 | ✗ | engineConfiguration->highPressureFuel.value1 = 0; | ||
| 76 | ✗ | engineConfiguration->highPressureFuel.v2 = 4.5; /* volts */; | ||
| 77 | // fun fact: twice the range of VAG B6? | |||
| 78 | ✗ | engineConfiguration->highPressureFuel.value2 = 25300; | ||
| 79 | ✗ | } | ||
| 80 | ||||
| 81 | ✗ | void setGmSbc() { | ||
| 82 | ✗ | engineConfiguration->cylindersCount = 8; | ||
| 83 | // that's original firing order before gen 3 | |||
| 84 | ✗ | engineConfiguration->firingOrder = FO_1_8_4_3_6_5_7_2; | ||
| 85 | ✗ | engineConfiguration->displacement = 5.2; | ||
| 86 | ||||
| 87 | // see engine sniffer at https://github.com/rusefi/rusefi/issues/5353 | |||
| 88 | // if injectors are wired in groups of four best to use channels 1 and 4 | |||
| 89 | ✗ | engineConfiguration->crankingInjectionMode = IM_BATCH; | ||
| 90 | ✗ | engineConfiguration->injectionMode = IM_BATCH; | ||
| 91 | ||||
| 92 | ✗ | engineConfiguration->etbFunctions[0] = DC_None; | ||
| 93 | ✗ | engineConfiguration->etbFunctions[1] = DC_None; | ||
| 94 | ||||
| 95 | ✗ | strcpy(engineConfiguration->engineMake, ENGINE_MAKE_GM); | ||
| 96 | ✗ | strcpy(engineConfiguration->engineCode, "SBC"); | ||
| 97 | // white wire "HEI E" plug pin D | |||
| 98 | ✗ | engineConfiguration->ignitionMode = IM_ONE_COIL; | ||
| 99 | ✗ | engineConfiguration->globalTriggerAngleOffset = 24; | ||
| 100 | ||||
| 101 | ✗ | gppwm_channel *ignOverride = &engineConfiguration->gppwm[0]; | ||
| 102 | ✗ | ignOverride->pwmFrequency = 0; | ||
| 103 | ✗ | strcpy(engineConfiguration->gpPwmNote[0], "ign ovrrd B"); | ||
| 104 | ✗ | setTable(ignOverride->table, 100); | ||
| 105 | ||||
| 106 | #ifdef HW_HELLEN_UAEFI121 | |||
| 107 | // coil control plug pin A | |||
| 108 | ||||
| 109 | // tan wire with a black trace - "HEI B", plug pin B (we use yellow) | |||
| 110 | ignOverride->pin = Gpio::MM100_IGN2; // 12a Coil 2 | |||
| 111 | // tach plug pin C | |||
| 112 | engineConfiguration->triggerInputPins[0] = Gpio::MM100_IN_D2; // 35a HALL2 red wire | |||
| 113 | engineConfiguration->camInputs[0] = Gpio::Unassigned; | |||
| 114 | engineConfiguration->camInputs[1] = Gpio::Unassigned; | |||
| 115 | engineConfiguration->ignitionPins[1] = Gpio::Unassigned; | |||
| 116 | #endif // HW_HELLEN_UAEFI121 | |||
| 117 | ||||
| 118 | #if HW_PROTEUS | |||
| 119 | // tan wire with a black trace - "HEI B", plug pin B | |||
| 120 | ✗ | ignOverride->pin = Gpio::PROTEUS_IGN_12; | ||
| 121 | ✗ | engineConfiguration->fanPin = Gpio::Unassigned; | ||
| 122 | // reminder about D101 | |||
| 123 | ✗ | engineConfiguration->injectionPins[0] = Gpio::PROTEUS_LS_14; // #1 | ||
| 124 | // reminder about D104 | |||
| 125 | ✗ | engineConfiguration->injectionPins[3] = Gpio::PROTEUS_LS_15; // #4 | ||
| 126 | ||||
| 127 | // wow high side relay control on MEFI1 ELECTRONIC-FUEL-INJECTION-MEFI-1-2-5.7L-350CID-8.2L-502CID.pdf page 46 | |||
| 128 | ✗ | engineConfiguration->fuelPumpPin = Gpio::PROTEUS_HS_1; | ||
| 129 | // low side on MEFI3 ELECTRONIC-FUEL-INJECTION-MEFI-3-5.7L-350CID-8.2L-502CID.pdf page 487 | |||
| 130 | ||||
| 131 | ✗ | setGmCltSensor(&engineConfiguration->clt); | ||
| 132 | #endif // HW_PROTEUS | |||
| 133 | ✗ | engineConfiguration->mainRelayPin = Gpio::Unassigned; // vehicle controls main relay | ||
| 134 | ||||
| 135 | ✗ | setStepperHw(); | ||
| 136 | ||||
| 137 | // 8 cylinders one coil HEI trigger | |||
| 138 | ✗ | engineConfiguration->trigger.type = trigger_type_e::TT_TOOTHED_WHEEL; | ||
| 139 | ✗ | engineConfiguration->trigger.customTotalToothCount = 8; | ||
| 140 | ✗ | engineConfiguration->trigger.customSkippedToothCount = 0; | ||
| 141 | ✗ | engineConfiguration->skippedWheelOnCam = true; | ||
| 142 | // Proteus Digital 1 is Tach input "HEI R", plug pin C | |||
| 143 | ||||
| 144 | ✗ | engineConfiguration->map.sensor.type = MT_GM_1_BAR; | ||
| 145 | ✗ | } | ||
| 146 | ||||
| 147 | ✗ | static void setGmGdi() { | ||
| 148 | ✗ | engineConfiguration->camSyncOnSecondCrankRevolution = true; | ||
| 149 | ✗ | engineConfiguration->globalTriggerAngleOffset = 90; | ||
| 150 | ✗ | engineConfiguration->vvtMode[0] = VVT_BOSCH_QUICK_START; | ||
| 151 | ✗ | engineConfiguration->lowPressureFuel.hwChannel = EFI_ADC_NONE; | ||
| 152 | ✗ | gmRailSensor(); | ||
| 153 | ||||
| 154 | // is this oddly high or OKis? | |||
| 155 | ✗ | engineConfiguration->mc33_hpfp_i_peak = 10; | ||
| 156 | ✗ | engineConfiguration->mc33_hpfp_i_hold = 7; | ||
| 157 | ||||
| 158 | #ifdef HW_HELLEN_4K_GDI | |||
| 159 | engineConfiguration->invertCamVVTSignal = true; | |||
| 160 | engineConfiguration->invertExhaustCamVVTSignal = true; | |||
| 161 | ||||
| 162 | engineConfiguration->triggerInputPins[0] = Gpio::H144_IN_SENS2; // Digital Input 3 | |||
| 163 | engineConfiguration->camInputs[0] = Gpio::H144_IN_SENS3; // Digital Input 4 | |||
| 164 | engineConfiguration->camInputs[1] = Gpio::Unassigned; | |||
| 165 | engineConfiguration->sentInputPins[0] = Gpio::H144_IN_AUX2_DIGITAL; | |||
| 166 | setGmCltSensor(&engineConfiguration->clt); | |||
| 167 | ||||
| 168 | // engineConfiguration->starterControlPin = high side :() | |||
| 169 | #endif // HW_HELLEN_4K_GDI | |||
| 170 | ||||
| 171 | #ifdef HW_HELLEN_8CHAN | |||
| 172 | engineConfiguration->sentInputPins[0] = Gpio::MM176_IN_D3; | |||
| 173 | engineConfiguration->starterControlPin = Gpio::MM176_IGN5; // 14C | |||
| 174 | ||||
| 175 | engineConfiguration->map.sensor.hwChannel = MM176_IN_CRANK_ANALOG; // 1A Aux Analog 1. Important to use analog without muxing! | |||
| 176 | engineConfiguration->fuelPumpPin = Gpio::MM176_OUT_IO2; // 6C - High Side 2 orange/brown | |||
| 177 | engineConfiguration->hpfpValvePin = Gpio::MM176_GP17; // 19D Injector 9 | |||
| 178 | ||||
| 179 | engineConfiguration->camInputs[2] = Gpio::Unassigned; | |||
| 180 | engineConfiguration->camInputs[3] = Gpio::Unassigned; | |||
| 181 | config->boardUseCrankPullUp = true; | |||
| 182 | ||||
| 183 | engineConfiguration->starterControlPin = Gpio::PIN_5C; // 5C - High Side 1, ignition output is not enough at least on HHR | |||
| 184 | setGmCltSensor(&engineConfiguration->clt); | |||
| 185 | #endif // HW_HELLEN_8CHAN | |||
| 186 | ||||
| 187 | ✗ | setPPSCalibration(1, 4.25, 0.5, 2.14); | ||
| 188 | ||||
| 189 | ✗ | strcpy(engineConfiguration->engineMake, ENGINE_MAKE_GM); | ||
| 190 | ✗ | engineConfiguration->etbFunctions[1] = DC_None; | ||
| 191 | ✗ | setGDIFueling(); | ||
| 192 | ✗ | } | ||
| 193 | ||||
| 194 | ✗ | static void setGmEcotec3() { | ||
| 195 | ✗ | setGmGdi(); | ||
| 196 | ✗ | engineConfiguration->sentEtbType = SentEtbType::GM_TYPE_1; | ||
| 197 | ✗ | setTPS1Inputs(EFI_ADC_NONE, EFI_ADC_NONE); | ||
| 198 | ✗ | engineConfiguration->EtbSentInput = SentInput::INPUT1; | ||
| 199 | ✗ | } | ||
| 200 | ||||
| 201 | ✗ | static void set4CylGmEcotec3() { | ||
| 202 | ✗ | setGmEcotec3(); | ||
| 203 | ✗ | engineConfiguration->hpfpCamLobes = 4; | ||
| 204 | ✗ | setHpfpLobeProfileAngle(engineConfiguration->hpfpCamLobes); | ||
| 205 | ✗ | engineConfiguration->vvtMode[1] = VVT_BOSCH_QUICK_START; | ||
| 206 | ✗ | setInline4(); | ||
| 207 | ✗ | } | ||
| 208 | ||||
| 209 | ✗ | void setGmLcv() { | ||
| 210 | ✗ | set4CylGmEcotec3(); | ||
| 211 | ✗ | engineConfiguration->displacement = 2.5; | ||
| 212 | ✗ | engineConfiguration->map.sensor.type = MT_GM_1_BAR; | ||
| 213 | ✗ | strcpy(engineConfiguration->engineCode, "LCV"); | ||
| 214 | ✗ | } | ||
| 215 | ||||
| 216 | ✗ | void setGmLnf() { | ||
| 217 | ✗ | setGmGdi(); | ||
| 218 | ✗ | engineConfiguration->displacement = 2.0; | ||
| 219 | ✗ | strcpy(engineConfiguration->engineCode, "LNF"); | ||
| 220 | ✗ | setTPS1Calibration(880, 129, 118, 870); | ||
| 221 | ||||
| 222 | ✗ | engineConfiguration->hpfpPeakPos = 0; | ||
| 223 | ||||
| 224 | // todo: engineConfiguration->hpfpCam = HPFP_CAM_IN1; | |||
| 225 | #ifdef HW_HELLEN_8CHAN | |||
| 226 | engineConfiguration->vvtMode[1] = VVT_BOSCH_QUICK_START; | |||
| 227 | engineConfiguration->invertCamVVTSignal = true; | |||
| 228 | engineConfiguration->invertPrimaryTriggerSignal = true; | |||
| 229 | engineConfiguration->highPressureFuel.hwChannel = MM176_IN_MAP1_ANALOG; // 2A Aux Analog 4 | |||
| 230 | ||||
| 231 | engineConfiguration->vvtPins[0] = Gpio::MM176_OUT_PWM1; | |||
| 232 | engineConfiguration->vvtPins[1] = Gpio::MM176_OUT_PWM2; | |||
| 233 | #endif // HW_HELLEN_8CHAN | |||
| 234 | ✗ | } | ||
| 235 | ||||
| 236 | // 2.0T | |||
| 237 | ✗ | void setGmLtg() { | ||
| 238 | ✗ | set4CylGmEcotec3(); | ||
| 239 | ✗ | engineConfiguration->displacement = 2.0; | ||
| 240 | #ifdef HW_HELLEN_8CHAN | |||
| 241 | engineConfiguration->oilPressure.hwChannel = MM176_IN_MAP1_ANALOG; // 2A Aux Analog 4 | |||
| 242 | engineConfiguration->invertCamVVTSignal = true; | |||
| 243 | ||||
| 244 | engineConfiguration->triggerInputPins[0] = Gpio::MM176_IN_D4; // 9A - Hall Input 4 | |||
| 245 | ||||
| 246 | engineConfiguration->luaOutputPins[0] = Gpio::MM176_OUT_IO1; // 7C - High Side 3 - unusual starter | |||
| 247 | engineConfiguration->luaOutputPins[1] = Gpio::MM176_OUT_IO4, // 9C - Low Side 4 - unusual starter | |||
| 248 | #endif // HW_HELLEN_8CHAN | |||
| 249 | ✗ | strcpy(engineConfiguration->engineCode, "LTG"); | ||
| 250 | ✗ | } | ||
| 251 | ||||
| 252 | ✗ | void setGmSbcGen5() { | ||
| 253 | ✗ | setGmEcotec3(); | ||
| 254 | ✗ | engineConfiguration->hpfpCamLobes = 3; | ||
| 255 | ✗ | engineConfiguration->displacement = 5.3; | ||
| 256 | ✗ | engineConfiguration->cylindersCount = 8; | ||
| 257 | ✗ | engineConfiguration->firingOrder = FO_1_8_7_2_6_5_4_3; | ||
| 258 | ✗ | engineConfiguration->map.sensor.type = MT_GM_1_BAR; | ||
| 259 | ||||
| 260 | // engineConfiguration->hpfpPumpVolume = 0.623; // LT4 | |||
| 261 | ✗ | engineConfiguration->hpfpPumpVolume = 0.49; // cc per stroke | ||
| 262 | ||||
| 263 | // LT 17.7 g/sec at 100bar which 1440 | |||
| 264 | // todo: real flow! | |||
| 265 | ✗ | engineConfiguration->injector.flow = 990; // 12.6g/sec | ||
| 266 | ||||
| 267 | #ifdef HW_HELLEN_8CHAN | |||
| 268 | engineConfiguration->mc33_hpfp_i_peak = 15; | |||
| 269 | engineConfiguration->mc33_hpfp_i_hold = 7; | |||
| 270 | ||||
| 271 | engineConfiguration->injectionPins[4] = Gpio::MM176_INJ5; | |||
| 272 | engineConfiguration->injectionPins[5] = Gpio::MM176_INJ6; | |||
| 273 | engineConfiguration->injectionPins[6] = Gpio::MM176_INJ7; | |||
| 274 | engineConfiguration->injectionPins[7] = Gpio::MM176_INJ8; | |||
| 275 | ||||
| 276 | engineConfiguration->ignitionPins[4] = Gpio::MM176_IGN5; | |||
| 277 | engineConfiguration->ignitionPins[5] = Gpio::MM176_IGN6; | |||
| 278 | engineConfiguration->ignitionPins[6] = Gpio::MM176_IGN7; | |||
| 279 | engineConfiguration->ignitionPins[7] = Gpio::MM176_IGN8; | |||
| 280 | ||||
| 281 | engineConfiguration->starterControlPin = Gpio::MM176_SPI3_SCK; // 29C - Ignition 9 | |||
| 282 | ||||
| 283 | engineConfiguration->invertCamVVTSignal = true; | |||
| 284 | engineConfiguration->invertPrimaryTriggerSignal = true; | |||
| 285 | engineConfiguration->vvtMode[1] = VVT_INACTIVE; | |||
| 286 | engineConfiguration->camInputs[1] = Gpio::Unassigned; | |||
| 287 | ||||
| 288 | // early models before SENT | |||
| 289 | // todo: early gen5 LS engines have redundant high pressure sensors #7364 | |||
| 290 | engineConfiguration->highPressureFuel.v1 = 0.57; /* volts */; | |||
| 291 | engineConfiguration->highPressureFuel.value1 = 500; | |||
| 292 | engineConfiguration->highPressureFuel.v2 = 2.25; /* volts */; | |||
| 293 | engineConfiguration->highPressureFuel.value2 = 10900; | |||
| 294 | ||||
| 295 | engineConfiguration->lowPressureFuel.v1 = 2.9; /* volts */; | |||
| 296 | engineConfiguration->lowPressureFuel.value1 = 435; | |||
| 297 | engineConfiguration->lowPressureFuel.v2 = 3.7; /* volts */; | |||
| 298 | engineConfiguration->lowPressureFuel.value2 = 576; | |||
| 299 | ||||
| 300 | engineConfiguration->oilPressure.v1 = 0.6; | |||
| 301 | engineConfiguration->oilPressure.value1 = 0; // 100 kPa absolute | |||
| 302 | engineConfiguration->oilPressure.v2 = 2.6f; | |||
| 303 | engineConfiguration->oilPressure.value2 = 420; // 520 kPa absolute | |||
| 304 | ||||
| 305 | engineConfiguration->oilPressure.hwChannel = MM176_IN_MAP1_ANALOG; // 2A Aux Analog 4 | |||
| 306 | engineConfiguration->fuelLevelSensor = MM176_IN_O2S_ANALOG; // 3A - Aux Analog 2 | |||
| 307 | engineConfiguration->lowPressureFuel.hwChannel = MM176_IN_AUX2_ANALOG; // 4A - Aux Analog 7 | |||
| 308 | engineConfiguration->acPressure.hwChannel = MM176_IN_MAP2_ANALOG;// 10A - Aux Analog 5 | |||
| 309 | engineConfiguration->flexSensorPin = Gpio::MM176_IN_SENS3; | |||
| 310 | #endif // HW_HELLEN_8CHAN | |||
| 311 | ✗ | } | ||
| 312 |