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
|
|
|
|
*
|
2019-08-04 18:56:01 -07:00
|
|
|
* See https://github.com/rusefi/rusefi_documentation/wiki/Hardware_microRusEfi_wiring
|
|
|
|
*
|
2019-08-01 19:27:23 -07:00
|
|
|
* @author Matthew Kennedy, (c) 2019
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "global.h"
|
|
|
|
#include "engine.h"
|
|
|
|
#include "engine_math.h"
|
|
|
|
#include "allsensors.h"
|
|
|
|
#include "fsio_impl.h"
|
|
|
|
#include "engine_configuration.h"
|
|
|
|
|
|
|
|
EXTERN_ENGINE;
|
|
|
|
|
2019-08-04 18:56:01 -07:00
|
|
|
static void setInjectorPins() {
|
2019-08-01 19:27:23 -07:00
|
|
|
boardConfiguration->injectionPins[0] = GPIOE_14;
|
|
|
|
boardConfiguration->injectionPins[1] = GPIOE_13;
|
|
|
|
boardConfiguration->injectionPins[2] = GPIOE_12;
|
|
|
|
boardConfiguration->injectionPins[3] = GPIOE_11;
|
|
|
|
|
|
|
|
// Disable remainder
|
|
|
|
for (int i = 4; i < INJECTION_PIN_COUNT;i++) {
|
|
|
|
boardConfiguration->injectionPins[i] = GPIO_UNASSIGNED;
|
|
|
|
}
|
|
|
|
|
|
|
|
boardConfiguration->injectionPinMode = OM_DEFAULT;
|
|
|
|
}
|
|
|
|
|
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?
|
2019-08-01 19:27:23 -07:00
|
|
|
boardConfiguration->ignitionPins[0] = GPIOD_4;
|
|
|
|
boardConfiguration->ignitionPins[1] = GPIOD_3;
|
|
|
|
boardConfiguration->ignitionPins[2] = GPIOD_2;
|
|
|
|
boardConfiguration->ignitionPins[3] = GPIOD_1;
|
|
|
|
|
|
|
|
// disable remainder
|
|
|
|
for (int i = 4; i < IGNITION_PIN_COUNT; i++) {
|
|
|
|
boardConfiguration->ignitionPins[i] = GPIO_UNASSIGNED;
|
|
|
|
}
|
|
|
|
|
|
|
|
boardConfiguration->ignitionPinMode = OM_DEFAULT;
|
|
|
|
}
|
|
|
|
|
2019-08-04 18:56:01 -07:00
|
|
|
static void setLedPins() {
|
2019-09-09 18:34:15 -07:00
|
|
|
//engineConfiguration->atalErrorPin = GPIOE_3; // d21 = red
|
2019-08-01 19:27:23 -07:00
|
|
|
engineConfiguration->communicationLedPin = GPIOE_2; // d23 = blue
|
|
|
|
engineConfiguration->runningLedPin = GPIOE_4; // d22 = green
|
|
|
|
boardConfiguration->triggerErrorPin = GPIOE_1; // d27 = orange
|
|
|
|
}
|
|
|
|
|
2019-08-04 18:56:01 -07:00
|
|
|
static void setupVbatt() {
|
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;
|
|
|
|
|
2019-08-18 17:18:56 -07:00
|
|
|
// 39k high side/10k low side multiplied by above analogInputDividerCoefficient = 8.166666f
|
2019-08-25 19:53:57 -07:00
|
|
|
engineConfiguration->vbattDividerCoeff = (49.0f / 10.0f) * engineConfiguration->analogInputDividerCoefficient;
|
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() {
|
2019-08-01 19:27:23 -07:00
|
|
|
// Enable spi3
|
|
|
|
boardConfiguration->is_enabled_spi_3 = true;
|
|
|
|
|
|
|
|
// Wire up spi3
|
|
|
|
boardConfiguration->spi3mosiPin = GPIOB_5;
|
|
|
|
boardConfiguration->spi3misoPin = GPIOB_4;
|
|
|
|
boardConfiguration->spi3sckPin = GPIOB_3;
|
|
|
|
|
|
|
|
// Chip select
|
|
|
|
engineConfiguration->tle8888_cs = GPIOD_5;
|
|
|
|
|
|
|
|
// SPI device
|
|
|
|
engineConfiguration->tle8888spiDevice = SPI_DEVICE_3;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
boardConfiguration->etb1.controlPin1 = GPIOC_7;
|
|
|
|
// DIR pin
|
|
|
|
boardConfiguration->etb1.directionPin1 = GPIOA_8;
|
|
|
|
|
2019-08-14 22:59:15 -07:00
|
|
|
// set_fsio_output_pin 7 PC8
|
|
|
|
#if EFI_FSIO
|
2019-08-31 17:17:17 -07:00
|
|
|
// set_rpn_expression 8 "1"
|
2019-08-14 22:59:15 -07:00
|
|
|
// disable ETB by default
|
|
|
|
setFsio(7, GPIOC_8, "1" PASS_CONFIG_PARAMETER_SUFFIX);
|
|
|
|
// enable ETB
|
2019-08-31 17:17:17 -07:00
|
|
|
// set_rpn_expression 8 "0"
|
2019-08-14 22:59:15 -07:00
|
|
|
//setFsio(7, GPIOC_8, "0" PASS_CONFIG_PARAMETER_SUFFIX);
|
|
|
|
#endif /* EFI_FSIO */
|
|
|
|
|
|
|
|
|
2019-08-17 14:33:44 -07:00
|
|
|
// set_analog_input_pin pps PA7
|
|
|
|
// EFI_ADC_7: "31 - AN volt 3" - PA7
|
2019-08-14 22:59:15 -07:00
|
|
|
// engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_7;
|
|
|
|
|
2019-08-01 19:27:23 -07:00
|
|
|
// Unused
|
|
|
|
boardConfiguration->etb1.directionPin2 = GPIO_UNASSIGNED;
|
|
|
|
|
|
|
|
// we only have pwm/dir, no dira/dirb
|
|
|
|
engineConfiguration->etb1_use_two_wires = false;
|
|
|
|
|
|
|
|
engineConfiguration->etbFreq = 800;
|
|
|
|
}
|
|
|
|
|
2019-08-04 18:56:01 -07:00
|
|
|
static void setupDefaultSensorInputs() {
|
2019-08-01 19:27:23 -07:00
|
|
|
// trigger inputs
|
|
|
|
// tle8888 VR conditioner
|
|
|
|
boardConfiguration->triggerInputPins[0] = GPIOC_6;
|
|
|
|
boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED;
|
|
|
|
boardConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED;
|
|
|
|
// Direct hall-only cam input
|
|
|
|
engineConfiguration->camInputs[0] = GPIOA_5;
|
|
|
|
|
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
|
2019-08-14 22:59:15 -07:00
|
|
|
// tps = "20 - AN volt 5"
|
2019-08-01 19:27:23 -07:00
|
|
|
engineConfiguration->tps1_1AdcChannel = EFI_ADC_13;
|
|
|
|
engineConfiguration->tps2_1AdcChannel = EFI_ADC_NONE;
|
|
|
|
|
2019-09-02 14:16:36 -07:00
|
|
|
|
|
|
|
// EFI_ADC_10: "27 - AN volt 1"
|
|
|
|
engineConfiguration->map.sensor.hwChannel = EFI_ADC_10;
|
|
|
|
|
|
|
|
// EFI_ADC_2: "24 - AN temp 3"
|
|
|
|
engineConfiguration->afr.hwChannel = EFI_ADC_2;
|
|
|
|
|
2019-08-14 22:59:15 -07:00
|
|
|
// clt = "18 - AN temp 1"
|
2019-08-01 19:27:23 -07:00
|
|
|
engineConfiguration->clt.adcChannel = EFI_ADC_0;
|
|
|
|
engineConfiguration->clt.config.bias_resistor = 2700;
|
|
|
|
|
2019-08-14 22:59:15 -07:00
|
|
|
// iat = "23 - AN temp 2"
|
2019-08-01 19:27:23 -07:00
|
|
|
engineConfiguration->iat.adcChannel = EFI_ADC_1;
|
|
|
|
engineConfiguration->iat.config.bias_resistor = 2700;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setPinConfigurationOverrides(void) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void setSerialConfigurationOverrides(void) {
|
|
|
|
boardConfiguration->useSerialPort = false;
|
|
|
|
engineConfiguration->binarySerialTxPin = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->binarySerialRxPin = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->consoleSerialTxPin = GPIO_UNASSIGNED;
|
|
|
|
engineConfiguration->consoleSerialRxPin = GPIO_UNASSIGNED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Board-specific configuration code overrides.
|
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.
|
|
|
|
*/
|
|
|
|
void setBoardConfigurationOverrides(void) {
|
|
|
|
setInjectorPins();
|
|
|
|
setIgnitionPins();
|
|
|
|
setLedPins();
|
|
|
|
setupVbatt();
|
|
|
|
setupTle8888();
|
|
|
|
setupEtb();
|
|
|
|
|
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-02 08:07:34 -07:00
|
|
|
// TLE8888 half bridges (pushpull, lowside, or high-low) IN12
|
|
|
|
// GPIOE_8: "35 - GP Out 1"
|
|
|
|
boardConfiguration->fuelPumpPin = GPIOE_8;
|
|
|
|
|
2019-09-08 08:17:27 -07:00
|
|
|
|
|
|
|
// TLE8888 high current low side: VVT2 IN9 / OUT5
|
|
|
|
// GPIOE_10: "3 - Lowside 2"
|
|
|
|
boardConfiguration->idle.solenoidPin = GPIOE_10;
|
|
|
|
|
|
|
|
|
2019-09-05 20:14:28 -07:00
|
|
|
// TLE8888_PIN_22: "34 - GP Out 2"
|
|
|
|
boardConfiguration->fanPin = TLE8888_PIN_22;
|
|
|
|
|
2019-08-01 19:27:23 -07:00
|
|
|
// "required" hardware is done - set some reasonable defaults
|
|
|
|
setupDefaultSensorInputs();
|
|
|
|
|
|
|
|
// Some sensible defaults for other options
|
|
|
|
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
|
|
|
|
engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_60_2;
|
|
|
|
engineConfiguration->useOnlyRisingEdgeForTrigger = true;
|
|
|
|
setAlgorithm(LM_SPEED_DENSITY PASS_CONFIG_PARAMETER_SUFFIX);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAdcChannelOverrides(void) {
|
|
|
|
}
|