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
16
23
24static void setIgnitionPins() {
25 engineConfiguration->ignitionPins[0] = Gpio::MM100_IGN1;
26 engineConfiguration->ignitionPins[1] = Gpio::MM100_IGN2;
27 engineConfiguration->ignitionPins[2] = Gpio::MM100_IGN3;
28 engineConfiguration->ignitionPins[3] = Gpio::MM100_IGN4;
29}
30
32 engineConfiguration->tps1_1AdcChannel = MM100_IN_TPS_ANALOG;
33
35
36// engineConfiguration->map.sensor.hwChannel = H144_IN_MAP1; // external MAP
37 engineConfiguration->map.sensor.hwChannel = H144_IN_MAP2; // On-board MAP
38 engineConfiguration->map.sensor.type = MT_MPXH6400;
39
40 engineConfiguration->clt.adcChannel = MM100_IN_CLT_ANALOG;
41 engineConfiguration->iat.adcChannel = MM100_IN_IAT_ANALOG;
42}
43
45 /* Force PWR_EN as TLE9104s are powered from +5VA */
47
50
51 /* Two TLE9104 */
53 engineConfiguration->vrThreshold[0].pin = Gpio::MM100_OUT_PWM2;
54}
55
63
64/*
65 * RESET and EN signals of both TLE9104 are driven by same gpios,
66 * Do not allow TLE driver to drive this pins as it will reset
67 * first chip while initing second.
68 * Set pins to proper once.
69 * TODO: improve?
70 */
71static const tle9104_config tle9104_cfg[BOARD_TLE9104_COUNT] = {
72 {
73 .spi_bus = &SPID3,
74 .spi_config = {
75 .circular = false,
76#ifdef _CHIBIOS_RT_CONF_VER_6_1_
77 .end_cb = nullptr,
78#else
79 .slave = false,
80 .data_cb = nullptr,
81 .error_cb = nullptr,
82#endif
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 },
97 { .port = GPIOA, .pad = 9 },
98 { .port = GPIOD, .pad = 11 },
99 { .port = GPIOD, .pad = 10 }
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 .ssport = GPIOB,
116 .sspad = 12,
117 .cr1 =
118 SPI_CR1_16BIT_MODE |
119 SPI_CR1_SSM |
120 SPI_CR1_SSI |
121 ((3 << SPI_CR1_BR_Pos) & SPI_CR1_BR) | // div = 16
122 SPI_CR1_MSTR |
123 SPI_CR1_CPHA |
124 0,
125 .cr2 = SPI_CR2_16BIT_MODE
126 },
127 .direct_io = {
128 { .port = GPIOA, .pad = 8 }, // tach
129 { .port = GPIOD, .pad = 15 }, // pump relay
130 { .port = GPIOD, .pad = 2 }, // idle valve
131 { .port = GPIOD, .pad = 12 } // fan relay
132 },
133 .resn = Gpio::Unassigned, //Gpio::B14,
134 .en = Gpio::Unassigned //Gpio::B15
135 }
136};
137
138static void board_init_ext_gpios() {
139 {
140 /* Waste of RAM, switch to palSetPadMode() and palSetPort() */
141 static OutputPin TleCs0;
142 TleCs0.initPin("TLE9104 CS0", Gpio::A15);
143 TleCs0.setValue(1);
144 }
145 {
146 static OutputPin TleCs1;
147 TleCs1.initPin("TLE9104 CS1", Gpio::B12);
148 TleCs1.setValue(1);
149 }
150
151 {
152 static OutputPin TleReset;
153 TleReset.initPin("TLE9104 Reset", Gpio::B14);
154 TleReset.setValue(1);
155
156 static OutputPin TleEn;
157 TleEn.initPin("TLE9104 En", Gpio::B15);
158 TleEn.setValue(1);
159 }
160
162}
163
164/**
165 * @brief Board-specific initialization code.
166 */
168 alphaTempPullUp.initPin("a-temp", Gpio::MM100_IGN8); // E6
169 alphaTachSelPullUp.initPin("Tach PullUp", Gpio::MM100_OUT_PWM1);
170 alphaHall1PullUp.initPin("hall1 PullUp", Gpio::MM100_OUT_PWM3);
171 alphaHall2PullUp.initPin("hall2 PullUp", Gpio::MM100_OUT_PWM4);
172 alphaHall3PullUp.initPin("hall3 PullUp", Gpio::MM100_OUT_PWM5);
173 alphaHall4PullUp.initPin("hall4 PullUp", Gpio::MM100_OUT_PWM6);
175}
176
185
186static Gpio OUTPUTS[] = {
187 Gpio::TLE9104_0_OUT_3, // 1A - Injector 4
188 Gpio::TLE9104_0_OUT_2, // 2A - Injector 3
189 Gpio::TLE9104_0_OUT_1, // 3A - Injector 2
190 Gpio::TLE9104_0_OUT_0, // 4A - Injector 1
191 Gpio::TLE9104_1_OUT_1, // 5A Fuel Pump Relay
192 Gpio::TLE9104_1_OUT_2, // 6A Idle Output
193 Gpio::TLE9104_1_OUT_3, // 28A Fan Relay
194 Gpio::TLE9104_1_OUT_0, // 14A Tach Output
195 Gpio::MM100_IGN1,
196 Gpio::MM100_IGN2,
197 Gpio::MM100_IGN3,
198 Gpio::MM100_IGN4,
199};
200
202 return efi::size(OUTPUTS);
203}
204
208
210 return OUTPUTS;
211}
212
218
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
@ TLE9104_1_OUT_3
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 alphaHall4PullUp
static OutputPin alphaTachSelPullUp
static OutputPin alphaHall3PullUp
static OutputPin alphaHall2PullUp
static void alphax_silver_revA_boardDefaultConfiguration()
static void alphax_silver_revA_boardConfigOverrides()
static void alphax_silver_revA_boardInitHardware()
Board-specific initialization code.
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