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 2chan 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
22
34
41
43 // trigger inputs, hall
44 engineConfiguration->triggerInputPins[0] = Gpio::H144_IN_CRANK;
45 engineConfiguration->triggerInputPins[1] = Gpio::H144_IN_CAM;
47
49
50
51
53
54 engineConfiguration->clt.adcChannel = H144_IN_CLT;
55 engineConfiguration->iat.adcChannel = H144_IN_IAT;
56}
57
59
60 alphaTachPullUp.initPin("a-tach", Gpio::H144_OUT_IO1);
61 alphaTempPullUp.initPin("a-temp", Gpio::H144_OUT_IO4);
62 alphaCrankPPullUp.initPin("a-crank-p", Gpio::H144_OUT_IO2);
63 alphaCrankNPullUp.initPin("a-crank-n", Gpio::H144_OUT_IO5);
64 alpha2stepPullDown.initPin("a-2step", Gpio::H144_OUT_IO7);
65 alphaCamPullDown.initPin("a-cam", Gpio::H144_OUT_IO8);
66}
67
76
77
78
79static bool isMegaModuleRevision() {
80#ifndef EFI_BOOTLOADER
82 return hellenBoardId != BOARD_ID_ALPHA2CH_B && hellenBoardId != BOARD_ID_ALPHA2CH_C && hellenBoardId != BOARD_ID_ALPHA2CH_D;
83#else
84 return true;
85#endif // EFI_BOOTLOADER
86}
87
90#ifndef EFI_BOOTLOADER
92
93 // rev.D uses SPI1 pins for CAN2, but rev.E and later uses mega-module meaning SPI1 for SD-card
97 } else {
98 setHellenEnPin(Gpio::H144_OUT_IO3);
99 }
100
101 // todo: is it time for some helper method to work with sets?!
102 bool isBeforeRevG = hellenBoardId == BOARD_ID_ALPHA2CH_B ||
103 hellenBoardId == BOARD_ID_ALPHA2CH_C ||
104 hellenBoardId == BOARD_ID_ALPHA2CH_D ||
105 hellenBoardId == BOARD_ID_ALPHA2CH_E ||
106 hellenBoardId == BOARD_ID_ALPHA2CH_F;
107
108 if (isBeforeRevG) {
109 engineConfiguration->vrThreshold[0].pin = Gpio::H144_OUT_PWM6;
110 } else {
111 engineConfiguration->vrThreshold[0].pin = Gpio::Unassigned; // rev G started to use MAX9924
112 }
113
114 engineConfiguration->vrThreshold[1].pin = Gpio::Unassigned; // 2chan never had second VR
116#endif // EFI_BOOTLOADER
117
118 setHellenCan();
119}
120
121/**
122 * @brief Board-specific configuration defaults.
123 *
124 * See also setDefaultEngineConfiguration
125 *
126 */
130
131 if (isMegaModuleRevision()) {
133 engineConfiguration->map.sensor.hwChannel = H144_IN_MAP3; // On-board MAP
134 engineConfiguration->map.sensor.type = MT_MPXH6400;
135 } else {
136 engineConfiguration->map.sensor.hwChannel = H144_IN_MAP2; // B2 external signal
137 engineConfiguration->baroSensor.type = MT_MPXH6400;
138 engineConfiguration->baroSensor.hwChannel = H144_IN_MAP3; // On-board MAP
139 }
140
142
143 engineConfiguration->fuelPumpPin = Gpio::H144_OUT_PWM2;
144 engineConfiguration->fanPin = Gpio::H144_OUT_PWM4;
145 engineConfiguration->tachOutputPin = Gpio::H144_OUT_PWM3;
146
147 // "required" hardware is done - set some reasonable defaults
149
150 setInline4();
151
152 engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK
153
154 engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH;
155// ? engineConfiguration->malfunctionIndicatorPin = Gpio::G4; //1E - Check Engine Light
156}
157
159 // Wake on the CAN RX pin
160 palEnableLineEvent(PAL_LINE(GPIOD, 0), PAL_EVENT_MODE_RISING_EDGE);
161}
162
163static Gpio OUTPUTS[] = {
164 Gpio::H144_LS_1,
165 Gpio::H144_LS_2,
166};
167
169 return efi::size(OUTPUTS);
170}
171
173 return OUTPUTS;
174}
175
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 setInline4()
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 void alphax_2chan_ConfigOverrides()
static OutputPin alphaCamPullDown
static OutputPin alphaTachPullUp
static OutputPin alphaCrankPPullUp
static void setupDefaultSensorInputs()
static void alphax_2chan_boardInitHardware()
static Gpio OUTPUTS[]
static void setIgnitionPins()
static OutputPin alphaTempPullUp
static bool isMegaModuleRevision()
void boardPrepareForStop()
void boardOnConfigurationChange(engine_configuration_s *)
static OutputPin alpha2stepPullDown
int getBoardMetaOutputsCount()
static OutputPin alphaCrankNPullUp
static void alphax_2chan_defaultConfiguration()
Board-specific configuration defaults.
Gpio * getBoardMetaOutputs()
static void setInjectorPins()
void hellenMegaSdWithAccelerometer()
void setHellenCan()
void setHellenVbatt()
void setHellenEnPin(Gpio pin, bool enableBoardOnStartUp)
void setHellenMegaEnPin(bool enableBoardOnStartUp)
void setHellenMMbaro()
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]