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/hellen/hellen-nb1/board_configuration.cpp
3 *
4 *
5 * @brief Configuration defaults for the 8chan board
6 *
7 * @author andreika <prometheus.pcb@gmail.com>
8 * @author Andrey Belomutskiy, (c) 2012-2020
9 */
10
11#include "pch.h"
12#include "hellen_meta.h"
13#include "defaults.h"
14#include "board_overrides.h"
15
17
25
37
38static void setIgnitionPins() {
39 engineConfiguration->ignitionPins[0] = Gpio::MM176_IGN1;
40 engineConfiguration->ignitionPins[1] = Gpio::MM176_IGN2;
41 engineConfiguration->ignitionPins[2] = Gpio::MM176_IGN3;
42 engineConfiguration->ignitionPins[3] = Gpio::MM176_IGN4;
43}
44
46 // trigger inputs, VR/hall crank
47 engineConfiguration->triggerInputPins[0] = Gpio::MM176_USB1ID; // 1B
48// engineConfiguration->triggerInputPins[1] = Gpio::H144_IN_CAM;
49 engineConfiguration->camInputs[0] = Gpio::MM176_IN_D1; // 15A
50 engineConfiguration->camInputs[1] = Gpio::MM176_IN_D2;
51 engineConfiguration->camInputs[2] = Gpio::MM176_IN_D3; // 24A
52 engineConfiguration->camInputs[3] = Gpio::MM176_IN_D4; // 9A
53 engineConfiguration->vvtMode[0] = VVT_SINGLE_TOOTH;
54 engineConfiguration->vvtMode[1] = VVT_SINGLE_TOOTH;
55
56 setTPS1Inputs(MM176_IN_TPS_ANALOG, MM176_IN_TPS2_ANALOG);
57
58 setPPSInputs(MM176_IN_PPS1_ANALOG, MM176_IN_PPS2_ANALOG);
59
60 // random values to have valid config
63
64
65// engineConfiguration->map.sensor.hwChannel = H144_IN_MAP2;
66 engineConfiguration->baroSensor.type = MT_MPXH6400;
67// engineConfiguration->baroSensor.hwChannel = H144_IN_MAP3;
68
69 engineConfiguration->afr.hwChannel = EFI_ADC_NONE;
70
71 engineConfiguration->clt.adcChannel = MM176_IN_CLT_ANALOG;
72
73 engineConfiguration->iat.adcChannel = MM176_IN_IAT_ANALOG;
74}
75
77 // technically same thing as setHellenMegaEnPin() since underlying pin E10 is same as H144_GP8
78 setHellenEnPin(Gpio::MM176_EN_PIN);
79
80 alphaCrankPPullUp.initPin("Crank-PullUp", Gpio::MM176_GP16);
81 alphaHall1PullDown.initPin("PullDown-Hall1", Gpio::MM176_OUT_IO10);
82 alphaHall2PullDown.initPin("PullDown-Hall2", Gpio::MM176_GP21);
83 alphaHall3PullDown.initPin("PullDown-Hall3", Gpio::MM176_GP22);
84 alphaHall4PullDown.initPin("PullDown-Hall4", Gpio::MM176_GP23);
85 alphaHall5PullDown.initPin("PullDown-Hall5", Gpio::MM176_GP24);
86 alphaFlexPullDown.initPin("PullDown-Flex", Gpio::MM176_GP25);
87 tempPullUp.initPin("Temp PullUp", Gpio::MM176_OUT_IO12);
88}
89
100
106
107/**
108 * @brief Board-specific configuration defaults.
109 *
110 * See also setDefaultEngineConfiguration
111 *
112 */
116 setupTLE9201(/*controlPin*/Gpio::MM176_OUT_PWM9, Gpio::MM176_GP6, Gpio::MM176_GP7);
117 setupTLE9201(/*controlPin*/Gpio::MM176_OUT_PWM18, Gpio::MM176_GP10, Gpio::MM176_GP11, 1);
118// engineConfiguration->vvtPins[0] = Gpio::H144_OUT_PWM7;
119// engineConfiguration->vvtPins[1] = Gpio::H144_OUT_PWM8;
120
122
124
125 engineConfiguration->mainRelayPin = Gpio::MM176_GP1;
126// engineConfiguration->fanPin = Gpio::H144_OUT_IO11;
127// engineConfiguration->fuelPumpPin = Gpio::H144_OUT_IO12;
128// engineConfiguration->tachOutputPin = Gpio::H144_OUT_IO13;
129
130 // "required" hardware is done - set some reasonable defaults
133
135 engineConfiguration->firingOrder = FO_1_3_4_2;
136
137 engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK
138
139 engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH;
140
141 engineConfiguration->vrThreshold[0].pin = Gpio::MM176_OUT_PWM11;
142 engineConfiguration->vrThreshold[1].pin = Gpio::MM176_OUT_PWM12;
143 //engineConfiguration->vrThreshold[2].pin = Gpio::MM176_OUT_PWM13;
144
145 hellenWbo();
146}
147
149 // Wake on the CAN RX pin
150 palEnableLineEvent(PAL_LINE(GPIOD, 0), PAL_EVENT_MODE_RISING_EDGE);
151}
152
154 Gpio::MM176_INJ1, // 1D - Injector 1
155 Gpio::MM176_INJ2, // 2D - Injector 2
156 Gpio::MM176_INJ3, // 3D - Injector 3
157 Gpio::MM176_INJ4, // 4D - Injector 4
158
159 Gpio::MM176_INJ5, // 5D - Injector 5
160 Gpio::MM176_INJ6, // 6D - Injector 6
161 Gpio::MM176_INJ7, // 7D - Injector 7
162 Gpio::MM176_INJ8, // 13D - Injector 8
163
164 Gpio::MM176_GP1, // 11D - Main Relay
165 Gpio::MM176_GP2, // 10D - Fan
166// Gpio::MM176_OUT_PWM1, // 8D - VVT 1
167};
168
169static Gpio OUTPUTS[] = {
170 Gpio::MM176_INJ1, // 1D - Injector 1
171 Gpio::MM176_INJ2, // 2D - Injector 2
172 Gpio::MM176_INJ3, // 3D - Injector 3
173 Gpio::MM176_INJ4, // 4D - Injector 4
174 Gpio::MM176_INJ5, // 5D - Injector 5
175
176 Gpio::MM176_INJ6, // 6D - Injector 6
177 Gpio::MM176_INJ7, // 7D - Injector 7
178 Gpio::MM176_OUT_PWM1, // 8D - VVT 1
179 Gpio::MM176_GP3, // 9D - Fuel Pump
180 Gpio::MM176_GP2, // 10D - Fan
181
182 Gpio::MM176_GP1, // 11D - Main Relay
183 Gpio::MM176_OUT_IO8, // 12D - NOS
184 Gpio::MM176_INJ8, // 13D - Injector 8
185 Gpio::MM176_OUT_PWM2, // 14D - VVT 2
186 Gpio::MM176_OUT_IO13, // 15D - Tachometer
187
188 Gpio::MM176_OUT_PWM6, // 16C - Low Side 1
189 Gpio::MM176_GP17, // 19D - Injector 9
190 Gpio::MM176_OUT_PWM3, // 20D - VVT 3
191 Gpio::MM176_OUT_PWM4, // 21D - VVT 4
192 Gpio::MM176_OUT_PWM5, // 22C - Boost
193
194 Gpio::MM176_OUT_PWM7, // 23C - Low Side 2
195 Gpio::MM176_GP20, // 24D - Injector 12
196 Gpio::MM176_GP19, // 25D - Injector 11
197 Gpio::MM176_GP18, // 26D - Injector 10
198 Gpio::MM176_OUT_IO3, // 8C - Low Side 3
199
200 Gpio::MM176_OUT_IO4, // 9C - Low Side 4
201 Gpio::MM176_OUT_IO5, // 17C - Low Side 5
202 Gpio::MM176_OUT_IO6, // 25C - Low Side 6
203 Gpio::MM176_OUT_IO7, // 34C - Low Side 7
204 Gpio::MM176_OUT_PWM8, // 5C - High Side 1
205
206 Gpio::MM176_OUT_IO2, // 6C - High Side 2
207 Gpio::MM176_OUT_IO1, // 7C - High Side 3
208 Gpio::MM176_IGN1, // 11C - Ignition 1
209 Gpio::MM176_IGN3, // 13C - Ignition 3
210 Gpio::MM176_IGN5, // 14C - Ignition 5
211
212// Gpio::MM176_IGN8, // 15C - Ignition 8
213//
214// Gpio::MM176_IGN2, // 19C - Ignition 2
215// Gpio::MM176_IGN4, // 20C - Ignition 4
216// Gpio::MM176_IGN7, // 21C - Ignition 7
217// Gpio::MM176_SPI3_MISO, // 23C - Ignition 10
218//
219// Gpio::MM176_IGN6, // 28C - Ignition 6
220// Gpio::MM176_SPI3_SCK, // 29C - Ignition 9
221// Gpio::MM176_SPI3_MOSI, // 30C - Ignition 11
222// Gpio::MM176_SPI3_CS, // 31C - Ignition 12
223
224
225};
226
229 return efi::size(OUTPUTS_GM_GEN4);
230 }
231 return efi::size(OUTPUTS);
232}
233
240
247
250 // STATIC_BOARD_ID_PLATINUM_GM_GEN4
251 return 1;
252 }
253 return 2;
254}
255
261
262int boardGetAnalogInputDiagnostic(adc_channel_e hwChannel, float voltage) {
263 /* we do not check voltage for valid ragne yet */
264 (void)voltage;
265
266 switch (hwChannel) {
267 /* inputs that may be affected by incorrect reference voltage */
268 case MM176_IN_TPS_ANALOG:
269 case MM176_IN_TPS2_ANALOG:
270 case MM176_IN_PPS1_ANALOG:
271 case MM176_IN_PPS2_ANALOG:
272 case MM176_IN_IAT_ANALOG:
273 case MM176_IN_AT1_ANALOG:
274 case MM176_IN_CLT_ANALOG:
275 case MM176_IN_AT2_ANALOG:
276 //case MM176_IN_O2S_ANALOG:
277 //case MM176_IN_O2S2_ANALOG:
278 case MM176_IN_MAP1_ANALOG:
279 case MM176_IN_MAP2_ANALOG:
280 case MM176_IN_AUX1_ANALOG:
281 case MM176_IN_AUX2_ANALOG:
282 case MM176_IN_AUX3_ANALOG:
283 case MM176_IN_AUX4_ANALOG:
284 /* TODO: more? */
285 return (boardGetAnalogDiagnostic() == ObdCode::None) ? 0 : -1;
286 /* all other inputs should not rely on output 5V */
287 default:
288 return 0;
289 }
290
291 return 0;
292}
void setup_custom_board_overrides()
std::optional< setup_custom_board_overrides_type > custom_board_InitHardware
Definition hardware.cpp:77
Single output pin reference and state.
Definition efi_output.h:49
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError=false)
Definition efi_gpio.cpp:711
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition efi_gpio.cpp:604
@ Unassigned
void setPPSInputs(adc_channel_e pps1, adc_channel_e pps2)
void setTPS1Inputs(adc_channel_e tps1, adc_channel_e tps2)
void setupTLE9201(Gpio controlPin, Gpio direction, Gpio disable, int dcIndex)
std::optional< setup_custom_board_overrides_type > custom_board_ConfigOverrides
std::optional< setup_custom_board_overrides_type > custom_board_DefaultConfiguration
static constexpr persistent_config_s * config
static constexpr engine_configuration_s * engineConfiguration
static OutputPin alphaCrankPPullUp
static void setupDefaultSensorInputs()
static Gpio OUTPUTS[]
static void setIgnitionPins()
void boardPrepareForStop()
void boardOnConfigurationChange(engine_configuration_s *)
int getBoardMetaOutputsCount()
Gpio * getBoardMetaOutputs()
static void setInjectorPins()
int getBoardMetaLowSideOutputsCount()
static OutputPin tempPullUp
int getBoardMetaDcOutputsCount()
static OutputPin alphaHall2PullDown
static OutputPin alphaHall5PullDown
static void alphax_8chan_defaultConfiguration()
Board-specific configuration defaults.
static OutputPin alphaHall3PullDown
int boardGetAnalogInputDiagnostic(adc_channel_e hwChannel, float voltage)
static OutputPin alphaFlexPullDown
static void alphax_8chan_boardInitHardware()
static OutputPin alphaHall1PullDown
static OutputPin alphaHall4PullDown
static Gpio OUTPUTS_GM_GEN4[]
static void alphax_8chan_boardConfigOverrides()
ObdCode boardGetAnalogDiagnostic()
void setHellenCan()
void hellenMegaModule()
void hellenWbo()
void setHellenEnPin(Gpio pin, bool enableBoardOnStartUp)
void setHellenCan2()
void setHellenMMbaro()
brain_input_pin_e triggerInputPins[TRIGGER_INPUT_PIN_COUNT]