rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
board_configuration.cpp
Go to the documentation of this file.
1#include "pch.h"
2#include "hellen_meta.h"
3#include "defaults.h"
4#include "hellen_leds_100.cpp"
5#include "smart_gpio.h"
7#include "pca_board_id.h" // bb i2c board id, works via __weak__ magic
8#include "board_overrides.h"
9
15
22
23static void setIgnitionPins() {
24 engineConfiguration->ignitionPins[0] = Gpio::MM100_IGN1;
25 engineConfiguration->ignitionPins[1] = Gpio::MM100_IGN2;
26 engineConfiguration->ignitionPins[2] = Gpio::MM100_IGN3;
27 engineConfiguration->ignitionPins[3] = Gpio::MM100_IGN4;
28}
29
31 engineConfiguration->tps1_1AdcChannel = MM100_IN_TPS_ANALOG;
32
34
35// engineConfiguration->map.sensor.hwChannel = H144_IN_MAP1; // external MAP
36 engineConfiguration->map.sensor.hwChannel = H144_IN_MAP2; // On-board MAP
37 engineConfiguration->map.sensor.type = MT_MPXH6400;
38
39 engineConfiguration->clt.adcChannel = MM100_IN_CLT_ANALOG;
40 engineConfiguration->iat.adcChannel = MM100_IN_IAT_ANALOG;
41}
42
44 /* Force PWR_EN as TLE9104s are powered from +5VA */
46
49
50 /* Two TLE9104 */
52 engineConfiguration->vrThreshold[0].pin = Gpio::MM100_OUT_PWM2;
53}
54
62
63/*
64 * RESET and EN signals of both TLE9104 are driven by same gpios,
65 * Do not allow TLE driver to drive this pins as it will reset
66 * first chip while initing second.
67 * Set pins to proper once.
68 * TODO: improve?
69 */
70static const tle9104_config tle9104_cfg[BOARD_TLE9104_COUNT] = {
71 {
72 .spi_bus = &SPID3,
73 .spi_config = {
74 .circular = false,
75#ifdef _CHIBIOS_RT_CONF_VER_6_1_
76 .end_cb = nullptr,
77#else
78 .slave = false,
79 .data_cb = nullptr,
80 .error_cb = nullptr,
81#endif
82 // 9104_CSN_INJ
83 .ssport = GPIOA,
84 .sspad = 15,
85 .cr1 =
86 SPI_CR1_16BIT_MODE |
87 SPI_CR1_SSM |
88 SPI_CR1_SSI |
89 ((3 << SPI_CR1_BR_Pos) & SPI_CR1_BR) | // div = 16
90 SPI_CR1_MSTR |
91 SPI_CR1_CPHA |
92 0,
93 .cr2 = SPI_CR2_16BIT_MODE
94 },
95 .direct_io = {
96 { .port = GPIOD, .pad = 3 }, // INJ1
97 { .port = GPIOD, .pad = 11 }, // INJ3
98 { .port = GPIOA, .pad = 9 }, // INJ2
99 { .port = GPIOD, .pad = 10 } // INJ4
100 },
101 .resn = Gpio::Unassigned, //Gpio::B14,
102 .en = Gpio::Unassigned //Gpio::B15
103 },
104 {
105 .spi_bus = &SPID3,
106 .spi_config = {
107 .circular = false,
108#ifdef _CHIBIOS_RT_CONF_VER_6_1_
109 .end_cb = nullptr,
110#else
111 .slave = false,
112 .data_cb = nullptr,
113 .error_cb = nullptr,
114#endif
115 // 9104_CSN_LS
116 .ssport = GPIOB,
117 .sspad = 12,
118 .cr1 =
119 SPI_CR1_16BIT_MODE |
120 SPI_CR1_SSM |
121 SPI_CR1_SSI |
122 ((3 << SPI_CR1_BR_Pos) & SPI_CR1_BR) | // div = 16
123 SPI_CR1_MSTR |
124 SPI_CR1_CPHA |
125 0,
126 .cr2 = SPI_CR2_16BIT_MODE
127 },
128 .direct_io = {
129 { .port = GPIOA, .pad = 8 }, // TACH
130 { .port = GPIOD, .pad = 15 }, // PUMP_RELAY
131 { .port = GPIOD, .pad = 2 }, // IDLE
132 { .port = NULL, .pad = 0 } // no used, grounded
133 },
134 .resn = Gpio::Unassigned, //Gpio::B14,
135 .en = Gpio::Unassigned //Gpio::B15
136 },
137 {
138 .spi_bus = &SPID3,
139 .spi_config = {
140 .circular = false,
141#ifdef _CHIBIOS_RT_CONF_VER_6_1_
142 .end_cb = nullptr,
143#else
144 .slave = false,
145 .data_cb = nullptr,
146 .error_cb = nullptr,
147#endif
148 // 9104_CSN_LS2
149 .ssport = GPIOE,
150 .sspad = 1,
151 .cr1 =
152 SPI_CR1_16BIT_MODE |
153 SPI_CR1_SSM |
154 SPI_CR1_SSI |
155 ((3 << SPI_CR1_BR_Pos) & SPI_CR1_BR) | // div = 16
156 SPI_CR1_MSTR |
157 SPI_CR1_CPHA |
158 0,
159 .cr2 = SPI_CR2_16BIT_MODE
160 },
161 .direct_io = {
162 { .port = GPIOD, .pad = 12 }, // VVT1
163 { .port = GPIOD, .pad = 14 }, // VVT2
164 { .port = NULL, .pad = 0 }, // no used, grounded
165 { .port = GPIOA, .pad = 10 } // BOOST
166 },
167 .resn = Gpio::Unassigned, //Gpio::B14,
168 .en = Gpio::Unassigned //Gpio::B15
169 }
170};
171
172static void board_init_ext_gpios() {
173 /* Waste of RAM, switch to palSetPadMode() and palSetPort() */
174 {
175 static OutputPin TleCs0;
176 TleCs0.initPin("TLE9104 CS0", Gpio::A15);
177 TleCs0.setValue(1);
178 }
179 {
180 static OutputPin TleCs1;
181 TleCs1.initPin("TLE9104 CS1", Gpio::B12);
182 TleCs1.setValue(1);
183 }
184 {
185 static OutputPin TleCs2;
186 TleCs2.initPin("TLE9104 CS2", Gpio::E1);
187 TleCs2.setValue(1);
188 }
189
190 {
191 static OutputPin TleReset;
192 TleReset.initPin("TLE9104 Reset", Gpio::B14);
193 TleReset.setValue(1);
194
195 static OutputPin TleEn;
196 TleEn.initPin("TLE9104 En", Gpio::B15);
197 TleEn.setValue(1);
198 }
199
201}
202
203/**
204 * @brief Board-specific initialization code.
205 */
207 alphaTempPullUp.initPin("a-temp", Gpio::MM100_IGN8); // E6
208 alphaTachSelPullUp.initPin("Tach PullUp", Gpio::MM100_OUT_PWM1);
209 alphaHall1PullUp.initPin("hall1 PullUp", Gpio::MM100_IGN5);
210 alphaHall2PullUp.initPin("hall2 PullUp", Gpio::MM100_IGN6);
211 alphaHall34PullUp.initPin("hall3 PullUp", Gpio::MM100_IGN7);
213}
214
222
223static Gpio OUTPUTS[] = {
224 Gpio::TLE9104_0_OUT_3, // 1A - Injector 4
225 Gpio::TLE9104_0_OUT_1, // 2A - Injector 3
226 Gpio::TLE9104_0_OUT_2, // 3A - Injector 2
227 Gpio::TLE9104_0_OUT_0, // 4A - Injector 1
228 Gpio::TLE9104_1_OUT_1, // 5A - Fuel Pump Relay
229 Gpio::TLE9104_1_OUT_2, // 6A - Idle Output
230 Gpio::TLE9104_1_OUT_0, // 14A - Tach Output
231// Gpio::TLE9104_2_OUT_0, // J10.4 - OUT_VVT1
232// Gpio::TLE9104_2_OUT_1, // J10.5 - OUT_VVT2
233// Gpio::TLE9104_2_OUT_3, // J10.2 - OUT_BOOST
234 Gpio::MM100_IGN4,
235 Gpio::MM100_IGN1,
236 Gpio::MM100_IGN2,
237 Gpio::MM100_IGN3,
238};
239
241 return efi::size(OUTPUTS);
242}
243
247
249 return OUTPUTS;
250}
251
257
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
@ TLE9104_0_OUT_0
@ TLE9104_0_OUT_2
@ TLE9104_0_OUT_3
@ TLE9104_1_OUT_0
@ TLE9104_1_OUT_2
@ TLE9104_1_OUT_1
@ TLE9104_0_OUT_1
void setInline4()
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 Gpio OUTPUTS[]
static void setIgnitionPins()
static OutputPin alphaTempPullUp
void boardOnConfigurationChange(engine_configuration_s *)
int getBoardMetaOutputsCount()
Gpio * getBoardMetaOutputs()
static void setInjectorPins()
static const tle9104_config tle9104_cfg[BOARD_TLE9104_COUNT]
int getBoardMetaLowSideOutputsCount()
static OutputPin alphaHall1PullUp
static void board_init_ext_gpios()
static OutputPin alphaTachSelPullUp
static OutputPin alphaHall2PullUp
static void alphax_silver_boardDefaultConfiguration()
static OutputPin alphaHall34PullUp
static void alphax_silver_boardInitHardware()
Board-specific initialization code.
static void alphax_silver_boardConfigOverrides()
void setHellenCan()
void hellenMegaModule()
void setHellenMegaEnPin(bool enableBoardOnStartUp)
void setHellenMMbaro()
static void enableHellenSpi3()
SPIDriver * spi_bus
Definition tle9104.h:12
void initAll9104(const tle9104_config *configs)
Definition tle9104.cpp:568