cj125 progress
This commit is contained in:
parent
742bf3f8ab
commit
89474adb63
|
@ -12,10 +12,14 @@
|
|||
#include "allsensors.h"
|
||||
#include "fsio_impl.h"
|
||||
#include "engine_configuration.h"
|
||||
#include "cj125.h"
|
||||
|
||||
EXTERN_ENGINE;
|
||||
|
||||
void vag_18_Turbo(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
/**
|
||||
* set engine_type 102
|
||||
*/
|
||||
void vag_18_Turbo(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
||||
|
||||
//Base Engine Settings
|
||||
|
||||
|
@ -53,8 +57,6 @@ void vag_18_Turbo(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
engineConfiguration->afr.hwChannel = EFI_ADC_NONE;
|
||||
engineConfiguration->vbattAdcChannel = EFI_ADC_4;
|
||||
engineConfiguration->vbattDividerCoeff = ((float) (10.0 + 33)) / 10 * 2;
|
||||
engineConfiguration->cj125ur = EFI_ADC_11;
|
||||
engineConfiguration->cj125ua = EFI_ADC_12;
|
||||
engineConfiguration->mafAdcChannel = EFI_ADC_8;
|
||||
|
||||
//CAN Settings
|
||||
|
@ -90,9 +92,10 @@ void vag_18_Turbo(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
|
||||
//SPI Settings
|
||||
engineConfiguration->is_enabled_spi_1 = true;
|
||||
engineConfiguration->is_enabled_spi_2 = true;
|
||||
engineConfiguration->is_enabled_spi_3 = false;
|
||||
engineConfiguration->cj125SpiDevice = SPI_DEVICE_2;
|
||||
|
||||
cj125defaultPinout(PASS_CONFIG_PARAMETER_SIGNATURE);
|
||||
engineConfiguration->cj125ur = EFI_ADC_11;
|
||||
engineConfiguration->cj125CsPin = GPIOB_11;
|
||||
|
||||
//Digital Inputs/Outputs
|
||||
|
@ -111,10 +114,10 @@ void vag_18_Turbo(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
engineConfiguration->brakePedalPin = GPIOE_10;
|
||||
engineConfiguration->camInputs[0] = GPIOA_2;
|
||||
#if defined(STM32_HAS_GPIOG) && STM32_HAS_GPIOG
|
||||
engineConfiguration->triggerInputPins[0] = GPIOG_7;
|
||||
// engineConfiguration->triggerInputPins[0] = GPIOG_7;
|
||||
#endif /* STM32_HAS_GPIOF */
|
||||
#if defined(STM32_HAS_GPIOF) && STM32_HAS_GPIOF
|
||||
engineConfiguration->vehicleSpeedSensorInputPin = GPIOF_14;
|
||||
// engineConfiguration->vehicleSpeedSensorInputPin = GPIOF_14;
|
||||
#endif /* STM32_HAS_GPIOF */
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* me7pnp.h
|
||||
* @file me7pnp.h
|
||||
*
|
||||
* Created on: 1. mai 2019
|
||||
* Author: Ola
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
#include "test_engine.h"
|
||||
#include "sachs.h"
|
||||
#include "vw.h"
|
||||
#include "me7pnp.h"
|
||||
#include "vw_b6.h"
|
||||
#include "daihatsu.h"
|
||||
#include "chevrolet_camaro_4.h"
|
||||
|
@ -1321,6 +1322,9 @@ void resetConfigurationExt(Logging * logger, configuration_callback_t boardCallb
|
|||
case TOYOTA_JZS147:
|
||||
setToyota_jzs147EngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
|
||||
break;
|
||||
case VAG_18_TURBO:
|
||||
vag_18_Turbo(PASS_CONFIG_PARAMETER_SIGNATURE);
|
||||
break;
|
||||
case TEST_33816:
|
||||
setTest33816EngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
|
||||
break;
|
||||
|
|
|
@ -286,7 +286,7 @@ void executeTSCommand(uint16_t subsystem, uint16_t index) {
|
|||
startIdleBench();
|
||||
#endif /* EFI_IDLE_CONTROL */
|
||||
} else if (subsystem == 0x18) {
|
||||
#if EFI_CJ125
|
||||
#if EFI_CJ125 && HAL_USE_SPI
|
||||
cjCalibrate();
|
||||
#endif /* EFI_CJ125 */
|
||||
} else if (subsystem == 0x20 && index == 0x3456) {
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
/*
|
||||
* @file CJ125.cpp
|
||||
*
|
||||
* https://github.com/rusefi/rusefi/tree/master/hardware/CJ125_board
|
||||
*
|
||||
* https://github.com/rusefi/hw_modular/tree/master/cj125_Module
|
||||
*
|
||||
* @date: Jun 24, 2016
|
||||
* @author Andrey Belomutskiy, (c) 2012-2020
|
||||
*
|
||||
|
@ -11,19 +15,17 @@
|
|||
#include "pwm_generator.h"
|
||||
#include "rpm_calculator.h"
|
||||
|
||||
EXTERN_ENGINE;
|
||||
|
||||
#if EFI_CJ125 && HAL_USE_SPI
|
||||
|
||||
#include "adc_inputs.h"
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
#include "mpu_util.h"
|
||||
#endif
|
||||
|
||||
//#define CJ125_DEBUG
|
||||
//#define CJ125_DEBUG_SPI
|
||||
|
||||
EXTERN_ENGINE;
|
||||
|
||||
#include "hardware.h"
|
||||
#include "backup_ram.h"
|
||||
#include "pin_repository.h"
|
||||
|
@ -154,10 +156,22 @@ static uint32_t get16bitFromVoltage(float v) {
|
|||
return (uint32_t)(v * CJ125_VOLTAGE_TO_16BIT_FACTOR);
|
||||
}
|
||||
|
||||
static void cjPrintState() {
|
||||
scheduleMsg(logger, "cj125: state=%d diag=0x%x (vUa=%.3f vUr=%.3f) (vUaCal=%.3f vUrCal=%.3f)",
|
||||
globalInstance.state, globalInstance.diag,
|
||||
globalInstance.vUa, globalInstance.vUr,
|
||||
globalInstance.vUaCal, globalInstance.vUrCal);
|
||||
}
|
||||
|
||||
static void cjInfo() {
|
||||
cjPrintState();
|
||||
printSpiConfig(logger, "cj125", CONFIG(cj125SpiDevice));
|
||||
}
|
||||
|
||||
static void cjPrintData(void) {
|
||||
#ifdef CJ125_DEBUG
|
||||
scheduleMsg(logger, "cj125: state=%d diag=0x%x (vUa=%.3f vUr=%.3f) (vUaCal=%.3f vUrCal=%.3f)", state, globalInstance.diag, vUa, vUr, globalInstance.vUaCal, globalInstance.vUrCal);
|
||||
#endif
|
||||
if (engineConfiguration->isCJ125Verbose) {
|
||||
cjPrintState();
|
||||
}
|
||||
}
|
||||
|
||||
static void cjPrintErrorCode(cj125_error_e errCode) {
|
||||
|
@ -320,35 +334,13 @@ void CJ125::setError(cj125_error_e errCode DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
cjWriteRegister(INIT_REG2_WR, CJ125_INIT2_RESET);
|
||||
}
|
||||
|
||||
// engineConfiguration->spi2SckMode = PAL_STM32_OTYPE_OPENDRAIN; // 4
|
||||
// engineConfiguration->spi2MosiMode = PAL_STM32_OTYPE_OPENDRAIN; // 4
|
||||
// engineConfiguration->spi2MisoMode = PAL_STM32_PUDR_PULLUP; // 32
|
||||
// CONFIG(cj125CsPin) = GPIOA_15;
|
||||
// engineConfiguration->cj125CsPinMode = OM_OPENDRAIN;
|
||||
|
||||
void cj125defaultPinout(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
engineConfiguration->cj125ua = EFI_ADC_13; // PC3
|
||||
engineConfiguration->cj125ur = EFI_ADC_4; // PA4
|
||||
CONFIG(wboHeaterPin) = GPIOC_13;
|
||||
|
||||
CONFIG(isCJ125Enabled) = false;
|
||||
|
||||
CONFIG(spi2mosiPin) = GPIOB_15;
|
||||
CONFIG(spi2misoPin) = GPIOB_14;
|
||||
CONFIG(spi2sckPin) = GPIOB_13;
|
||||
|
||||
CONFIG(cj125CsPin) = GPIOB_0;
|
||||
CONFIG(isCJ125Enabled) = true;
|
||||
CONFIG(is_enabled_spi_2) = true;
|
||||
}
|
||||
|
||||
static void cjStartSpi(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
globalInstance.cj125Cs.initPin("cj125 CS", CONFIG(cj125CsPin),
|
||||
&engineConfiguration->cj125CsPinMode);
|
||||
// Idle CS pin - SPI CS is high when idle
|
||||
globalInstance.cj125Cs.setValue(true);
|
||||
|
||||
cj125spicfg.cr1 += getSpiPrescaler(_150KHz, engineConfiguration->cj125SpiDevice);
|
||||
cj125spicfg.cr1 += getSpiPrescaler(_150KHz, CONFIG(cj125SpiDevice));
|
||||
|
||||
cj125spicfg.ssport = getHwPort("cj125", CONFIG(cj125CsPin));
|
||||
cj125spicfg.sspad = getHwPin("cj125", CONFIG(cj125CsPin));
|
||||
|
@ -357,7 +349,7 @@ static void cjStartSpi(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
// error already reported
|
||||
return;
|
||||
}
|
||||
scheduleMsg(logger, "cj125: Starting SPI driver");
|
||||
scheduleMsg(logger, "cj125: Starting SPI driver %s", getSpi_device_e(engineConfiguration->cj125SpiDevice));
|
||||
spiStart(driver, &cj125spicfg);
|
||||
}
|
||||
|
||||
|
@ -491,10 +483,12 @@ static void cjStartCalibration(void) {
|
|||
globalInstance.state = CJ125_CALIBRATION;
|
||||
}
|
||||
|
||||
static void cjStartTest(void) {
|
||||
static void cjRestart(void) {
|
||||
if (!cjCheckConfig())
|
||||
return;
|
||||
globalInstance.state = CJ125_INIT;
|
||||
globalInstance.errorCode = CJ125_NO_ERROR;
|
||||
cjInfo();
|
||||
}
|
||||
#endif /* EFI_UNIT_TEST */
|
||||
|
||||
|
@ -527,7 +521,7 @@ float cjGetAfr(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
return globalInstance.lambda * CJ125_STOICH_RATIO;
|
||||
}
|
||||
|
||||
bool cjHasAfrSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
bool cjHasAfrSensor(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
||||
if (!CONFIG(isCJ125Enabled))
|
||||
return false;
|
||||
return globalInstance.isValidState();
|
||||
|
@ -588,10 +582,34 @@ void initCJ125(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
addConsoleActionI("cj125_set_init2", cjSetInit2);
|
||||
#endif /* CJ125_DEBUG */
|
||||
|
||||
addConsoleAction("cj125", cjStartTest);
|
||||
addConsoleAction("cj125_info", cjInfo);
|
||||
addConsoleAction("cj125_restart", cjRestart);
|
||||
addConsoleAction("cj125_calibrate", cjStartCalibration);
|
||||
|
||||
chThdCreateStatic(cj125ThreadStack, sizeof(cj125ThreadStack), LOWPRIO, (tfunc_t)(void*) cjThread, NULL);
|
||||
}
|
||||
|
||||
#endif /* EFI_CJ125 && HAL_USE_SPI */
|
||||
|
||||
#if EFI_CJ125
|
||||
// engineConfiguration->spi2SckMode = PAL_STM32_OTYPE_OPENDRAIN; // 4
|
||||
// engineConfiguration->spi2MosiMode = PAL_STM32_OTYPE_OPENDRAIN; // 4
|
||||
// engineConfiguration->spi2MisoMode = PAL_STM32_PUDR_PULLUP; // 32
|
||||
// CONFIG(cj125CsPin) = GPIOA_15;
|
||||
// engineConfiguration->cj125CsPinMode = OM_OPENDRAIN;
|
||||
|
||||
void cj125defaultPinout(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
||||
engineConfiguration->cj125ua = EFI_ADC_13; // PC3
|
||||
engineConfiguration->cj125ur = EFI_ADC_4; // PA4
|
||||
CONFIG(wboHeaterPin) = GPIOC_13;
|
||||
|
||||
CONFIG(spi2mosiPin) = GPIOB_15;
|
||||
CONFIG(spi2misoPin) = GPIOB_14;
|
||||
CONFIG(spi2sckPin) = GPIOB_13;
|
||||
|
||||
CONFIG(cj125CsPin) = GPIOB_0;
|
||||
CONFIG(isCJ125Enabled) = true;
|
||||
CONFIG(is_enabled_spi_2) = true;
|
||||
CONFIG(cj125SpiDevice) = SPI_DEVICE_2;
|
||||
}
|
||||
#endif /* EFI_CJ125 */
|
||||
|
|
|
@ -106,5 +106,5 @@ void initCJ125(Logging *shared DECLARE_ENGINE_PARAMETER_SUFFIX);
|
|||
|
||||
void cjCalibrate(void);
|
||||
float cjGetAfr(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
bool cjHasAfrSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
void cj125defaultPinout();
|
||||
bool cjHasAfrSensor(DECLARE_CONFIG_PARAMETER_SIGNATURE);
|
||||
void cj125defaultPinout(DECLARE_CONFIG_PARAMETER_SIGNATURE);
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
#define EFI_IDLE_PID_CIC FALSE
|
||||
#define EFI_MAIN_RELAY_CONTROL FALSE
|
||||
#define EFI_HIP_9011 TRUE
|
||||
#define EFI_CJ125 FALSE
|
||||
#define EFI_CJ125 TRUE
|
||||
#define EFI_CAN_SUPPORT FALSE
|
||||
#define EFI_MAX_31855 FALSE
|
||||
|
||||
|
|
Loading…
Reference in New Issue