rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
board_configuration.cpp
Go to the documentation of this file.
1/**
2 * @file board_configuration.cpp
3 *
4 *
5 * @brief Configuration defaults for the 4chan 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
27
39
40static void setIgnitionPins() {
41 engineConfiguration->ignitionPins[0] = Gpio::H144_IGN_1;
42 engineConfiguration->ignitionPins[1] = Gpio::H144_IGN_2;
43 engineConfiguration->ignitionPins[2] = Gpio::H144_IGN_3;
44 engineConfiguration->ignitionPins[3] = Gpio::H144_IGN_4;
45}
46
48 // trigger inputs, hall
49 engineConfiguration->triggerInputPins[0] = Gpio::H144_IN_CRANK;
50// engineConfiguration->triggerInputPins[1] = Gpio::H144_IN_CAM;
52
53 setTPS1Inputs(H144_IN_TPS, H144_IN_AUX1_ANALOG);
54
55 setPPSInputs(H144_IN_PPS, H144_IN_AUX2_ANALOG);
56
57 // random values to have valid config
60
61
62
64
65 engineConfiguration->clt.adcChannel = H144_IN_CLT;
66
67 engineConfiguration->iat.adcChannel = H144_IN_IAT;
68}
69
70static bool is_F_OrOlder() {
71#ifdef STM32F7XX
72 // only new mega module boards were fabricated with F7
73 return false;
74#else
76 return hellenBoardId == BOARD_ID_ALPHA4CH_B || hellenBoardId == BOARD_ID_ALPHA4CH_D || hellenBoardId == BOARD_ID_ALPHA4CH_E || hellenBoardId == BOARD_ID_ALPHA4CH_F;
77#endif
78}
79
81 alphaTachPullUp.initPin("a-tach", Gpio::H144_OUT_IO1);
82 alphaTempPullUp.initPin("a-temp", Gpio::H144_OUT_IO4);
83 alphaCrankPPullUp.initPin("a-crank-p", Gpio::H144_OUT_IO2);
84 alphaCrankNPullUp.initPin("a-crank-n", Gpio::H144_OUT_IO5);
85 alpha2stepPullDown.initPin("a-2step", Gpio::H144_OUT_IO7);
86 alphaCamVrPullUp.initPin("a-cam-vr", Gpio::H144_OUT_IO9);
87 if (is_F_OrOlder()) {
88 alphaD2PullDown.initPin("a-d2-legacy", Gpio::H144_LS_5);
89 alphaCamPullDown.initPin("a-cam-legacy", Gpio::H144_OUT_IO8);
90 alphaD3PullDown.initPin("a-d3-legacy", Gpio::H144_LS_6);
91 } else {
92 alphaD2PullDown.initPin("a_d2", Gpio::H144_OUT_IO13);
93 alphaCamPullDown.initPin("a_cam", Gpio::H144_GP_IO4);
94 alphaD3PullDown.initPin("a_d3", Gpio::H144_OUT_IO8);
95 }
96
97 alphaD4PullDown.initPin("a-d4", Gpio::H144_LS_7);
98 alphaD5PullDown.initPin("a-d5", Gpio::H144_LS_8);
99}
100
115
116
117
120
121 if (is_F_OrOlder()) {
122 setHellenEnPin(Gpio::H144_OUT_IO3);
124 } else {
126 // rev G and newer uses hellen mega-module
128 }
129
131
132 setHellenCan();
133}
134
135/**
136 * @brief Board-specific configuration defaults.
137 *
138 * See also setDefaultEngineConfiguration
139 *
140
141 */
145 setupTLE9201(/*controlPin*/Gpio::H144_OUT_PWM2, /*directionPin1*/Gpio::H144_GP_IO1, /*disablePin*/Gpio::H144_GP_IO2);
146 if (is_F_OrOlder()) {
147 engineConfiguration->tachOutputPin = Gpio::H144_OUT_IO13;
148 engineConfiguration->vvtPins[0] = Gpio::H144_OUT_PWM7;
149 engineConfiguration->vvtPins[1] = Gpio::H144_OUT_PWM8;
150 } else {
151 engineConfiguration->vvtPins[0] = Gpio::H144_IGN_7;
152 engineConfiguration->vvtPins[1] = Gpio::H144_IGN_8;
153 engineConfiguration->tachOutputPin = Gpio::H144_GP_IO3;
154 }
155
156
157 // todo: should be conditional? currently set best for newest boards based on MegaModule
159 engineConfiguration->map.sensor.hwChannel = H144_IN_MAP3; // On-board MAP
160 engineConfiguration->map.sensor.type = MT_MPXH6400;
161 // engineConfiguration->baroSensor.type = MT_MPXH6400;
162 // engineConfiguration->baroSensor.hwChannel = H144_IN_MAP3; // On-board MAP
163
165
167 engineConfiguration->fuelPumpPin = Gpio::H144_OUT_IO12;
168 engineConfiguration->fanPin = Gpio::H144_OUT_IO11;
169 engineConfiguration->mainRelayPin = Gpio::H144_OUT_IO10;
170 engineConfiguration->boostControlPin = Gpio::H144_OUT_PWM3;
171
172 // "required" hardware is done - set some reasonable defaults
174
176 engineConfiguration->firingOrder = FO_1_3_4_2;
177
178 engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK
179
180
181
182 engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH;
183// ? engineConfiguration->malfunctionIndicatorPin = Gpio::G4; //1E - Check Engine Light
184 engineConfiguration->vrThreshold[0].pin = Gpio::H144_OUT_PWM6;
185 engineConfiguration->vrThreshold[1].pin = Gpio::H144_OUT_PWM4;
187}
188
190 // Wake on the CAN RX pin
191 palEnableLineEvent(PAL_LINE(GPIOD, 0), PAL_EVENT_MODE_RISING_EDGE);
192}
193
194static Gpio OUTPUTS[] = {
195 Gpio::H144_LS_1, // A8 - Injector 1
196 Gpio::H144_LS_2, // B8 - Injector 2
197 Gpio::H144_LS_3, // D1 - Injector 3
198 Gpio::H144_LS_4, // E1 - Injector 4
199 Gpio::H144_IGN_7, // F2 - VVT#1 rev G
200 Gpio::H144_IGN_8, // F4 - VVT#2 rev G
201 Gpio::H144_OUT_PWM5, // F1 - Idle2
202 Gpio::H144_OUT_PWM1, // C8 - Idle
203};
204
206 return efi::size(OUTPUTS);
207}
208
210 return OUTPUTS;
211}
212
214 return 1;
215}
216
void setup_custom_board_overrides()
std::optional< setup_custom_board_overrides_type > custom_board_InitHardware
Definition hardware.cpp:77
EngineState engineState
Definition engine.h:344
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)
static EngineAccessor engine
Definition engine.h:413
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 alphaCamPullDown
static OutputPin alphaTachPullUp
static OutputPin alphaCrankPPullUp
static void setupDefaultSensorInputs()
static Gpio OUTPUTS[]
static void setIgnitionPins()
static OutputPin alphaTempPullUp
void boardPrepareForStop()
void boardOnConfigurationChange(engine_configuration_s *)
static OutputPin alpha2stepPullDown
int getBoardMetaOutputsCount()
static OutputPin alphaCrankNPullUp
Gpio * getBoardMetaOutputs()
static void setInjectorPins()
static void alphax_4chan_defaultConfiguration()
Board-specific configuration defaults.
static void alphax_4chan_boardInitHardware()
static OutputPin alphaD5PullDown
static OutputPin alphaD2PullDown
int getBoardMetaDcOutputsCount()
static OutputPin alphaD3PullDown
static OutputPin alphaCamVrPullUp
static OutputPin alphaD4PullDown
static void alphax_4chan_ConfigOverrides()
static bool is_F_OrOlder()
void hellenMegaSdWithAccelerometer()
void setHellenCan()
void setHellenVbatt()
void setHellenEnPin(Gpio pin, bool enableBoardOnStartUp)
void setHellenMegaEnPin(bool enableBoardOnStartUp)
static void setAccelerometerSpi()
void setHellenMMbaro()
void setHellenSdCardSpi2()
void setDefaultHellenAtPullUps(float pullup=HELLEN_DEFAULT_AT_PULLUP)
hellenBoardId("Detected Board ID", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 1368, 1.0, 0.0, 3000.0, "id")
brain_input_pin_e triggerInputPins[TRIGGER_INPUT_PIN_COUNT]