2019-08-01 19:27:23 -07:00
|
|
|
/**
|
|
|
|
* @file boards/microrusefi/board_configuration.cpp
|
|
|
|
*
|
2019-08-04 18:56:01 -07:00
|
|
|
*
|
2019-08-01 19:27:23 -07:00
|
|
|
* @brief Configuration defaults for the microRusefi board
|
|
|
|
*
|
2020-04-13 11:30:17 -07:00
|
|
|
* MICRO_RUS_EFI
|
|
|
|
* set engine_type 60
|
|
|
|
*
|
2020-05-21 15:36:32 -07:00
|
|
|
* MRE_BOARD_OLD_TEST
|
2020-04-13 11:30:17 -07:00
|
|
|
* set engine_type 30
|
|
|
|
*
|
2020-05-21 15:36:32 -07:00
|
|
|
* MRE_BOARD_NEW_TEST
|
|
|
|
* set engine_type 31
|
2020-04-13 11:30:17 -07:00
|
|
|
*
|
2021-12-30 21:45:12 -08:00
|
|
|
* See https://github.com/rusefi/rusefi/wiki/Hardware-microRusEfi-wiring
|
2019-08-04 18:56:01 -07:00
|
|
|
*
|
2019-08-01 19:27:23 -07:00
|
|
|
* @author Matthew Kennedy, (c) 2019
|
|
|
|
*/
|
|
|
|
|
2021-08-03 19:05:01 -07:00
|
|
|
#include "pch.h"
|
2021-10-26 07:27:10 -07:00
|
|
|
#include "mre_meta.h"
|
2019-08-01 19:27:23 -07:00
|
|
|
|
2019-08-04 18:56:01 -07:00
|
|
|
static void setInjectorPins() {
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->injectionPins[0] = Gpio::TLE8888_PIN_1;
|
|
|
|
engineConfiguration->injectionPins[1] = Gpio::TLE8888_PIN_2;
|
|
|
|
engineConfiguration->injectionPins[2] = Gpio::TLE8888_PIN_3;
|
|
|
|
engineConfiguration->injectionPins[3] = Gpio::TLE8888_PIN_4;
|
2019-08-01 19:27:23 -07:00
|
|
|
|
|
|
|
// Disable remainder
|
2021-07-06 17:14:08 -07:00
|
|
|
for (int i = 4; i < MAX_CYLINDER_COUNT;i++) {
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->injectionPins[i] = Gpio::Unassigned;
|
2019-08-01 19:27:23 -07:00
|
|
|
}
|
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->injectionPinMode = OM_DEFAULT;
|
2019-08-01 19:27:23 -07:00
|
|
|
}
|
|
|
|
|
2019-08-04 18:56:01 -07:00
|
|
|
static void setIgnitionPins() {
|
2019-08-17 19:42:22 -07:00
|
|
|
// todo: I wonder if these are not right in light of the network rename and the +12 VP issue?
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->ignitionPins[0] = Gpio::D4;
|
|
|
|
engineConfiguration->ignitionPins[1] = Gpio::D3;
|
|
|
|
engineConfiguration->ignitionPins[2] = Gpio::D2;
|
|
|
|
engineConfiguration->ignitionPins[3] = Gpio::D1;
|
2019-08-01 19:27:23 -07:00
|
|
|
|
|
|
|
// disable remainder
|
2021-07-06 17:14:08 -07:00
|
|
|
for (int i = 4; i < MAX_CYLINDER_COUNT; i++) {
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->ignitionPins[i] = Gpio::Unassigned;
|
2019-08-01 19:27:23 -07:00
|
|
|
}
|
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->ignitionPinMode = OM_DEFAULT;
|
2019-08-01 19:27:23 -07:00
|
|
|
}
|
|
|
|
|
2019-08-04 18:56:01 -07:00
|
|
|
static void setLedPins() {
|
2019-09-14 13:03:04 -07:00
|
|
|
#ifdef EFI_COMMUNICATION_PIN
|
|
|
|
engineConfiguration->communicationLedPin = EFI_COMMUNICATION_PIN;
|
|
|
|
#else
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->communicationLedPin = Gpio::E2; // d23 = blue
|
2019-09-14 13:03:04 -07:00
|
|
|
#endif /* EFI_COMMUNICATION_PIN */
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->runningLedPin = Gpio::E4; // d22 = green
|
|
|
|
engineConfiguration->warningLedPin = Gpio::E1; // d27 = orange or yellow
|
2019-08-01 19:27:23 -07:00
|
|
|
}
|
|
|
|
|
2019-08-04 18:56:01 -07:00
|
|
|
static void setupVbatt() {
|
2020-02-12 19:15:36 -08:00
|
|
|
/*
|
|
|
|
below 0.4
|
2019-08-01 19:27:23 -07:00
|
|
|
// 1k high side/1.5k low side = 1.6667 ratio divider
|
|
|
|
engineConfiguration->analogInputDividerCoefficient = 2.5f / 1.5f;
|
2020-02-12 19:15:36 -08:00
|
|
|
*/
|
2019-08-01 19:27:23 -07:00
|
|
|
|
2020-03-25 13:23:04 -07:00
|
|
|
// 6.8k high side/10k low side = 1.68 ratio divider
|
2020-02-12 20:16:46 -08:00
|
|
|
engineConfiguration->analogInputDividerCoefficient = 16.8f / 10.0f;
|
2020-02-12 19:15:36 -08:00
|
|
|
|
2020-03-25 13:23:04 -07:00
|
|
|
// set vbatt_divider 8.23
|
|
|
|
// R139=39k high side/R141=10k low side multiplied by above analogInputDividerCoefficient = 8.232f
|
|
|
|
engineConfiguration->vbattDividerCoeff = (49.0f / 10.0f) * engineConfiguration->analogInputDividerCoefficient;
|
2020-05-13 16:27:11 -07:00
|
|
|
// PC1, pin #1 input +12 from Main Relay. Main Relay controlled by TLE8888
|
2019-08-18 17:18:56 -07:00
|
|
|
engineConfiguration->vbattAdcChannel = EFI_ADC_11;
|
|
|
|
|
2019-08-01 19:27:23 -07:00
|
|
|
engineConfiguration->adcVcc = 3.29f;
|
|
|
|
}
|
|
|
|
|
2019-08-04 18:56:01 -07:00
|
|
|
static void setupTle8888() {
|
2020-05-14 23:31:02 -07:00
|
|
|
// on microRusEFI SPI3 is exposed on PC10/PC11 and there is interest to use SD card there
|
|
|
|
// PB3/PB4 could be either SPI1 or SP3, let's use not SPI3 to address the contention
|
|
|
|
// Enable spi1
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->is_enabled_spi_1 = true;
|
2019-08-01 19:27:23 -07:00
|
|
|
|
2020-05-14 23:31:02 -07:00
|
|
|
// Wire up spi1
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->spi1mosiPin = Gpio::B5;
|
|
|
|
engineConfiguration->spi1misoPin = Gpio::B4;
|
|
|
|
engineConfiguration->spi1sckPin = Gpio::B3;
|
2019-08-01 19:27:23 -07:00
|
|
|
|
|
|
|
// Chip select
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->tle8888_cs = Gpio::D5;
|
2019-08-01 19:27:23 -07:00
|
|
|
|
|
|
|
// SPI device
|
2020-05-14 23:31:02 -07:00
|
|
|
engineConfiguration->tle8888spiDevice = SPI_DEVICE_1;
|
2019-08-01 19:27:23 -07:00
|
|
|
}
|
|
|
|
|
2019-08-04 18:56:01 -07:00
|
|
|
static void setupEtb() {
|
2019-08-01 19:27:23 -07:00
|
|
|
// TLE9201 driver
|
|
|
|
// This chip has three control pins:
|
|
|
|
// DIR - sets direction of the motor
|
|
|
|
// PWM - pwm control (enable high, coast low)
|
|
|
|
// DIS - disables motor (enable low)
|
|
|
|
|
|
|
|
// PWM pin
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->etbIo[0].controlPin = Gpio::C7;
|
2019-08-01 19:27:23 -07:00
|
|
|
// DIR pin
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->etbIo[0].directionPin1 = Gpio::A8;
|
2020-04-10 14:27:13 -07:00
|
|
|
// Disable pin
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->etbIo[0].disablePin = Gpio::C8;
|
2020-04-10 14:27:13 -07:00
|
|
|
// Unused
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->etbIo[0].directionPin2 = Gpio::Unassigned;
|
2019-08-14 22:59:15 -07:00
|
|
|
|
2019-08-01 19:27:23 -07:00
|
|
|
// we only have pwm/dir, no dira/dirb
|
2019-11-29 13:51:51 -08:00
|
|
|
engineConfiguration->etb_use_two_wires = false;
|
2019-08-01 19:27:23 -07:00
|
|
|
}
|
|
|
|
|
2019-08-04 18:56:01 -07:00
|
|
|
static void setupDefaultSensorInputs() {
|
2019-08-01 19:27:23 -07:00
|
|
|
// trigger inputs
|
|
|
|
// tle8888 VR conditioner
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->triggerInputPins[0] = Gpio::C6;
|
|
|
|
engineConfiguration->triggerInputPins[1] = Gpio::Unassigned;
|
|
|
|
engineConfiguration->triggerInputPins[2] = Gpio::Unassigned;
|
2019-08-01 19:27:23 -07:00
|
|
|
// Direct hall-only cam input
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->camInputs[0] = Gpio::A5;
|
2019-08-01 19:27:23 -07:00
|
|
|
|
2019-08-17 19:42:22 -07:00
|
|
|
// open question if it's great to have TPS in default TPS - the down-side is for
|
|
|
|
// vehicles without TPS or for first start without TPS one would have to turn in off
|
|
|
|
// to avoid cranking corrections based on wrong TPS data
|
2021-10-26 07:27:10 -07:00
|
|
|
engineConfiguration->tps1_1AdcChannel = MRE_IN_TPS;
|
2019-08-01 19:27:23 -07:00
|
|
|
engineConfiguration->tps2_1AdcChannel = EFI_ADC_NONE;
|
|
|
|
|
2019-09-02 14:16:36 -07:00
|
|
|
|
2021-10-26 07:27:10 -07:00
|
|
|
engineConfiguration->map.sensor.hwChannel = MRE_IN_MAP;
|
2019-09-02 14:16:36 -07:00
|
|
|
|
2019-09-16 18:00:20 -07:00
|
|
|
// EFI_ADC_14: "32 - AN volt 6"
|
|
|
|
engineConfiguration->afr.hwChannel = EFI_ADC_14;
|
2019-09-02 14:16:36 -07:00
|
|
|
|
2021-10-26 07:27:10 -07:00
|
|
|
engineConfiguration->clt.adcChannel = MRE_IN_CLT;
|
2019-08-01 19:27:23 -07:00
|
|
|
|
2021-10-26 07:27:10 -07:00
|
|
|
engineConfiguration->iat.adcChannel = MRE_IN_IAT;
|
2020-07-27 17:23:57 -07:00
|
|
|
|
2020-07-27 19:05:40 -07:00
|
|
|
setCommonNTCSensor(&engineConfiguration->auxTempSensor1, 2700);
|
|
|
|
setCommonNTCSensor(&engineConfiguration->auxTempSensor2, 2700);
|
2020-07-27 17:23:57 -07:00
|
|
|
|
|
|
|
#if HW_CHECK_MODE
|
|
|
|
engineConfiguration->auxTempSensor1.adcChannel = EFI_ADC_2;
|
|
|
|
engineConfiguration->auxTempSensor2.adcChannel = EFI_ADC_3;
|
|
|
|
#endif // HW_CHECK_MODE
|
2019-08-01 19:27:23 -07:00
|
|
|
}
|
|
|
|
|
2022-01-11 19:26:24 -08:00
|
|
|
void setBoardConfigOverrides() {
|
2021-03-31 11:46:50 -07:00
|
|
|
setLedPins();
|
|
|
|
setupVbatt();
|
|
|
|
setupTle8888();
|
|
|
|
setupEtb();
|
|
|
|
|
|
|
|
engineConfiguration->clt.config.bias_resistor = 2700;
|
|
|
|
engineConfiguration->iat.config.bias_resistor = 2700;
|
|
|
|
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->canTxPin = Gpio::B6;
|
|
|
|
engineConfiguration->canRxPin = Gpio::B12;
|
2021-03-31 11:46:50 -07:00
|
|
|
|
|
|
|
// SPI for SD card
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->is_enabled_spi_3 = true;
|
2021-03-31 11:46:50 -07:00
|
|
|
engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3;
|
|
|
|
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->spi3mosiPin = Gpio::C12;
|
|
|
|
engineConfiguration->spi3misoPin = Gpio::C11;
|
|
|
|
engineConfiguration->spi3sckPin = Gpio::C10;
|
2021-03-31 11:46:50 -07:00
|
|
|
}
|
|
|
|
|
2022-01-11 19:26:24 -08:00
|
|
|
void setSerialConfigurationOverrides() {
|
2020-05-02 19:27:20 -07:00
|
|
|
// why would MRE disable serial by default? we definitely have pads exposed
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->useSerialPort = false;
|
2022-02-06 18:50:09 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-01 19:27:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-03-22 11:15:09 -07:00
|
|
|
* @brief Board-specific configuration defaults.
|
2019-08-04 18:56:01 -07:00
|
|
|
*
|
|
|
|
* See also setDefaultEngineConfiguration
|
|
|
|
*
|
2019-08-01 19:27:23 -07:00
|
|
|
* @todo Add your board-specific code, if any.
|
|
|
|
*/
|
2022-01-11 19:26:24 -08:00
|
|
|
void setBoardDefaultConfiguration() {
|
2019-08-01 19:27:23 -07:00
|
|
|
setInjectorPins();
|
|
|
|
setIgnitionPins();
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->sdCardCsPin = Gpio::B9;
|
2020-09-06 19:36:31 -07:00
|
|
|
|
2019-09-12 04:29:38 -07:00
|
|
|
// MRE has a special main relay control low side pin
|
|
|
|
// rusEfi firmware is totally not involved with main relay control on microRusEfi board
|
|
|
|
// todo: maybe even set EFI_MAIN_RELAY_CONTROL to FALSE for MRE configuration
|
2019-09-14 13:03:04 -07:00
|
|
|
// TLE8888 half bridges (pushpull, lowside, or high-low) TLE8888_IN11 / TLE8888_OUT21
|
2022-04-28 14:32:39 -07:00
|
|
|
// Gpio::TLE8888_PIN_21: "35 - GP Out 1"
|
|
|
|
engineConfiguration->fuelPumpPin = Gpio::TLE8888_PIN_21;
|
2019-09-02 08:07:34 -07:00
|
|
|
|
2020-05-13 20:26:28 -07:00
|
|
|
// engineConfiguration->isSdCardEnabled = true;
|
|
|
|
|
2019-09-08 08:17:27 -07:00
|
|
|
// TLE8888 high current low side: VVT2 IN9 / OUT5
|
2022-04-28 14:32:39 -07:00
|
|
|
// Gpio::E10: "3 - Lowside 2"
|
|
|
|
engineConfiguration->idle.solenoidPin = Gpio::TLE8888_PIN_5;
|
2019-09-08 08:17:27 -07:00
|
|
|
|
|
|
|
|
2022-04-28 14:32:39 -07:00
|
|
|
// Gpio::TLE8888_PIN_22: "34 - GP Out 2"
|
|
|
|
engineConfiguration->fanPin = Gpio::TLE8888_PIN_22;
|
2019-09-05 20:14:28 -07:00
|
|
|
|
2019-08-01 19:27:23 -07:00
|
|
|
// "required" hardware is done - set some reasonable defaults
|
|
|
|
setupDefaultSensorInputs();
|
|
|
|
|
|
|
|
engineConfiguration->specs.cylindersCount = 4;
|
|
|
|
engineConfiguration->specs.firingOrder = FO_1_3_4_2;
|
|
|
|
|
|
|
|
engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // IM_WASTED_SPARK
|
|
|
|
engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS;
|
|
|
|
engineConfiguration->injectionMode = IM_SIMULTANEOUS;//IM_BATCH;// IM_SEQUENTIAL;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:05:44 -08:00
|
|
|
/**
|
|
|
|
* @brief Board-specific SD card configuration code overrides. Needed by bootloader code.
|
|
|
|
* @todo Add your board-specific code, if any.
|
|
|
|
*/
|
2022-01-11 19:26:24 -08:00
|
|
|
void setSdCardConfigurationOverrides() {
|
2019-11-06 17:05:44 -08:00
|
|
|
}
|