| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | /* | |||
| 2 | * @file vw_b6.cpp | |||
| 3 | * | |||
| 4 | * @date Dec 26, 2019 | |||
| 5 | * @author Andrey Belomutskiy, (c) 2012-2020 | |||
| 6 | */ | |||
| 7 | ||||
| 8 | #include "pch.h" | |||
| 9 | ||||
| 10 | #include "vw_b6.h" | |||
| 11 | #include "table_helper.h" | |||
| 12 | #include "electronic_throttle.h" | |||
| 13 | #include "mre_meta.h" | |||
| 14 | #include "defaults.h" | |||
| 15 | #include "proteus_meta.h" | |||
| 16 | ||||
| 17 | #if HW_MICRO_RUSEFI || HW_PROTEUS | |||
| 18 | ✗ | static inline void commonPassatB6() { | ||
| 19 | ✗ | setCrankOperationMode(); | ||
| 20 | ✗ | engineConfiguration->trigger.type = trigger_type_e::TT_TOOTHED_WHEEL_60_2; | ||
| 21 | ✗ | engineConfiguration->vvtMode[0] = VVT_BOSCH_QUICK_START; | ||
| 22 | ✗ | engineConfiguration->map.sensor.type = MT_BOSCH_2_5; | ||
| 23 | ||||
| 24 | ✗ | engineConfiguration->globalTriggerAngleOffset = 90; | ||
| 25 | ||||
| 26 | ✗ | engineConfiguration->idlePidRpmDeadZone = 500; | ||
| 27 | ✗ | engineConfiguration->idleMode = idle_mode_e::IM_AUTO; | ||
| 28 | ||||
| 29 | ✗ | setInline4(); | ||
| 30 | ||||
| 31 | ✗ | engineConfiguration->disableEtbWhenEngineStopped = true; | ||
| 32 | ||||
| 33 | ||||
| 34 | ✗ | for (int i = 4; i < MAX_CYLINDER_COUNT;i++) { | ||
| 35 | ✗ | engineConfiguration->injectionPins[i] = Gpio::Unassigned; | ||
| 36 | ✗ | engineConfiguration->ignitionPins[i] = Gpio::Unassigned; | ||
| 37 | } | |||
| 38 | ||||
| 39 | // Injectors flow 1214 cc/min at 100 bar pressure | |||
| 40 | ✗ | engineConfiguration->injector.flow = 1214; | ||
| 41 | ✗ | setGDIFueling(); | ||
| 42 | ||||
| 43 | ✗ | strcpy(engineConfiguration->engineMake, ENGINE_MAKE_VAG); | ||
| 44 | ✗ | strcpy(engineConfiguration->engineCode, "BPY"); | ||
| 45 | ✗ | strcpy(engineConfiguration->vehicleName, "test"); | ||
| 46 | ||||
| 47 | ✗ | setPPSCalibration(0.36, 2.13, 0.73, 4.30); | ||
| 48 | ||||
| 49 | ✗ | engineConfiguration->invertCamVVTSignal = true; | ||
| 50 | ||||
| 51 | /** | |||
| 52 | * PSS-140 | |||
| 53 | */ | |||
| 54 | // todo: calibration | |||
| 55 | ✗ | engineConfiguration->highPressureFuel.v1 = 0.5; /* volts */; | ||
| 56 | ✗ | engineConfiguration->highPressureFuel.value1 = 0; | ||
| 57 | ✗ | engineConfiguration->highPressureFuel.v2 = 4.5; /* volts */; | ||
| 58 | ✗ | engineConfiguration->highPressureFuel.value2 = BAR2KPA(140); | ||
| 59 | ||||
| 60 | ✗ | engineConfiguration->lowPressureFuel.v1 = 0.5; /* volts */; | ||
| 61 | ✗ | engineConfiguration->lowPressureFuel.value1 = PSI2KPA(0); | ||
| 62 | ✗ | engineConfiguration->lowPressureFuel.v2 = 4.5; /* volts */; | ||
| 63 | // todo: what's the proper calibration of this Bosch sensor? is it really 200psi? | |||
| 64 | ✗ | engineConfiguration->lowPressureFuel.value2 = PSI2KPA(200); | ||
| 65 | ||||
| 66 | ✗ | gppwm_channel *lowPressureFuelPumpControl = &engineConfiguration->gppwm[1]; | ||
| 67 | ✗ | strcpy(engineConfiguration->gpPwmNote[1], "LPFP"); | ||
| 68 | ✗ | lowPressureFuelPumpControl->pwmFrequency = 20; | ||
| 69 | ✗ | lowPressureFuelPumpControl->loadAxis = GPPWM_FuelLoad; | ||
| 70 | ✗ | lowPressureFuelPumpControl->dutyIfError = 50; | ||
| 71 | ✗ | setTable(lowPressureFuelPumpControl->table, (uint8_t)50); | ||
| 72 | ||||
| 73 | ✗ | gppwm_channel *coolantControl = &engineConfiguration->gppwm[0]; | ||
| 74 | ✗ | strcpy(engineConfiguration->gpPwmNote[0], "Rad Fan"); | ||
| 75 | ✗ | coolantControl->loadAxis = GPPWM_Clt; | ||
| 76 | ||||
| 77 | ✗ | coolantControl->pwmFrequency = 25; | ||
| 78 | ✗ | coolantControl->loadAxis = GPPWM_FuelLoad; | ||
| 79 | // Volkswage wants 10% for fan to be OFF, between pull-up and low side control we need to invert that value | |||
| 80 | // todo system lua for duty driven by CLT? (3, Gpio::E0, "0.15 90 coolant 120 min max 90 - 30 / 0.8 * +", 25); | |||
| 81 | ✗ | int value = 100 - 10; | ||
| 82 | ✗ | coolantControl->dutyIfError = value; | ||
| 83 | ✗ | setTable(coolantControl->table, (uint8_t)value); | ||
| 84 | // for now I just want to stop radiator whine | |||
| 85 | // todo: enable cooling! | |||
| 86 | /* | |||
| 87 | for (int load = 0; load < GPPWM_LOAD_COUNT; load++) { | |||
| 88 | for (int r = 0; r < GPPWM_RPM_COUNT; r++) { | |||
| 89 | engineConfiguration->gppwm[0].table[load][r] = value; | |||
| 90 | } | |||
| 91 | } | |||
| 92 | */ | |||
| 93 | ||||
| 94 | ✗ | setTable(config->veTable, 55); | ||
| 95 | #if EFI_ELECTRONIC_THROTTLE_BODY | |||
| 96 | ✗ | setBoschVAGETB(); | ||
| 97 | #endif //EFI_ELECTRONIC_THROTTLE_BODY | |||
| 98 | ||||
| 99 | // random number just to take position away from zero | |||
| 100 | ✗ | engineConfiguration->vvtOffsets[0] = 180; | ||
| 101 | ||||
| 102 | // https://rusefi.com/forum/viewtopic.php?p=38235#p38235 | |||
| 103 | ✗ | engineConfiguration->injector.flow = 1200; | ||
| 104 | ||||
| 105 | ✗ | engineConfiguration->idle.solenoidPin = Gpio::Unassigned; | ||
| 106 | ✗ | engineConfiguration->fanPin = Gpio::Unassigned; | ||
| 107 | ✗ | } | ||
| 108 | #endif // HW_MICRO_RUSEFI || HW_PROTEUS | |||
| 109 | ||||
| 110 | ||||
| 111 | // MAF signal frequency after hardware divider x16, Hz | |||
| 112 | static const float hardCodedFreqBins[] = {139, | |||
| 113 | 152, | |||
| 114 | 180, | |||
| 115 | 217, | |||
| 116 | 280, | |||
| 117 | 300, | |||
| 118 | 365}; | |||
| 119 | ||||
| 120 | // MAF grams per second | |||
| 121 | static const float hardCodedGperSValues[] { | |||
| 122 | 3.58, | |||
| 123 | 4.5, | |||
| 124 | 6.7, | |||
| 125 | 11, | |||
| 126 | 22, | |||
| 127 | 25, | |||
| 128 | 40 | |||
| 129 | }; | |||
| 130 | ||||
| 131 | /** | |||
| 132 | * set engine_type 39 | |||
| 133 | */ | |||
| 134 | ✗ | void setProteusVwPassatB6() { | ||
| 135 | #if HW_PROTEUS | |||
| 136 | static_assert(sizeof(hardCodedFreqBins) == sizeof(hardCodedGperSValues)); | |||
| 137 | #if SCRIPT_CURVE_16 == 16 | |||
| 138 | { | |||
| 139 | ✗ | size_t mi = 0; | ||
| 140 | ✗ | for (; mi < efi::size(hardCodedFreqBins); mi++) { | ||
| 141 | ✗ | config->scriptCurve1Bins[mi] = hardCodedFreqBins[mi]; | ||
| 142 | ✗ | config->scriptCurve1[mi] = hardCodedGperSValues[mi]; | ||
| 143 | } | |||
| 144 | ||||
| 145 | ✗ | for (; mi < SCRIPT_CURVE_16; mi++) { | ||
| 146 | ✗ | config->scriptCurve1Bins[mi] = 3650 + mi; | ||
| 147 | ✗ | config->scriptCurve1[mi] = 4000; | ||
| 148 | } | |||
| 149 | } | |||
| 150 | ✗ | strcpy(engineConfiguration->scriptCurveName[0], "MAFcurve"); | ||
| 151 | #endif | |||
| 152 | ||||
| 153 | ✗ | commonPassatB6(); | ||
| 154 | ✗ | engineConfiguration->triggerInputPins[0] = PROTEUS_VR_1; | ||
| 155 | ✗ | engineConfiguration->camInputs[0] = PROTEUS_DIGITAL_2; | ||
| 156 | ||||
| 157 | ✗ | engineConfiguration->auxSpeedSensorInputPin[0] = PROTEUS_DIGITAL_5; | ||
| 158 | ||||
| 159 | ✗ | engineConfiguration->lowPressureFuel.hwChannel = PROTEUS_IN_ANALOG_VOLT_5; | ||
| 160 | ✗ | engineConfiguration->highPressureFuel.hwChannel = PROTEUS_IN_ANALOG_VOLT_4; | ||
| 161 | ||||
| 162 | ✗ | gppwm_channel *coolantControl = &engineConfiguration->gppwm[0]; | ||
| 163 | ✗ | coolantControl->pin = Gpio::PROTEUS_LS_5; | ||
| 164 | ||||
| 165 | ✗ | engineConfiguration->mainRelayPin = Gpio::PROTEUS_LS_6; | ||
| 166 | ||||
| 167 | ✗ | gppwm_channel *lowPressureFuelPumpControl = &engineConfiguration->gppwm[1]; | ||
| 168 | ✗ | lowPressureFuelPumpControl->pin = Gpio::PROTEUS_LS_7; | ||
| 169 | ||||
| 170 | //engineConfiguration->boostControlPin = Gpio::PROTEUS_LS_8; | |||
| 171 | ✗ | engineConfiguration->vvtPins[0] = Gpio::PROTEUS_LS_9; | ||
| 172 | ✗ | engineConfiguration->hpfpValvePin = Gpio::PROTEUS_LS_15; | ||
| 173 | ||||
| 174 | ✗ | setProteusEtbIO(); | ||
| 175 | ||||
| 176 | #if EFI_PROD_CODE | |||
| 177 | #include "vw_b6.lua" | |||
| 178 | #endif | |||
| 179 | ||||
| 180 | #endif // HW_PROTEUS | |||
| 181 | ✗ | } | ||
| 182 | ||||
| 183 | /** | |||
| 184 | * set engine_type 62 | |||
| 185 | * VW_B6 | |||
| 186 | * has to be microRusEFI 0.5.2 | |||
| 187 | */ | |||
| 188 | ✗ | void setMreVwPassatB6() { | ||
| 189 | #if HW_MICRO_RUSEFI | |||
| 190 | ✗ | commonPassatB6(); | ||
| 191 | ||||
| 192 | // engineConfiguration->afr.hwChannel = MRE_IN_ANALOG_VOLT_10; | |||
| 193 | ||||
| 194 | ✗ | engineConfiguration->tps1_2AdcChannel = MRE_IN_ANALOG_VOLT_9; | ||
| 195 | ||||
| 196 | ||||
| 197 | ||||
| 198 | // EFI_ADC_7: "31 - AN volt 3" - PA7 | |||
| 199 | // 36 - AN volt 8 | |||
| 200 | ✗ | setPPSInputs(MRE_IN_ANALOG_VOLT_3, MRE_IN_ANALOG_VOLT_8); | ||
| 201 | ||||
| 202 | // "26 - AN volt 2" | |||
| 203 | ✗ | engineConfiguration->highPressureFuel.hwChannel = MRE_IN_ANALOG_VOLT_2; | ||
| 204 | ||||
| 205 | ||||
| 206 | // "19 - AN volt 4" | |||
| 207 | ✗ | engineConfiguration->lowPressureFuel.hwChannel = EFI_ADC_12; | ||
| 208 | ||||
| 209 | ✗ | engineConfiguration->isSdCardEnabled = false; | ||
| 210 | ||||
| 211 | ✗ | engineConfiguration->mc33816spiDevice = SPI_DEVICE_3; | ||
| 212 | // RED | |||
| 213 | ✗ | engineConfiguration->spi3mosiPin = Gpio::C12; | ||
| 214 | // YELLOW | |||
| 215 | ✗ | engineConfiguration->spi3misoPin = Gpio::C11; | ||
| 216 | // BROWN | |||
| 217 | ✗ | engineConfiguration->spi3sckPin = Gpio::C10; | ||
| 218 | ✗ | engineConfiguration->sdCardCsPin = Gpio::Unassigned; | ||
| 219 | ✗ | engineConfiguration->is_enabled_spi_3 = true; | ||
| 220 | ||||
| 221 | ||||
| 222 | // J8 orange | |||
| 223 | ✗ | engineConfiguration->mc33816_cs = Gpio::B8; | ||
| 224 | // J8 Grey | |||
| 225 | ✗ | engineConfiguration->mc33816_rstb = Gpio::A15; | ||
| 226 | // J8 Dark BLUE | |||
| 227 | ✗ | engineConfiguration->mc33816_driven = Gpio::B9; | ||
| 228 | // J9 violet | |||
| 229 | ✗ | engineConfiguration->mc33816_flag0 = Gpio::C13; | ||
| 230 | ||||
| 231 | // J10 Dark BLUE | |||
| 232 | ✗ | engineConfiguration->injectionPins[0] = Gpio::E6; | ||
| 233 | // J11 green | |||
| 234 | ✗ | engineConfiguration->injectionPins[1] = Gpio::E5; | ||
| 235 | // J18 grey | |||
| 236 | ✗ | engineConfiguration->injectionPins[2] = Gpio::B7; | ||
| 237 | // J6 white | |||
| 238 | ✗ | engineConfiguration->injectionPins[3] = Gpio::E0; | ||
| 239 | ||||
| 240 | ||||
| 241 | ✗ | gppwm_channel *lowPressureFuelPumpControl = &engineConfiguration->gppwm[1]; | ||
| 242 | ||||
| 243 | // "42 - Injector 4", somehow GP4 did not work? not enough current? not happy with diode? | |||
| 244 | ✗ | lowPressureFuelPumpControl->pin = MRE_INJ_4; | ||
| 245 | ||||
| 246 | ||||
| 247 | ✗ | gppwm_channel *coolantControl = &engineConfiguration->gppwm[0]; | ||
| 248 | ||||
| 249 | ✗ | coolantControl->pin = MRE_LS_2; | ||
| 250 | // "7 - Lowside 1" | |||
| 251 | //engineConfiguration->hpfpValvePin = MRE_LS_1; | |||
| 252 | ✗ | engineConfiguration->hpfpValvePin = Gpio::B10; // AUX J13 | ||
| 253 | ||||
| 254 | ||||
| 255 | #endif /* HW_MICRO_RUSEFI */ | |||
| 256 | ✗ | } | ||
| 257 |