rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
board_configuration.cpp
Go to the documentation of this file.
1/**
2 * @file boards/proteus/board_configuration.cpp
3 *
4 * @brief Configuration defaults for the Proteus board
5 *
6 * @author Matthew Kennedy, (c) 2019
7 */
8
9#include "pch.h"
10#include "proteus_meta.h"
11#include "board_overrides.h"
12
13static const brain_pin_e injPins[] = {
14 Gpio::PROTEUS_LS_1,
15 Gpio::PROTEUS_LS_2,
16 Gpio::PROTEUS_LS_3,
17 Gpio::PROTEUS_LS_4,
18 Gpio::PROTEUS_LS_5,
19 Gpio::PROTEUS_LS_6,
20 Gpio::PROTEUS_LS_7,
21 Gpio::PROTEUS_LS_8,
22 Gpio::PROTEUS_LS_9,
23 Gpio::PROTEUS_LS_10,
24 Gpio::PROTEUS_LS_11,
25 Gpio::PROTEUS_LS_12
26};
27
28static const brain_pin_e ignPins[] = {
29 Gpio::PROTEUS_IGN_1,
30 Gpio::PROTEUS_IGN_2,
31 Gpio::PROTEUS_IGN_3,
32 Gpio::PROTEUS_IGN_4,
33 Gpio::PROTEUS_IGN_5,
34 Gpio::PROTEUS_IGN_6,
35 Gpio::PROTEUS_IGN_7,
36 Gpio::PROTEUS_IGN_8,
37 Gpio::PROTEUS_IGN_9,
38 Gpio::PROTEUS_IGN_10,
39 Gpio::PROTEUS_IGN_11,
40 Gpio::PROTEUS_IGN_12,
41};
42
43static void setInjectorPins() {
44 copyArray(engineConfiguration->injectionPins, injPins);
45}
46
47static void setIgnitionPins() {
48 copyArray(engineConfiguration->ignitionPins, ignPins);
49}
50
51// PE3 is error LED, configured in board.mk
53 return Gpio::E4;
54}
55
57 return Gpio::E5;
58}
59
61 return Gpio::E6;
62}
63
64static void setupVbatt() {
65 // 5.6k high side/10k low side = 1.56 ratio divider
66 engineConfiguration->analogInputDividerCoefficient = 1.56f;
67
68 // 82k high side/10k low side = 9.2
69 engineConfiguration->vbattDividerCoeff = (92.0f / 10.0f);
70
71 // Battery sense on PA7
72 engineConfiguration->vbattAdcChannel = EFI_ADC_7;
73
74 engineConfiguration->adcVcc = 3.3f;
75}
76
77static void setupEtb() {
78 // TLE9201 driver
79 // This chip has three control pins:
80 // DIR - sets direction of the motor
81 // PWM - pwm control (enable high, coast low)
82 // DIS - disables motor (enable low)
83
84 // Throttle #1
85 // PWM pin
86 engineConfiguration->etbIo[0].controlPin = Gpio::D12;
87 // DIR pin
88 engineConfiguration->etbIo[0].directionPin1 = Gpio::D10;
89 // Disable pin
90 engineConfiguration->etbIo[0].disablePin = Gpio::D11;
91
92 // Throttle #2
93 // PWM pin
94 engineConfiguration->etbIo[1].controlPin = Gpio::D13;
95 // DIR pin
96 engineConfiguration->etbIo[1].directionPin1 = Gpio::D9;
97 // Disable pin
98 engineConfiguration->etbIo[1].disablePin = Gpio::D8;
99
100 // we only have pwm/dir, no dira/dirb
101 engineConfiguration->etb_use_two_wires = false;
102}
103
105 // trigger inputs
106 // Digital channel 1 as default - others not set
107 engineConfiguration->triggerInputPins[0] = PROTEUS_DIGITAL_1;
109
110 engineConfiguration->triggerInputPins[1] = Gpio::Unassigned;
111
112
113 engineConfiguration->clt.adcChannel = PROTEUS_IN_CLT;
114 engineConfiguration->iat.adcChannel = PROTEUS_IN_IAT;
115 engineConfiguration->tps1_1AdcChannel = PROTEUS_IN_TPS;
116 engineConfiguration->map.sensor.hwChannel = PROTEUS_IN_MAP;
117
118 // see also enableAemXSeries
119 // pin #28 WBO AFR "Analog Volt 10"
120 engineConfiguration->afr.hwChannel = PROTEUS_IN_ANALOG_VOLT_10;
121}
122
123static void setupSdCard() {
124 engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3;
125 engineConfiguration->sdCardCsPin = Gpio::D2;
126
127 engineConfiguration->is_enabled_spi_3 = true;
128 engineConfiguration->spi3sckPin = Gpio::C10;
129 engineConfiguration->spi3misoPin = Gpio::C11;
130 engineConfiguration->spi3mosiPin = Gpio::C12;
131
132 engineConfiguration->is_enabled_spi_5 = true;
133 engineConfiguration->spi5sckPin = Gpio::F7;
134 engineConfiguration->spi5misoPin = Gpio::F8;
135 engineConfiguration->spi5mosiPin = Gpio::F9;
136}
137
139 setupSdCard();
140 setupVbatt();
141
142 engineConfiguration->clt.config.bias_resistor = PROTEUS_DEFAULT_AT_PULLUP;
143 engineConfiguration->iat.config.bias_resistor = PROTEUS_DEFAULT_AT_PULLUP;
144
145 engineConfiguration->canTxPin = Gpio::D1;
146 engineConfiguration->canRxPin = Gpio::D0;
147 engineConfiguration->can2RxPin = Gpio::B12;
148 engineConfiguration->can2TxPin = Gpio::B13;
149
150 engineConfiguration->lps25BaroSensorScl = Gpio::B10;
151 engineConfiguration->lps25BaroSensorSda = Gpio::B11;
152}
153
154/**
155 * @brief Board-specific configuration defaults.
156 *
157
158 *
159
160 */
164 setupEtb();
165
166 engineConfiguration->isSdCardEnabled = true;
167
168 // "required" hardware is done - set some reasonable defaults
170
171 engineConfiguration->enableSoftwareKnock = true;
172
173#if HW_PROTEUS & EFI_PROD_CODE
174 engineConfiguration->mainRelayPin = Gpio::PROTEUS_LS_12;
175 engineConfiguration->fanPin = Gpio::PROTEUS_LS_11;
176 engineConfiguration->fuelPumpPin = Gpio::PROTEUS_LS_10;
177#endif // HW_PROTEUS
178
179 // If we're running as hardware CI, borrow a few extra pins for that
180#ifdef HARDWARE_CI
181 engineConfiguration->triggerSimulatorPins[0] = Gpio::G3;
182 engineConfiguration->triggerSimulatorPins[1] = Gpio::G2;
183#endif
184}
185
187 // Wake on the CAN RX pin
188 palEnableLineEvent(PAL_LINE(GPIOD, 0), PAL_EVENT_MODE_RISING_EDGE);
189}
190
191#if HW_PROTEUS
193 Gpio::PROTEUS_LS_1, // inj 1
194 Gpio::PROTEUS_LS_2, // inj 2
195 Gpio::PROTEUS_LS_3, // inj 3
196 Gpio::PROTEUS_LS_4, // inj 4
197};
198
200 Gpio::PROTEUS_LS_14, // inj 1 four times
201 Gpio::PROTEUS_LS_14, // inj 1 four times
202 Gpio::PROTEUS_LS_14, // inj 1 four times
203 Gpio::PROTEUS_LS_14, // inj 1 four times
204
205 Gpio::PROTEUS_LS_15, // inj 4 four times
206 Gpio::PROTEUS_LS_15, // inj 4 four times
207 Gpio::PROTEUS_LS_15, // inj 4 four times
208 Gpio::PROTEUS_LS_15, // inj 4 four times
209
210};
211
213 Gpio::PROTEUS_LS_1, // inj 1
214 Gpio::PROTEUS_LS_2, // inj 2
215 Gpio::PROTEUS_LS_3,
216 Gpio::PROTEUS_LS_4,
217 Gpio::PROTEUS_LS_5,
218 Gpio::PROTEUS_LS_6,
219 Gpio::PROTEUS_LS_7,
220 Gpio::PROTEUS_LS_8,
221 Gpio::PROTEUS_LS_9, // inj 9
222 Gpio::PROTEUS_LS_10, // inj 10
223 Gpio::PROTEUS_LS_11, // inj 11
224 Gpio::PROTEUS_LS_12, // inj 12
225 Gpio::PROTEUS_LS_14, // starter control or aux output
226 Gpio::PROTEUS_LS_15, // radiator fan relay output white
227
228
229 //Gpio::PROTEUS_LS_13, // main relay
230 //Gpio::PROTEUS_LS_16, // main relay
231};
232
234 Gpio::PROTEUS_LS_1, // inj 1
235 Gpio::PROTEUS_LS_2, // inj 2
236 Gpio::PROTEUS_LS_3, // inj 3
237 Gpio::PROTEUS_LS_4, // inj 4
238 Gpio::PROTEUS_LS_12, // main relay
239 Gpio::PROTEUS_LS_14, // starter
240};
241
243 Gpio::PROTEUS_LS_1, // inj 1
244 Gpio::PROTEUS_LS_2, // inj 2
245 Gpio::PROTEUS_LS_3, // inj 3
246 Gpio::PROTEUS_LS_12, // main relay
247 Gpio::PROTEUS_LS_14, // starter
248 Gpio::PROTEUS_LS_15, // intercooler fan
249 Gpio::PROTEUS_LS_4, // accessories relay
250 Gpio::PROTEUS_IGN_1,
251 Gpio::PROTEUS_IGN_2,
252 Gpio::PROTEUS_IGN_3,
253};
254
256 Gpio::PROTEUS_LS_1,
257 Gpio::PROTEUS_LS_2,
258 Gpio::PROTEUS_IGN_1,
259 Gpio::PROTEUS_IGN_2,
260 Gpio::PROTEUS_IGN_8, // ACR
261 Gpio::PROTEUS_IGN_9, // ACR2
262};
263
267 }
270 }
271 if (engineConfiguration->engineType == engine_type_e::HARLEY) {
273 }
274 if (engineConfiguration->engineType == engine_type_e::GM_SBC) {
276 }
279 }
280 return 16;
281}
282
284Gpio::PROTEUS_LS_1,
285Gpio::PROTEUS_LS_2,
286Gpio::PROTEUS_LS_3,
287Gpio::PROTEUS_LS_4,
288Gpio::PROTEUS_LS_5,
289Gpio::PROTEUS_LS_6,
290Gpio::PROTEUS_LS_7,
291Gpio::PROTEUS_LS_8,
292Gpio::PROTEUS_LS_9,
293Gpio::PROTEUS_LS_10,
294Gpio::PROTEUS_LS_11,
295Gpio::PROTEUS_LS_12,
296Gpio::PROTEUS_LS_13,
297Gpio::PROTEUS_LS_14,
298Gpio::PROTEUS_LS_15,
299Gpio::PROTEUS_LS_16,
300 Gpio::PROTEUS_IGN_1,
301 Gpio::PROTEUS_IGN_2,
302 Gpio::PROTEUS_IGN_3,
303 Gpio::PROTEUS_IGN_4,
304 Gpio::PROTEUS_IGN_5,
305 Gpio::PROTEUS_IGN_6,
306 Gpio::PROTEUS_IGN_7,
307 Gpio::PROTEUS_IGN_8,
308 Gpio::PROTEUS_IGN_9,
309 Gpio::PROTEUS_IGN_10,
310 Gpio::PROTEUS_IGN_11,
311 Gpio::PROTEUS_IGN_12,
312 Gpio::PROTEUS_HS_1,
313 Gpio::PROTEUS_HS_2,
314 Gpio::PROTEUS_HS_3,
315 Gpio::PROTEUS_HS_4
316};
317
320 return efi::size(PROTEUS_SUBARU_OUTPUTS);
321 }
323 return efi::size(PROTEUS_CANAM_OUTPUTS);
324 }
326 return efi::size(PROTEUS_SLINGSHOT_OUTPUTS);
327 }
328 if (engineConfiguration->engineType == engine_type_e::HARLEY) {
329 return efi::size(PROTEUS_HARLEY_OUTPUTS);
330 }
331 if (engineConfiguration->engineType == engine_type_e::GM_SBC) {
332 return efi::size(PROTEUS_SBC_OUTPUTS);
333 }
335 return efi::size(PROTEUS_M73_OUTPUTS);
336 }
337 return efi::size(PROTEUS_OUTPUTS);
338}
339
342 return 2;
343 }
348 ) {
349 return 1;
350 }
351 return 1;
352/* return 2; proteus has two h-b ridges but stim board is short on channels to test :( */
353}
354
358 }
361 }
364 }
365 if (engineConfiguration->engineType == engine_type_e::HARLEY) {
367 }
368 if (engineConfiguration->engineType == engine_type_e::GM_SBC) {
369 return PROTEUS_SBC_OUTPUTS;
370 }
372 return PROTEUS_M73_OUTPUTS;
373 }
374 return PROTEUS_OUTPUTS;
375}
376#endif // HW_PROTEUS
377
Gpio getWarningLedPin()
Gpio getCommsLedPin()
Gpio getRunningLedPin()
void setup_custom_board_overrides()
@ Unassigned
std::optional< setup_custom_board_overrides_type > custom_board_ConfigOverrides
std::optional< setup_custom_board_overrides_type > custom_board_DefaultConfiguration
static constexpr engine_configuration_s * engineConfiguration
static void setupDefaultSensorInputs()
static void setIgnitionPins()
void boardPrepareForStop()
int getBoardMetaOutputsCount()
Gpio * getBoardMetaOutputs()
static void setInjectorPins()
int getBoardMetaLowSideOutputsCount()
int getBoardMetaDcOutputsCount()
static void setupEtb()
static void setupVbatt()
static Gpio PROTEUS_M73_OUTPUTS[]
static Gpio PROTEUS_SUBARU_OUTPUTS[]
static const brain_pin_e ignPins[]
static Gpio PROTEUS_CANAM_OUTPUTS[]
static void proteus_boardConfigOverrides()
static void setupSdCard()
static Gpio PROTEUS_HARLEY_OUTPUTS[]
static void proteus_boardDefaultConfiguration()
Board-specific configuration defaults.
static Gpio PROTEUS_OUTPUTS[]
static Gpio PROTEUS_SBC_OUTPUTS[]
static const brain_pin_e injPins[]
static Gpio PROTEUS_SLINGSHOT_OUTPUTS[]