rusefi/firmware/config/boards/hellen/hellen128/board_configuration.cpp

166 lines
4.7 KiB
C++
Raw Normal View History

/**
* @file boards/hellen/hellen128/board_configuration.cpp
*
* All fabricated boards use 176 pin MCU
*
* @brief Configuration defaults for the hellen128 board
*
* See https://rusefi.com/s/hellen128
*
* @author andreika <prometheus.pcb@gmail.com>
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "pch.h"
#include "hellen_meta.h"
#include "i2c_bb.h"
2022-10-29 20:46:54 -07:00
#include "defaults.h"
2023-03-27 15:46:17 -07:00
#include "m111.h"
static void setInjectorPins() {
engineConfiguration->injectionPins[0] = H176_LS_1;
engineConfiguration->injectionPins[1] = H176_LS_2;
engineConfiguration->injectionPins[2] = H176_LS_3;
engineConfiguration->injectionPins[3] = H176_LS_4;
engineConfiguration->injectionPins[4] = H176_LS_5;
engineConfiguration->injectionPins[5] = H176_LS_6;
engineConfiguration->injectionPins[6] = H176_LS_7;
engineConfiguration->injectionPins[7] = H176_LS_8;
}
static void setIgnitionPins() {
2022-05-22 21:20:41 -07:00
engineConfiguration->ignitionPins[0] = H176_IGN_1;
engineConfiguration->ignitionPins[1] = H176_IGN_2;
engineConfiguration->ignitionPins[2] = H176_IGN_3;
engineConfiguration->ignitionPins[3] = H176_IGN_4;
engineConfiguration->ignitionPins[4] = H176_IGN_5;
engineConfiguration->ignitionPins[5] = Gpio::I5;
engineConfiguration->ignitionPins[6] = Gpio::I6;
engineConfiguration->ignitionPins[7] = Gpio::I7;
}
static void setupDefaultSensorInputs() {
// trigger inputs
engineConfiguration->triggerInputPins[0] = Gpio::B1;
engineConfiguration->triggerInputPins[1] = Gpio::Unassigned;
// Direct hall-only cam input
engineConfiguration->camInputs[0] = Gpio::A6;
2022-10-29 21:20:15 -07:00
setTPS1Inputs(EFI_ADC_4, EFI_ADC_8);
engineConfiguration->mafAdcChannel = H144_IN_MAP1;
engineConfiguration->map.sensor.hwChannel = H144_IN_MAP2;
engineConfiguration->clt.adcChannel = H144_IN_CLT;
engineConfiguration->iat.adcChannel = H144_IN_IAT;
}
static bool isFirstInvocation = true;
2022-04-28 14:12:04 -07:00
static void setHellen128ETBConfig() {
BitbangI2c m_i2c;
2023-08-13 09:33:00 -07:00
uint8_t variant[2] = {0xff, 0xff};
//same pins as for LPS25
if (isFirstInvocation) {
isFirstInvocation = false;
m_i2c.init(Gpio::B10, Gpio::B11);
}
2023-08-13 09:33:00 -07:00
// looks like we support PCF8575 i2c I/O expander
m_i2c.read(/*address*/0x20, variant, sizeof(variant));
2023-08-13 09:33:00 -07:00
efiPrintf("BoardID [%02x%02x] ", variant[0], variant[1]);
//Rev C is different then Rev A/B
if ((variant[0] == 0x63) && (variant[1] == 0x00)) {
// 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)
//ETB1
// PWM pin
engineConfiguration->etbIo[0].controlPin = H176_OUT_PWM3;
// DIR pin
engineConfiguration->etbIo[0].directionPin1 = H176_OUT_PWM2;
// Disable pin
engineConfiguration->etbIo[0].disablePin = H176_OUT_PWM1;
//ETB2
// PWM pin
engineConfiguration->etbIo[1].controlPin = Gpio::I2;
// DIR pin
engineConfiguration->etbIo[1].directionPin1 = Gpio::H13;
// Disable pin
engineConfiguration->etbIo[1].disablePin = Gpio::B7;
// we only have pwm/dir, no dira/dirb
engineConfiguration->etb_use_two_wires = false;
} else {
//Set default ETB config
engineConfiguration->etbIo[0].directionPin1 = H176_OUT_PWM2;
engineConfiguration->etbIo[0].directionPin2 = H176_OUT_PWM3;
engineConfiguration->etbIo[0].controlPin = H176_OUT_PWM1; // ETB_EN
engineConfiguration->etb_use_two_wires = true;
}
}
2023-06-05 00:01:37 -07:00
#include "hellen_leds_176.cpp"
void setBoardConfigOverrides() {
2023-12-02 10:43:21 -08:00
setHellenVbatt();
2022-06-23 06:15:51 -07:00
setHellenSdCardSpi2();
2022-06-23 06:15:51 -07:00
setHellen128ETBConfig();
2021-08-26 23:31:48 -07:00
// this specific Hellen has less common pull-up value R49
engineConfiguration->clt.config.bias_resistor = 2700;
engineConfiguration->iat.config.bias_resistor = 2700;
2023-09-17 10:48:36 -07:00
setHellenCan();
}
/**
* @brief Board-specific configuration defaults.
*
* See also setDefaultEngineConfiguration
*
* @todo Add your board-specific code, if any.
*/
void setBoardDefaultConfiguration() {
setInjectorPins();
setIgnitionPins();
engineConfiguration->enableSoftwareKnock = true;
engineConfiguration->fuelPumpPin = Gpio::D15;
engineConfiguration->idle.solenoidPin = Gpio::Unassigned;
engineConfiguration->fanPin = Gpio::D12; // OUT_PWM8
engineConfiguration->mainRelayPin = Gpio::Unassigned;
engineConfiguration->starterControlPin = H176_OUT_IO10;
engineConfiguration->startStopButtonPin = H176_IN_A16;
engineConfiguration->startStopButtonMode = PI_PULLDOWN;
// "required" hardware is done - set some reasonable defaults
setupDefaultSensorInputs();
2023-03-27 15:46:17 -07:00
setM111EngineConfiguration();
2021-09-13 18:21:18 -07:00
/**
* Jimmy best tune
* https://rusefi.com/online/view.php?msq=626
2021-09-17 18:23:54 -07:00
* md_sanci latest tune
* https://rusefi.com/online/view.php?msq=630
2021-09-13 18:21:18 -07:00
*/
2022-10-29 20:46:54 -07:00
setPPSInputs(H144_IN_PPS, EFI_ADC_14);
2023-02-11 19:44:42 -08:00
setPPSCalibration(1.49, 4.72, 1.34, 4.24);
2021-09-13 18:21:18 -07:00
engineConfiguration->vrThreshold[0].pin = Gpio::D14;
hellenWbo();
}