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/hellen154hyundai/board_configuration.cpp
3 *
4 *
5 * @brief Configuration defaults for the hellen154hyundai board
6 *
7 * See https://rusefi.com/s/hellen154hyundai
8 *
9 * @author andreika <prometheus.pcb@gmail.com>
10 * @author Andrey Belomutskiy, (c) 2012-2020
11 */
12
13#include "pch.h"
14#include "defaults.h"
15#include "hellen_meta.h"
16#include "board_overrides.h"
17
24
31
33 engineConfiguration->vvtMode[0] = VVT_SINGLE_TOOTH;
34 engineConfiguration->vvtMode[1] = VVT_SINGLE_TOOTH;
35
37
38 setTPS1Inputs(H144_IN_TPS, H144_IN_TPS2);
39 setPPSInputs(H144_IN_PPS, H144_IN_PPS2);
40
42
43 engineConfiguration->afr.hwChannel = EFI_ADC_NONE;
44
45 engineConfiguration->clt.adcChannel = H144_IN_CLT;
46
47 engineConfiguration->iat.adcChannel = H144_IN_IAT;
48}
49
50static struct tle9201_config tle9201 = {
51 .spi_bus = &SPID3,
52 .spi_config = {
53 .circular = false,
54#ifdef _CHIBIOS_RT_CONF_VER_6_1_
55 .end_cb = nullptr,
56#else
57 .slave = false,
58 .data_cb = nullptr,
59 .error_cb = nullptr,
60#endif
61 // H_SPI3_CS
62 .ssport = GPIOA,
63 .sspad = 15,
64 .cr1 = TLE9201_CONFIG_CR1,
65 .cr2 = TLE9201_CONFIG_CR2
66 }
67};
68
70 /* Force 3.3V PWR_EN as MC33810 is powered from this power line */
72
74
75 /* MC33810, ETB1 and WASTGATE1 */
77
78 // trigger inputs
79 engineConfiguration->triggerInputPins[0] = Gpio::H144_IN_D_1;
80 // Direct hall-only cam input
81 engineConfiguration->camInputs[0] = Gpio::H144_IN_D_2; // intake
82 engineConfiguration->camInputs[1] = Gpio::H144_IN_D_3; // exhaust
83
84 // todo You would not believe how you invert TLE9201 #4579
86
87 setupTLE9201(/*controlPin*/Gpio::H144_OUT_PWM2, Gpio::H144_OUT_PWM3, Gpio::H144_OUT_IO12);
88
89 // wastegate DC motor
90 setupTLE9201(/*controlPin*/Gpio::H144_OUT_PWM4, Gpio::H144_OUT_PWM5, Gpio::H144_OUT_IO13, 1);
91}
92
93/**
94 * @brief Board-specific configuration defaults.
95 *
96 * See also setDefaultEngineConfiguration
97 *
98
99 */
103
104 setHellenCan();
105
106 engineConfiguration->fuelPumpPin = Gpio::H144_OUT_IO9;
107 engineConfiguration->fanPin = Gpio::H144_OUT_IO7;
108 engineConfiguration->mainRelayPin = Gpio::H144_OUT_IO3; // pin: 111a
109 // BK1 uses wire, BK2 uses CANbus
110 engineConfiguration->malfunctionIndicatorPin = Gpio::H144_OUT_PWM8;
111
112 engineConfiguration->brakePedalPin = Gpio::H144_IN_RES3;
113 engineConfiguration->clutchUpPin = Gpio::H144_IN_RES2;
114 engineConfiguration->acSwitch = Gpio::H144_IN_RES1;
115
116#ifndef EFI_BOOTLOADER
117 setCommonNTCSensor(&engineConfiguration->oilTempSensor, HELLEN_DEFAULT_AT_PULLUP); // random calibration for now
118#endif
120
121 // "required" hardware is done - set some reasonable defaults
123
124 engineConfiguration->etbFunctions[1] = DC_Wastegate;
125}
126
127static Gpio OUTPUTS[] = {
128 Gpio::MC33810_0_OUT_0, // 0: INJ_1 k25
129 Gpio::MC33810_0_OUT_1, // INJ_2 k26
130 Gpio::MC33810_0_OUT_2, // INJ_3 k27
131 Gpio::MC33810_0_OUT_3, // 3: INJ_4 k28
132 Gpio::H144_LS_5, // VVT1
133 Gpio::H144_LS_6, // 5: VVT2
134 Gpio::H144_LS_7, // K47 BK1 Wastegate Solenoid
135 Gpio::H144_OUT_IO7, // Fan Relay Low
136 Gpio::H144_OUT_IO3, // Main Relay K64
137 Gpio::H144_OUT_IO9, // Fuel Pump K70
138 Gpio::H144_OUT_IO10, // 10: K87 AC Relay
139 Gpio::H144_OUT_IO8, // Fan Relay HI
140 Gpio::MC33810_0_GD_0, // Coil 1
141 Gpio::MC33810_0_GD_1, // Coil 2
142 Gpio::MC33810_0_GD_2, // Coil 3
143 Gpio::MC33810_0_GD_3, // Coil 4
144 Gpio::H144_OUT_PWM8, // MIL
145// QC procedure seems to not work for that one Gpio::H144_OUT_PWM7, // low side? Tacho unused CAN tachometer right?
146// Gpio::H_SPI1_SCK, // X8 AuxLS1
147};
148
149static const struct mc33810_config mc33810 = {
150 .spi_bus = &SPID3,
151 .spi_config = {
152 .circular = false,
153#ifdef _CHIBIOS_RT_CONF_VER_6_1_
154 .end_cb = nullptr,
155#else
156 .slave = false,
157 .data_cb = nullptr,
158 .error_cb = nullptr,
159#endif
160 // SPI3_CS_33810 OUT_PWM1 H144_OUT_PWM1
161 .ssport = GPIOD,
162 .sspad = 13,
163 .cr1 =
164 SPI_CR1_16BIT_MODE |
165 SPI_CR1_SSM |
166 SPI_CR1_SSI |
167// ((3 << SPI_CR1_BR_Pos) & SPI_CR1_BR) | /* div = 16 */
168 ((0b110 << SPI_CR1_BR_Pos) & SPI_CR1_BR) | /* div = 128 */
169 SPI_CR1_MSTR |
170 0,
171 .cr2 = SPI_CR2_16BIT_MODE
172 },
173 .direct_io = {
174 /* injector drivers */
175 [0] = {.port = GPIOG, .pad = 7}, /* H144_LS_1 inj 1 */
176 [1] = {.port = GPIOG, .pad = 8}, /* H144_LS_2 inj 2 */
177 [2] = {.port = GPIOD, .pad = 11}, /* H144_LS_3 inj 3 */
178 [3] = {.port = GPIOD, .pad = 10}, /* H144_LS_4 inj 4 */
179 /* ignition pre-drivers */
180 [4] = {.port = GPIOG, .pad = 5}, /* H144_OUT_IO4 */
181 [5] = {.port = GPIOD, .pad = 2}, /* H144_OUT_IO5 */
182 [6] = {.port = GPIOG, .pad = 11}, /* H144_OUT_IO6 */
183 [7] = {.port = GPIOG, .pad = 2}, /* H144_OUT_IO11 */
184 },
185 .en = {.port = GPIOG, .pad = 9}, // H144_GP_IO4 hopefully
186 // TODO: pick from engineConfiguration->spi3sckPin or whatever SPI is used
187 .sck = {.port = GPIOC, .pad = 10},
188 .spkdur = Gpio::Unassigned,
189 .nomi = Gpio::Unassigned,
190 .maxi = Gpio::Unassigned
191};
192
194 static OutputPin spi3CsWastegate;
195
196 spi3CsWastegate.initPin("spi3-cs-wg", Gpio::H144_GP_IO6);
197 spi3CsWastegate.setValue(1);
198 // mc33810 takes care of the CS on it's own
199// static OutputPin spi3CsMc33810;
200// spi3CsMc33810.initPin("spi3-cs-mc33810", Gpio::H144_OUT_PWM1);
201// spi3CsMc33810.setValue(1);
202
203 gpio_pin_markUsed(tle9201.spi_config.ssport, tle9201.spi_config.sspad, "TLE9201 ETB CS");
204 palSetPadMode(tle9201.spi_config.ssport, tle9201.spi_config.sspad, PAL_MODE_OUTPUT_PUSHPULL);
205 int retTle = tle9201_add(0, &tle9201);
206 efiPrintf("*****************+ tle9201_add %d +*******************", retTle);
207
208 #if (BOARD_MC33810_COUNT > 0)
209 gpio_pin_markUsed(mc33810.spi_config.ssport, mc33810.spi_config.sspad, "mc33810 CS");
210 palSetPadMode(mc33810.spi_config.ssport, mc33810.spi_config.sspad, PAL_MODE_OUTPUT_PUSHPULL);
211
213 efiPrintf("*****************+ mc33810_add %d +*******************", ret);
214 #else
215 efiPrintf("**********------------- mc33810 not configured yet ------------************");
216 #endif
217}
218
220 return efi::size(OUTPUTS);
221}
222
226
228 return 2;
229}
230
232 return OUTPUTS;
233}
234
240
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
@ MC33810_0_GD_3
@ MC33810_0_OUT_2
@ Unassigned
@ MC33810_0_OUT_0
@ MC33810_0_OUT_3
@ MC33810_0_GD_2
@ MC33810_0_OUT_1
@ MC33810_0_GD_1
@ MC33810_0_GD_0
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 engine_configuration_s * engineConfiguration
static void setupDefaultSensorInputs()
static Gpio OUTPUTS[]
static void setIgnitionPins()
int getBoardMetaOutputsCount()
Gpio * getBoardMetaOutputs()
static void setInjectorPins()
int getBoardMetaLowSideOutputsCount()
int getBoardMetaDcOutputsCount()
static void hellen154hyundai_f7_boardInitHardware()
static void hellen154hyundai_f7_boardDefaultConfiguration()
Board-specific configuration defaults.
static struct tle9201_config tle9201
static const struct mc33810_config mc33810
static void hellen154hyundai_f7_boardConfigOverrides()
void setHellenCan()
void hellenMegaModule()
void setHellenMegaEnPin(bool enableBoardOnStartUp)
static void enableHellenSpi3()
int mc33810_add(brain_pin_e base, unsigned int index, const mc33810_config *cfg)
MC33810 driver add.
Definition mc33810.cpp:946
bool gpio_pin_markUsed(ioportid_t port, ioportmask_t pin, const char *msg)
brain_input_pin_e triggerInputPins[TRIGGER_INPUT_PIN_COUNT]
SPIDriver * spi_bus
Definition mc33810.h:30
SPIConfig spi_config
Definition mc33810.h:31
SPIDriver * spi_bus
Definition tle9201.h:32
SPIConfig spi_config
Definition tle9201.h:33
void setCommonNTCSensor(ThermistorConf *thermistorConf, float pullup)
int tle9201_add(unsigned int index, const tle9201_config *cfg)
TLE9201 driver add.
Definition tle9201.cpp:279