GCC Code Coverage Report


Directory: ./
File: firmware/config/engines/bmw_m73.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 40 0 40
Functions: 100.0% 3 0 3
Branches: -% 0 0 0
Decisions: -% 0 - 0

Line Branch Decision Exec Source
1 /*
2 * @file bmw_m73.cpp
3 *
4 * https://github.com/rusefi/rusefi/wiki/BMW_e38_750
5 *
6 * https://rusefi.com/wiki/index.php?title=Hardware:OEM_connectors#134_pin
7 * https://github.com/rusefi/rusefi/wiki/HOWTO_electronic_throttle_body
8 * Ignition module https://rusefi.com/forum/viewtopic.php?f=4&t=286
9 *
10 *
11 * 1/2 plugs black
12 * 2/2 plugs grey
13 *
14 *
15 * ********* | | OEM | rusEfi | function
16 *
17 * Plug #1 9 pin
18 * ECU pin 4: GND BRN/ORG
19 * ECU pin 6: GND BRN
20 * ECU pin 7: IN RED +12v hot at all times
21 * ECU pin 8: IN RED/BLU +12v from ECU relay
22 *
23 * Plug #2 24 pin
24 * ECU pin 3: CAN xxx/xxx CAN low
25 * ECU pin 4: CAN xxx/xxx CAN high
26 * ECU pin 23: OUT BRN/BLK BLK ECU relay control, low-side
27 *
28 * Plug #3 52 pin
29 * ECU pin 2: OUT WHT injector #4
30 * ECU pin 6: GND ECU
31 * ECU pin 15: OUT BLK injector #2
32 * ECU pin 20: IN WHT hall effect camshaft sensor signal
33 * ECU pin 21: GND BRN BLK CLT sensor (only on first ECU)
34 * ECU pin 22: IN RED/BRN GRN CLT sensor (only on first ECU)
35 * ECU pin 27: OUT ORG injector #6
36 * ECU pin 28: OUT RED injector #5
37 * ECU pin 32: IN ORG VR positive crankshaft sensor - only 2x 5k per channel, R111 not installed, W1002 not installed
38 * ECU pin 34: IN IAT sensor (only on second ECU)
39 * ECU pin 36: IN Knock Sensor #2
40 * ECU pin 37: GND Knock Sensor GND
41 * ECU pin 40: OUT BRN/BLK GRN injector #3
42 * ECU pin 41: OUT BRN/WHT BLU injector #1
43 * ECU pin 45: GND crankshaft shield
44 * ECU pin 46: IN BLK BLU VR negative crankshaft sensor
45 * ECU pin 47: GND BRN BLK IAT sensor Ground (only on second ECU)
46 * ECU pin 49: IN Knock Sensor #1
47 * ECU pin 50: GND Knock Sensor GND
48 *
49 * Plug #4 40 pin
50 * ECU pin 6: IN start signal from ignition key
51 * ECU pin 17: OUT BLK engine speed output for gauge cluster
52 * ECU pin 26: IN GRN/BLK RED +12v hot in start & run
53 * ECU pin 40: OUT YEL/BRN BRN starter enable
54 *
55 *
56 * Plug #5 9 pin
57 * ECU pin 3: OUT BLK coil signal, low-side
58 * ECU pin 5: GND BRN ground
59 * ECU pin 6: OUT BLK coil signal, low-side
60 * ECU pin 9: OUT BLK RED coil signal, low-side
61 *
62 * Frankenso
63 * set engine_type 40
64 * Manhattan
65 * set engine_type 24
66 * Proteus
67 * set engine_type 63
68 *
69 * https://raw.githubusercontent.com/wiki/rusefi/rusefi_documentation/oem_docs/VAG/Bosch_0280750009_pinout.jpg
70 *
71 * @date Nov 1, 2019
72 * @author Andrey Belomutskiy, (c) 2012-2020
73 */
74
75 #include "pch.h"
76
77 #include "bmw_m73.h"
78 #include "custom_engine.h"
79
80 #if EFI_ELECTRONIC_THROTTLE_BODY
81 #include "electronic_throttle.h"
82 #endif // EFI_ELECTRONIC_THROTTLE_BODY
83
84 #if HW_PROTEUS
85 #include "proteus_meta.h"
86 #endif // HW_PROTEUS
87
88 2 void m73engine() {
89 // 13641435991 injector
90 2 engineConfiguration->injector.flow = 180; // cc/min, who knows if this number is real - no good source of info
91
92 2 engineConfiguration->cylindersCount = 12;
93 2 engineConfiguration->displacement = 5.4;
94 2 strcpy(engineConfiguration->engineMake, ENGINE_MAKE_BMW);
95 2 strcpy(engineConfiguration->engineCode, "M73");
96 2 engineConfiguration->firingOrder = FO_1_7_5_11_3_9_6_12_2_8_4_10;
97 2 engineConfiguration->fuelAlgorithm = engine_load_mode_e::LM_ALPHA_N;
98 2 engineConfiguration->canNbcType = CAN_BUS_NBC_NONE;
99
100 2 engineConfiguration->vvtMode[0] = VVT_SINGLE_TOOTH;
101
102 2 engineConfiguration->globalTriggerAngleOffset = 90;
103 2 setCrankOperationMode();
104 2 engineConfiguration->trigger.type = trigger_type_e::TT_TOOTHED_WHEEL_60_2;
105
106 // this large engine seems to crank at around only 150 RPM? And happily idle at 400RPM?
107 2 engineConfiguration->cranking.rpm = 350;
108
109 2 engineConfiguration->ignitionMode = IM_TWO_COILS;
110
111 // set cranking_fuel x
112 2 setTable(config->crankingCycleBaseFuel, 27);
113
114 2 engineConfiguration->crankingTimingAngle = 15;
115 2 setTable(config->veTable, 45);
116
117 2 engineConfiguration->cylinderBore = 85.0;
118 2 }
119
120
121 // BMW_M73_F
122 1 void setBMW_M73_TwoCoilUnitTest() {
123 1 engineConfiguration->camInputs[0] = Gpio::A0; // a random unused pin needed for happy HW CI
124 // twoCoil configuration without unit tests ETB setup drama
125 1 m73engine();
126 1 }
127
128 /**
129 * set engine_type 63
130 *
131 * https://github.com/mck1117/proteus/blob/master/readme_pinout.md
132 *
133 * black#3 : orange : injector #1
134 * black#4 : blue : injector #3
135 * black#5 : white : injector #5
136 * black#6 : green : injector #6
137 * black#7 : orange : injector #7
138 * black#8 : blue : injector #9
139 * black#9 : white : injector #11
140 * black#15: blue : injector #2
141 * black#16: white : injector #4
142 * black#19: green : injector #8
143 * black#20: : injector #10
144 * black#21: : injector #12
145 *
146 *
147 * small#5 : : VR1 pos
148 * small#8 : blue : ETB1-
149 * small#13: blue : VR1 neg
150 * small#15: orange : ETB1+
151 * small#18: red : ignition power / ECU power source
152 * small#19: black : GND
153 * small#21: blue : ETB2-
154 * small#22: orange : ETB2+
155 * small#23: red : ETB/high-side power from main relay
156 *
157 *
158 *
159 * white#9 : orange : +5v
160 * white#17: green : PPS
161 * white#18: red : TPS#2
162 * white#23: black : Sensor Ground
163 * white#24: red : TPS#1
164 *
165 */
166 #if HW_PROTEUS
167 1 void setEngineBMW_M73_Proteus() {
168 1 m73engine();
169
170 // 12 injectors defined in boards/proteus/board_configuration.cpp
171
172
173 1 strcpy(engineConfiguration->vehicleName, "Using Proteus");
174
175 1 engineConfiguration->triggerInputPins[0] = PROTEUS_VR_1;
176
177 1 engineConfiguration->camInputs[0] = PROTEUS_DIGITAL_2;
178
179 // no idea why https://github.com/rusefi/rusefi/wiki/HOWTO-M73-v12-on-Proteus uses non default CLT pin
180 // engineConfiguration->clt.adcChannel = PROTEUS_IN_ANALOG_TEMP_4;
181 // newer https://github.com/rusefi/rusefi/wiki/HOWTO-custom-harness-lazyharnezz-M73 uses default pin
182
183
184 1 engineConfiguration->starterControlPin = Gpio::PROTEUS_LS_14;
185 1 engineConfiguration->startStopButtonPin = PROTEUS_DIGITAL_3;
186 1 engineConfiguration->startStopButtonMode = PI_PULLUP;
187 1 engineConfiguration->fuelPumpPin = Gpio::PROTEUS_LS_16;
188 1 engineConfiguration->fanPin = Gpio::PROTEUS_LS_15;
189 1 engineConfiguration->mainRelayPin = Gpio::PROTEUS_LS_13;
190
191 1 engineConfiguration->map.sensor.hwChannel = PROTEUS_IN_ANALOG_VOLT_8; // M73 adapter board
192 1 engineConfiguration->map.sensor.type = MT_MPX4250A;
193
194 // tps and pps
195 #if EFI_ELECTRONIC_THROTTLE_BODY
196 1 setProteusHitachiEtbDefaults();
197 #endif // EFI_ELECTRONIC_THROTTLE_BODY
198 1 setPPSCalibration(0.73, 4.0, 0.34, 1.86);
199 1 }
200 #endif // HW_PROTEUS
201