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#include "pch.h"
6#include "board_overrides.h"
7
15
20
22 // open question if we need those LEDs at all? shall those be configurable?
23 return Gpio::Unassigned;
24}
25
27#if defined(HW_NOT_COMMUNITY_FRANKENSO) || defined(EFI_BOOTLOADER)
28 // not f407-discovery but f407-discovery while reusing board file
29 return Gpio::D15;
30#else
31 // f407-discovery community board not frankenso
33#endif
34}
35
37 // open question if we need those LEDs at all? shall those be configurable?
38 return Gpio::Unassigned;
39}
40
41#if EFI_ONBOARD_MEMS
43// engineConfiguration->accelerometerCsPin = Gpio::E3; // we have a conflict with VVT output on Miata
44// engineConfiguration->is_enabled_spi_1 = true; // we have a conflict with PA5 input pin
45
46 // stm32f4discovery defaults
50}
51#endif // EFI_ONBOARD_MEMS
52
53/**
54 * @brief Hardware board-specific default configuration (GPIO pins, ADC channels, SPI configs etc.)
55 */
59
60#ifndef HW_NOT_COMMUNITY_FRANKENSO
61 // f407-discovery community board not frankenso
62 config->communityCommsLedPin = Gpio::D15; // blue LED on discovery
63#endif
64
65 // set optional subsystem configs
66#if EFI_ONBOARD_MEMS
67 // this would override some values from above
69#endif /* EFI_ONBOARD_MEMS */
70
71
72
76 engineConfiguration->afr.hwChannel = EFI_ADC_14;
77
79
82
84// engineConfiguration->triggerInputPins[1] = Gpio::A5;
85
86 // set this to SPI_DEVICE_3 to enable stimulation
87 //engineConfiguration->digitalPotentiometerSpiDevice = SPI_DEVICE_3;
92
95 engineConfiguration->spi1sckPin = Gpio::B3; // please note that this pin is also SWO/SWD - Single Wire debug Output
96
100
104
105
106
107#if EFI_FILE_LOGGING
109#endif /* EFI_FILE_LOGGING */
110
114}
115
117
118static const struct mc33810_config mc33810 = {
119 .spi_bus = &SPID3,
120 .spi_config = {
121 .circular = false,
122#ifdef _CHIBIOS_RT_CONF_VER_6_1_
123 .end_cb = nullptr,
124#else
125 .slave = false,
126 .data_cb = nullptr,
127 .error_cb = nullptr,
128#endif
129 // todo: use engineConfiguration->mc33810_cs
130 .ssport = GPIOC,
131 .sspad = 5,
132 .cr1 =
133 SPI_CR1_16BIT_MODE |
134 SPI_CR1_SSM |
135 SPI_CR1_SSI |
136 ((3 << SPI_CR1_BR_Pos) & SPI_CR1_BR) | /* div = 16 */
137 SPI_CR1_MSTR |
138 /* SPI_CR1_CPOL | */ // = 0
139 SPI_CR1_CPHA | // = 1
140 0,
141 .cr2 = SPI_CR2_16BIT_MODE
142 },
143 .direct_io = {
144 /* injector drivers */
145 [0] = {.port = GPIOA, .pad = 3},
146 [1] = {.port = GPIOA, .pad = 4},
147 [2] = {.port = nullptr, .pad = 0},
148 [3] = {.port = nullptr, .pad = 0},
149 /* ignition pre-drivers */
150 [4] = {.port = GPIOA, .pad = 0},
151 [5] = {.port = GPIOA, .pad = 1},
152//GPGD mode is not supported yet, ignition mode does not support spi on/off commands
153// so ignition signals should be directly driven
154 [6] = {.port = GPIOD, .pad = 0},
155// meaning even if we do not use it we need a pin for now
156 [7] = {.port = GPIOD, .pad = 1},
157 },
158 .en = {.port = GPIOA, .pad = 6}, // copy-paste with setMode code!
159 // TODO: pick from engineConfiguration->spi3sckPin or whatever SPI is used
160 .sck = {.port = GPIOB, .pad = 3},
161 .spkdur = Gpio::Unassigned,
162 .nomi = Gpio::Unassigned,
163 .maxi = Gpio::Unassigned
164};
165
168 efiPrintf("*****************+ mc33810_add %d +*******************", ret);
169
170#ifndef EFI_BOOTLOADER
171 // todo: add to more appropriate location?
172 addConsoleAction("injinfo", [](){
173 efiPrintf("injinfo index=%d", engine->fuelComputer.brokenInjector);
174 });
175#endif // EFI_BOOTLOADER
176 }
177}
178
Gpio getWarningLedPin()
Gpio getCommsLedPin()
Gpio getRunningLedPin()
void setup_custom_board_overrides()
std::optional< setup_custom_board_overrides_type > custom_board_InitHardware
Definition hardware.cpp:77
FuelComputer fuelComputer
Definition engine.h:139
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
@ Unassigned
@ MC33810_0_OUT_0
static EngineAccessor engine
Definition engine.h:413
std::optional< setup_custom_board_overrides_type > custom_board_DefaultConfiguration
void setDefaultSdCardParameters()
static constexpr persistent_config_s * config
static constexpr engine_configuration_s * engineConfiguration
static void f407_discovery_DefaultConfiguration()
Hardware board-specific default configuration (GPIO pins, ADC channels, SPI configs etc....
static void configureAccelerometerPins()
void f407_discovery_boardInitHardware()
static void setDefaultFrankensoStepperIdleParameters()
static void setCanFrankensoDefaults()
static const struct mc33810_config mc33810
int mc33810_add(brain_pin_e base, unsigned int index, const mc33810_config *cfg)
MC33810 driver add.
Definition mc33810.cpp:946
brain_input_pin_e triggerInputPins[TRIGGER_INPUT_PIN_COUNT]
SPIDriver * spi_bus
Definition mc33810.h:30