| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | /** | |||
| 2 | * @file test_engine.cpp | |||
| 3 | * | |||
| 4 | * set engine_type 26 | |||
| 5 | * VVT | |||
| 6 | * set engine_type 45 | |||
| 7 | * | |||
| 8 | * See also custom_engine.cpp | |||
| 9 | * | |||
| 10 | * @date Nov 14, 2014 | |||
| 11 | * @author Andrey Belomutskiy, (c) 2012-2020 | |||
| 12 | */ | |||
| 13 | ||||
| 14 | #include "pch.h" | |||
| 15 | #include "test_engine.h" | |||
| 16 | #include "proteus_meta.h" | |||
| 17 | ||||
| 18 | 2 | void setTestEngineBoschQuickStart() { | ||
| 19 | 2 | engineConfiguration->trigger.type = trigger_type_e::TT_VVT_BOSCH_QUICK_START; | ||
| 20 | 2 | } | ||
| 21 | ||||
| 22 | 1 | void setTestEngineWithBoschQuickStartCam() { | ||
| 23 | 1 | engineConfiguration->trigger.type = trigger_type_e::TT_HALF_MOON; | ||
| 24 | 1 | engineConfiguration->vvtMode[0] = VVT_BOSCH_QUICK_START; | ||
| 25 | 1 | } | ||
| 26 | ||||
| 27 | // TEST_ENGINE | |||
| 28 | 531 | void setTestCamEngineConfiguration() { | ||
| 29 | 531 | engineConfiguration->trigger.type = trigger_type_e::TT_ONE_PLUS_ONE; | ||
| 30 | 531 | setCamOperationMode(); | ||
| 31 | ||||
| 32 | 531 | engineConfiguration->mafAdcChannel = EFI_ADC_1; | ||
| 33 | 531 | engineConfiguration->tps1_1AdcChannel = EFI_ADC_2; | ||
| 34 | 531 | engineConfiguration->vbattAdcChannel = EFI_ADC_NONE; | ||
| 35 | ||||
| 36 | 531 | setWholeIatCorrTimingTable(0); | ||
| 37 | ||||
| 38 | // Many tests were written when the default target AFR was 14.0, so use that for tests by default. | |||
| 39 | 531 | engineConfiguration->stoichRatioPrimary = 14.0f; | ||
| 40 | ||||
| 41 | 531 | engineConfiguration->ignitionMode = IM_ONE_COIL; | ||
| 42 | 531 | setConstantDwell(3); // 50% duty cycle @ 5000 rpm | ||
| 43 | ||||
| 44 | 531 | engineConfiguration->malfunctionIndicatorPin = Gpio::Unassigned; | ||
| 45 | ||||
| 46 | 531 | engineConfiguration->ignitionPins[0] = Gpio::C7; // #1 | ||
| 47 | 531 | engineConfiguration->ignitionPins[1] = Gpio::Unassigned; // #2 | ||
| 48 | 531 | engineConfiguration->ignitionPins[2] = Gpio::Unassigned; // #3 | ||
| 49 | 531 | engineConfiguration->ignitionPins[3] = Gpio::Unassigned; // #4 | ||
| 50 | 531 | engineConfiguration->ignitionPins[4] = Gpio::Unassigned; // #5 | ||
| 51 | 531 | engineConfiguration->ignitionPins[5] = Gpio::Unassigned; // #6 | ||
| 52 | 531 | } | ||
| 53 | ||||
| 54 | 10 | void setTestCrankEngineConfiguration() { | ||
| 55 | 10 | setTestCamEngineConfiguration(); | ||
| 56 | ||||
| 57 | 10 | engineConfiguration->trigger.type = trigger_type_e::TT_HALF_MOON; | ||
| 58 | ||||
| 59 | 10 | setCrankOperationMode(); | ||
| 60 | // this is related to 'setDefaultBaseEngine' having 'skippedWheelOnCam = true' which is a weird fact by itself | |||
| 61 | 10 | engineConfiguration->skippedWheelOnCam = false; | ||
| 62 | 10 | } | ||
| 63 | ||||
| 64 | ✗ | void setTestDcWastegateConfiguration() { | ||
| 65 | ✗ | engineConfiguration->isBoostControlEnabled = 1; | ||
| 66 | ✗ | engineConfiguration->etbFunctions[0] = DC_Wastegate; | ||
| 67 | ✗ | setTable(config->boostTableOpenLoop, 50); | ||
| 68 | ✗ | engineConfiguration->tps1_1AdcChannel = EFI_ADC_1; // PA1 | ||
| 69 | ||||
| 70 | // PWM pin | |||
| 71 | ✗ | engineConfiguration->etbIo[0].controlPin = Gpio::C0; | ||
| 72 | // DIR pin | |||
| 73 | ✗ | engineConfiguration->etbIo[0].directionPin1 = Gpio::C1; | ||
| 74 | // Disable pin | |||
| 75 | ✗ | engineConfiguration->etbIo[0].disablePin = Gpio::C2; | ||
| 76 | // we only have pwm/dir, no dira/dirb | |||
| 77 | ✗ | engineConfiguration->etb_use_two_wires = false; | ||
| 78 | ✗ | } | ||
| 79 | ||||
| 80 | ✗ | void setTestVVTEngineConfiguration() { | ||
| 81 | ✗ | setCrankOperationMode(); | ||
| 82 | ||||
| 83 | ✗ | engineConfiguration->trigger.type = trigger_type_e::TT_TOOTHED_WHEEL; | ||
| 84 | ✗ | engineConfiguration->trigger.customTotalToothCount = 3; | ||
| 85 | ✗ | engineConfiguration->trigger.customSkippedToothCount = 1; | ||
| 86 | ||||
| 87 | // set algorithm 3 | |||
| 88 | ✗ | setAlgorithm(engine_load_mode_e::LM_SPEED_DENSITY); | ||
| 89 | ||||
| 90 | ✗ | engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; | ||
| 91 | ✗ | engineConfiguration->camInputs[0] = Gpio::A5; | ||
| 92 | ||||
| 93 | // set global_trigger_offset_angle 0 | |||
| 94 | ✗ | engineConfiguration->globalTriggerAngleOffset = 0; | ||
| 95 | ||||
| 96 | ✗ | engineConfiguration->vvtMode[0] = VVT_SINGLE_TOOTH; | ||
| 97 | ✗ | } | ||
| 98 | ||||
| 99 | #if EFI_UNIT_TEST | |||
| 100 | 2 | void setTestEngineIssue366both() { | ||
| 101 | 2 | setTestCamEngineConfiguration(); | ||
| 102 | ||||
| 103 | 2 | engineConfiguration->trigger.customTotalToothCount = 2; | ||
| 104 | 2 | engineConfiguration->trigger.customSkippedToothCount = 1; | ||
| 105 | ||||
| 106 | 2 | engineConfiguration->trigger.type = trigger_type_e::TT_TOOTHED_WHEEL; | ||
| 107 | 2 | } | ||
| 108 | ||||
| 109 | 1 | void setTestEngineIssue366rise() { | ||
| 110 | 1 | setTestEngineIssue366both(); | ||
| 111 | 1 | } | ||
| 112 | #endif /* EFI_UNIT_TEST */ | |||
| 113 | ||||
| 114 | #ifdef HARDWARE_CI | |||
| 115 | // set engine_type 30 | |||
| 116 | void setProteusAnalogPwmTest() { | |||
| 117 | engineConfiguration->camInputs[0] = Gpio::E0; // a random unused pin needed for happy HW CI. Huh, why do we have cam stimulation?! | |||
| 118 | ||||
| 119 | // lowest cpu trigger possible | |||
| 120 | engineConfiguration->trigger.type = trigger_type_e::TT_HALF_MOON; | |||
| 121 | ||||
| 122 | // Disable trigger stim | |||
| 123 | engineConfiguration->triggerSimulatorPins[0] = Gpio::Unassigned; | |||
| 124 | engineConfiguration->triggerSimulatorPins[1] = Gpio::Unassigned; | |||
| 125 | ||||
| 126 | // The idle control pin is connected to the default TPS input, analog volt 2 | |||
| 127 | engineConfiguration->idle.solenoidPin = Gpio::PROTEUS_IGN_10; | |||
| 128 | ||||
| 129 | // 5893hz is coprime with the analog sample rate, 500hz, so hopefully we get less aliasing | |||
| 130 | engineConfiguration->idle.solenoidFrequency = 5893; | |||
| 131 | ||||
| 132 | // Test range is 20% to 80% | |||
| 133 | engineConfiguration->tpsMin = 200; | |||
| 134 | engineConfiguration->tpsMax = 800; | |||
| 135 | } | |||
| 136 | #endif // HARDWARE_CI | |||
| 137 |