auto-sync

This commit is contained in:
rusEfi 2016-01-23 18:01:40 -05:00
parent ca8178355f
commit 8e082ebe7f
10 changed files with 98 additions and 84 deletions

View File

@ -14,10 +14,12 @@
*/ */
#include "toyota_jzs147.h" #include "toyota_jzs147.h"
#include "custom_engine.h"
EXTERN_ENGINE; EXTERN_ENGINE;
void setToyota_jzs147EngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { void setToyota_jzs147EngineConfiguration(DECLARE_ENGINE_PARAMETER_F) {
setCustomEngineConfiguration(PASS_ENGINE_PARAMETER_F); // default pinout
engineConfiguration->specs.displacement = 3.0; engineConfiguration->specs.displacement = 3.0;
engineConfiguration->specs.cylindersCount = 6; engineConfiguration->specs.cylindersCount = 6;
@ -26,6 +28,13 @@ void setToyota_jzs147EngineConfiguration(DECLARE_ENGINE_PARAMETER_F) {
setOperationMode(engineConfiguration, FOUR_STROKE_CAM_SENSOR); setOperationMode(engineConfiguration, FOUR_STROKE_CAM_SENSOR);
engineConfiguration->trigger.type = TT_2JZ; engineConfiguration->trigger.type = TT_2JZ;
boardConfiguration->ignitionPins[0] = GPIOE_14;
boardConfiguration->ignitionPins[1] = GPIOC_7;
boardConfiguration->ignitionPins[2] = GPIOC_9;
boardConfiguration->ignitionPins[3] = GPIOE_10;
boardConfiguration->ignitionPins[3] = GPIOE_10;
boardConfiguration->ignitionPins[3] = GPIOE_10;
} }

View File

@ -20,11 +20,11 @@
#include "speed_density.h" #include "speed_density.h"
#include "advance_map.h" #include "advance_map.h"
#if EFI_PROD_CODE #if EFI_PROD_CODE || defined(__DOXYGEN__)
#include "injector_central.h" #include "injector_central.h"
#else #else
#define isRunningBenchTest() true #define isRunningBenchTest() true
#endif #endif /* EFI_PROD_CODE */
static LoggingWithStorage logger("engine"); static LoggingWithStorage logger("engine");
@ -36,6 +36,25 @@ extern fuel_Map3D_t afrMap;
EXTERN_ENGINE EXTERN_ENGINE
; ;
MockAdcState::MockAdcState() {
memset(hasMockAdc, 0, sizeof(hasMockAdc));
}
#if EFI_ENABLE_MOCK_ADC || EFI_SIMULATOR
void MockAdcState::setMockVoltage(int hwChannel, float voltage) {
scheduleMsg(&logger, "fake voltage: channel %d value %f", hwChannel, voltage);
fakeAdcValues[hwChannel] = voltsToAdc(voltage);
hasMockAdc[hwChannel] = true;
}
#endif /* EFI_ENABLE_MOCK_ADC */
int MockAdcState::getMockAdcValue(int hwChannel) {
return fakeAdcValues[hwChannel];
}
/** /**
* We are executing these heavy (logarithm) methods from outside the trigger callbacks for performance reasons. * We are executing these heavy (logarithm) methods from outside the trigger callbacks for performance reasons.
* See also periodicFastCallback * See also periodicFastCallback

View File

@ -20,6 +20,18 @@
#include "accel_enrichment.h" #include "accel_enrichment.h"
#include "trigger_central.h" #include "trigger_central.h"
#define MOCK_ADC_SIZE 16
class MockAdcState {
public:
MockAdcState();
bool hasMockAdc[MOCK_ADC_SIZE];
int fakeAdcValues[MOCK_ADC_SIZE];
void setMockVoltage(int hwChannel, float voltage);
int getMockAdcValue(int hwChannel);
};
/** /**
* This class knows about when to inject fuel * This class knows about when to inject fuel
*/ */
@ -149,6 +161,9 @@ public:
floatms_t tpsAccelEnrich; floatms_t tpsAccelEnrich;
angle_t injectionOffset; angle_t injectionOffset;
// todo: surround with EFI_ENABLE_MOCK_ADC checks
MockAdcState mockAdcState;
}; };
class RpmCalculator; class RpmCalculator;

View File

@ -443,6 +443,52 @@ static void setFloat(const char *offsetStr, const char *valueStr) {
getFloat(offset); getFloat(offset);
} }
#if EFI_ENABLE_MOCK_ADC || EFI_SIMULATOR
static void setMockVoltage(int hwChannel, float voltage) {
engine->engineState.mockAdcState.setMockVoltage(hwChannel, voltage);
}
static void setCltVoltage(float voltage) {
setMockVoltage(engineConfiguration->clt.adcChannel, voltage);
}
static void setIatVoltage(float voltage) {
setMockVoltage(engineConfiguration->iat.adcChannel, voltage);
}
static void setMafVoltage(float voltage) {
setMockVoltage(engineConfiguration->mafAdcChannel, voltage);
}
static void setAfrVoltage(float voltage) {
setMockVoltage(engineConfiguration->afr.hwChannel, voltage);
}
static void setTpsVoltage(float voltage) {
setMockVoltage(engineConfiguration->tpsAdcChannel, voltage);
}
static void setMapVoltage(float voltage) {
setMockVoltage(engineConfiguration->map.sensor.hwChannel, voltage);
}
static void setVBattVoltage(float voltage) {
setMockVoltage(engineConfiguration->vbattAdcChannel, voltage);
}
static void initMockVoltage(void) {
addConsoleActionF("set_mock_clt_voltage", setCltVoltage);
addConsoleActionF("set_mock_iat_voltage", setIatVoltage);
addConsoleActionF("set_mock_maf_voltage", setMafVoltage);
addConsoleActionF("set_mock_afr_voltage", setAfrVoltage);
addConsoleActionF("set_mock_tps_voltage", setTpsVoltage);
addConsoleActionF("set_mock_map_voltage", setMapVoltage);
addConsoleActionF("set_mock_vbatt_voltage", setVBattVoltage);
}
#endif /* EFI_ENABLE_MOCK_ADC */
static void initConfigActions(void) { static void initConfigActions(void) {
addConsoleActionSS("set_float", (VoidCharPtrCharPtr) setFloat); addConsoleActionSS("set_float", (VoidCharPtrCharPtr) setFloat);
addConsoleActionII("set_int", (VoidIntInt) setInt); addConsoleActionII("set_int", (VoidIntInt) setInt);
@ -465,12 +511,13 @@ static void getKnockInfo(void) {
// this method is used by real firmware and simulator // this method is used by real firmware and simulator
void commonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S) { void commonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S) {
initConfigActions(); initConfigActions();
initMockVoltage();
#if EFI_PROD_CODE || EFI_SIMULATOR #if EFI_PROD_CODE || EFI_SIMULATOR
initSignalExecutor(); initSignalExecutor();
#endif #endif
#if EFI_PROD_CODE #if EFI_PROD_CODE || EFI_SIMULATOR
// todo: this is a mess, remove code duplication with simulator // todo: this is a mess, remove code duplication with simulator
initSettings(engineConfiguration); initSettings(engineConfiguration);
#endif #endif

View File

@ -28,20 +28,6 @@
#include "engine_sniffer.h" #include "engine_sniffer.h"
#include "adc_math.h" #include "adc_math.h"
MockAdcState::MockAdcState() {
memset(hasMockAdc, 0, sizeof(hasMockAdc));
}
void MockAdcState::setMockVoltage(int hwChannel, float voltage) {
fakeAdcValues[hwChannel] = voltsToAdc(voltage);
hasMockAdc[hwChannel] = true;
}
int MockAdcState::getMockAdcValue(int hwChannel) {
return fakeAdcValues[hwChannel];
}
#if EFI_ENGINE_SNIFFER || defined(__DOXYGEN__) #if EFI_ENGINE_SNIFFER || defined(__DOXYGEN__)
#include "engine_configuration.h" #include "engine_configuration.h"

View File

@ -11,19 +11,6 @@
#include "global.h" #include "global.h"
#define MOCK_ADC_SIZE 16
class MockAdcState {
public:
MockAdcState();
bool hasMockAdc[MOCK_ADC_SIZE];
int fakeAdcValues[MOCK_ADC_SIZE];
void setMockVoltage(int hwChannel, float voltage);
int getMockAdcValue(int hwChannel);
};
#if EFI_ENGINE_SNIFFER || defined(__DOXYGEN__) #if EFI_ENGINE_SNIFFER || defined(__DOXYGEN__)
#include "datalogging.h" #include "datalogging.h"

View File

@ -7,61 +7,14 @@
#include "main.h" #include "main.h"
#include "boards.h" #include "boards.h"
#include "engine_configuration.h" #include "engine.h"
#include "adc_math.h" #include "adc_math.h"
#include "engine_sniffer.h" #include "engine_sniffer.h"
static LoggingWithStorage logger("simulator board"); static LoggingWithStorage logger("simulator board");
extern engine_configuration_s *engineConfiguration; extern engine_configuration_s *engineConfiguration;
extern Engine *engine;
MockAdcState mockAdcState;
int getAdcValue(const char *msg, int hwChannel) { int getAdcValue(const char *msg, int hwChannel) {
return mockAdcState.getMockAdcValue(hwChannel); return engine->engineState.mockAdcState.getMockAdcValue(hwChannel);
} }
static void setVoltage(int hwChannel, float voltage) {
scheduleMsg(&logger, "fake voltage: channel %d value %f", hwChannel, voltage);
mockAdcState.setMockVoltage(hwChannel, voltage);
}
static void setCltVoltage(float voltage) {
setVoltage(engineConfiguration->clt.adcChannel, voltage);
}
static void setIatVoltage(float voltage) {
setVoltage(engineConfiguration->iat.adcChannel, voltage);
}
static void setMafVoltage(float voltage) {
setVoltage(engineConfiguration->mafAdcChannel, voltage);
}
static void setAfrVoltage(float voltage) {
setVoltage(engineConfiguration->afr.hwChannel, voltage);
}
static void setTpsVoltage(float voltage) {
setVoltage(engineConfiguration->tpsAdcChannel, voltage);
}
static void setMapVoltage(float voltage) {
setVoltage(engineConfiguration->map.sensor.hwChannel, voltage);
}
static void setVBattVoltage(float voltage) {
setVoltage(engineConfiguration->vbattAdcChannel, voltage);
}
void initFakeBoard(void) {
addConsoleActionF("set_mock_clt_voltage", setCltVoltage);
addConsoleActionF("set_mock_iat_voltage", setIatVoltage);
addConsoleActionF("set_mock_maf_voltage", setMafVoltage);
addConsoleActionF("set_mock_afr_voltage", setAfrVoltage);
addConsoleActionF("set_mock_tps_voltage", setTpsVoltage);
addConsoleActionF("set_mock_map_voltage", setMapVoltage);
addConsoleActionF("set_mock_vbatt_voltage", setVBattVoltage);
}

View File

@ -20,8 +20,6 @@
#define EFI_CONSOLE_UART_DEVICE (&testStream) #define EFI_CONSOLE_UART_DEVICE (&testStream)
int getAdcValue(const char *msg, int channel); int getAdcValue(const char *msg, int channel);
void initFakeBoard(void);
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"

View File

@ -10,6 +10,8 @@
#define EFI_ENABLE_ASSERTS TRUE #define EFI_ENABLE_ASSERTS TRUE
#define EFI_ENABLE_MOCK_ADC TRUE
#define EFI_GPIO TRUE #define EFI_GPIO TRUE
#define EFI_FSIO TRUE #define EFI_FSIO TRUE

View File

@ -73,8 +73,6 @@ void rusEfiFunctionalTest(void) {
initializeConsole(&sharedLogger); initializeConsole(&sharedLogger);
initFakeBoard();
initStatusLoop(engine); initStatusLoop(engine);
initDataStructures(PASS_ENGINE_PARAMETER_F); initDataStructures(PASS_ENGINE_PARAMETER_F);