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
18static void setInjectorPins() {
19 engineConfiguration->injectionPins[0] = Gpio::H144_LS_1;
20 engineConfiguration->injectionPins[1] = Gpio::H144_LS_2;
21 engineConfiguration->injectionPins[2] = Gpio::H144_LS_3;
22 engineConfiguration->injectionPins[3] = Gpio::H144_LS_4;
23}
24
25static void setIgnitionPins() {
26 engineConfiguration->ignitionPins[0] = Gpio::H144_IGN_1;
27 engineConfiguration->ignitionPins[1] = Gpio::H144_IGN_2;
28 engineConfiguration->ignitionPins[2] = Gpio::H144_IGN_3;
29 engineConfiguration->ignitionPins[3] = Gpio::H144_IGN_4;
30}
31
33 engineConfiguration->vvtMode[0] = VVT_SINGLE_TOOTH;
34 engineConfiguration->vvtMode[1] = VVT_SINGLE_TOOTH;
35
37
38 setTPS1Inputs(H144_IN_TPS, H144_IN_AUX1_ANALOG);
39
40 setPPSInputs(EFI_ADC_3, EFI_ADC_14);
41
43
44 engineConfiguration->afr.hwChannel = EFI_ADC_NONE;
45
46 engineConfiguration->clt.adcChannel = H144_IN_CLT;
47
48 engineConfiguration->iat.adcChannel = H144_IN_IAT;
49}
50
51#ifndef EFI_BOOTLOADER
52static bool isFirstInvocation = true;
53#endif // EFI_BOOTLOADER
54
55/*PUBLIC_API_WEAK*/ int hackHellenBoardId(int detectedId) {
56 if (detectedId == BOARD_ID_VAG121_D) {
57 // wow something bad has happened to that batch of boards?!
58 return BOARD_ID_154HYUNDAI_C;
59 }
60 return detectedId;
61}
62
65
67
69
70 // trigger inputs
72 // Direct hall-only cam input
73 // exhaust input same on both revisions
74 engineConfiguration->camInputs[1] = Gpio::H144_ORIGINAL_MCU_IN_D_AUX4;
75
76#ifndef EFI_BOOTLOADER
78
79 if (hellenBoardId == -1) {
80 engineConfiguration->triggerInputPins[0] = Gpio::H144_IN_CRANK;
81 engineConfiguration->camInputs[0] = Gpio::H144_IN_CAM;
82
83 // control pins are inverted since overall ECU pinout seems to be inverted
84 engineConfiguration->etbIo[0].directionPin1 = Gpio::H144_OUT_PWM3;
85 engineConfiguration->etbIo[0].directionPin2 = Gpio::H144_OUT_PWM2;
86 engineConfiguration->etbIo[0].controlPin = Gpio::H144_OUT_IO12;
89
90 // first revision of did not have Hellen Board ID
91 // https://github.com/rusefi/hellen154hyundai/issues/55
96
98 isFirstInvocation = false;
99 efiSetPadMode("ETB FIX0", Gpio::H144_OUT_PWM4, PAL_MODE_INPUT_ANALOG);
100 efiSetPadMode("ETB FIX1", Gpio::H144_OUT_PWM5, PAL_MODE_INPUT_ANALOG);
101 efiSetPadMode("ETB FIX2", Gpio::H144_OUT_IO13, PAL_MODE_INPUT_ANALOG);
102 }
104 } else if (hellenBoardId == BOARD_ID_154HYUNDAI_C || hellenBoardId == BOARD_ID_154HYUNDAI_D) {
105 engineConfiguration->triggerInputPins[0] = Gpio::H144_IN_SENS2;
106 engineConfiguration->camInputs[0] = Gpio::H144_IN_SENS3;
107
108
109 // todo You would not believe how you invert TLE9201 #4579
111
112 //ETB1
113 // PWM pin
114 engineConfiguration->etbIo[0].controlPin = Gpio::H144_OUT_PWM2;
115 // DIR pin
116 engineConfiguration->etbIo[0].directionPin1 = Gpio::H144_OUT_PWM3;
117 // Disable pin
118 engineConfiguration->etbIo[0].disablePin = Gpio::H144_OUT_IO12;
119
120 // wastegate DC motor
121 //ETB2
122 // PWM pin
123 engineConfiguration->etbIo[1].controlPin = Gpio::H144_OUT_PWM4;
124 // DIR pin
125 engineConfiguration->etbIo[1].directionPin1 = Gpio::H144_OUT_PWM5;
126 // Disable pin
127 engineConfiguration->etbIo[1].disablePin = Gpio::H144_OUT_IO13;
128 }
129#endif // EFI_BOOTLOADER
130}
131
132/**
133 * @brief Board-specific configuration defaults.
134 *
135 * See also setDefaultEngineConfiguration
136 *
137
138 */
142
144 setHellenCan();
145
146 engineConfiguration->fuelPumpPin = Gpio::H144_OUT_IO9;
147 engineConfiguration->fanPin = Gpio::H144_OUT_IO7;
148 engineConfiguration->mainRelayPin = Gpio::H144_OUT_IO3; // pin: 111a
149 // BK1 uses wire, BK2 uses CANbus
150 engineConfiguration->malfunctionIndicatorPin = Gpio::H144_OUT_PWM8;
151
152 engineConfiguration->brakePedalPin = Gpio::H144_IN_RES3;
153 engineConfiguration->clutchUpPin = Gpio::H144_IN_RES2;
154 engineConfiguration->acSwitch = Gpio::H144_IN_RES1;
155
156 // "required" hardware is done - set some reasonable defaults
158
159 engineConfiguration->etbFunctions[1] = DC_Wastegate;
160}
161
162static Gpio OUTPUTS[] = {
163 Gpio::H144_LS_1, // 0: INJ_1 k25
164 Gpio::H144_LS_2, // INJ_2 k26
165 Gpio::H144_LS_3, // INJ_3 k27
166 Gpio::H144_LS_4, // 3: INJ_4 k28
167 Gpio::H144_LS_5, // VVT1
168 Gpio::H144_LS_6, // 5: VVT2
169 Gpio::H144_LS_7, // K47 BK1 Wastegate Solenoid
170 Gpio::H144_OUT_IO7, // Fan Relay Low
171 Gpio::H144_OUT_IO3, // Main Relay K64
172 Gpio::H144_OUT_IO9, // Fuel Pump K70
173 Gpio::H144_OUT_IO10, // 10: K87 AC Relay
174 Gpio::H144_OUT_IO8, // Fan Relay HI
175 Gpio::H144_IGN_1, // Coil 1
176 Gpio::H144_IGN_2, // Coil 2
177 Gpio::H144_IGN_3, // Coil 3
178 Gpio::H144_IGN_4, // Coil 4
179 Gpio::H144_OUT_PWM8, // MIL
180// QC procedure seems to not work for that one Gpio::H144_OUT_PWM7, // low side? Tacho unused CAN tachometer right?
181// Gpio::H_SPI1_SCK, // X8 AuxLS1
182};
183
185 return efi::size(OUTPUTS);
186}
187
191
193 return 2;
194}
195
197 return OUTPUTS;
198}
199
void setup_custom_board_overrides()
void efiSetPadMode(const char *msg, brain_pin_e brainPin, iomode_t mode)
EngineState engineState
Definition engine.h:344
@ Unassigned
void setPPSInputs(adc_channel_e pps1, adc_channel_e pps2)
void setTPS1Inputs(adc_channel_e tps1, adc_channel_e tps2)
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 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 bool isFirstInvocation
static void hellen154_hyundai_boardConfigOverrides()
int hackHellenBoardId(int detectedId)
static void hellen154_hyundai_boardDefaultConfiguration()
Board-specific configuration defaults.
void setHellenCan()
void setHellenVbatt()
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]