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
77static bool isMegaModuleRevision() {
78#ifndef EFI_BOOTLOADER
80 return hellenBoardId != BOARD_ID_ALPHA2CH_B && hellenBoardId != BOARD_ID_ALPHA2CH_C && hellenBoardId != BOARD_ID_ALPHA2CH_D;
81#else
82 return true;
83#endif // EFI_BOOTLOADER
84}
85
88#ifndef EFI_BOOTLOADER
90
91 // rev.D uses SPI1 pins for CAN2, but rev.E and later uses mega-module meaning SPI1 for SD-card
95 } else {
96 setHellenEnPin(Gpio::H144_OUT_IO3);
97 }
98
99 // todo: is it time for some helper method to work with sets?!
100 bool isBeforeRevG = hellenBoardId == BOARD_ID_ALPHA2CH_B ||
101 hellenBoardId == BOARD_ID_ALPHA2CH_C ||
102 hellenBoardId == BOARD_ID_ALPHA2CH_D ||
103 hellenBoardId == BOARD_ID_ALPHA2CH_E ||
104 hellenBoardId == BOARD_ID_ALPHA2CH_F;
105
106 if (isBeforeRevG) {
107 engineConfiguration->vrThreshold[0].pin = Gpio::H144_OUT_PWM6;
108 } else {
109 engineConfiguration->vrThreshold[0].pin = Gpio::Unassigned; // rev G started to use MAX9924
110 }
111
112 engineConfiguration->vrThreshold[1].pin = Gpio::Unassigned; // 2chan never had second VR
114#endif // EFI_BOOTLOADER
115
116 setHellenCan();
117}
118
119/**
120 * @brief Board-specific configuration defaults.
121 *
122
123 *
124 */
128
129 if (isMegaModuleRevision()) {
131 engineConfiguration->map.sensor.hwChannel = H144_IN_MAP3; // On-board MAP
132 engineConfiguration->map.sensor.type = MT_MPXH6400;
133 } else {
134 engineConfiguration->map.sensor.hwChannel = H144_IN_MAP2; // B2 external signal
135 engineConfiguration->baroSensor.type = MT_MPXH6400;
136 engineConfiguration->baroSensor.hwChannel = H144_IN_MAP3; // On-board MAP
137 }
138
140
141 engineConfiguration->fuelPumpPin = Gpio::H144_OUT_PWM2;
142 engineConfiguration->fanPin = Gpio::H144_OUT_PWM4;
143 engineConfiguration->tachOutputPin = Gpio::H144_OUT_PWM3;
144
145 // "required" hardware is done - set some reasonable defaults
147
148 setInline4();
149
150 engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK
151
152 engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH;
153// ? engineConfiguration->malfunctionIndicatorPin = Gpio::G4; //1E - Check Engine Light
154}
155
157 // Wake on the CAN RX pin
158 palEnableLineEvent(PAL_LINE(GPIOD, 0), PAL_EVENT_MODE_RISING_EDGE);
159}
160
161static Gpio OUTPUTS[] = {
162 Gpio::H144_LS_1,
163 Gpio::H144_LS_2,
164};
165
167 return efi::size(OUTPUTS);
168}
169
171 return OUTPUTS;
172}
173
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
std::optional< setup_custom_board_config_type > custom_board_OnConfigurationChange
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()
static void customBoardOnConfigurationChange(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]