auto-sync
This commit is contained in:
parent
1323b5b51a
commit
6fd9362f6d
|
@ -73,6 +73,7 @@ int warningEnabled = TRUE;
|
|||
//int warningEnabled = FALSE;
|
||||
|
||||
extern board_configuration_s *boardConfiguration;
|
||||
extern bool hasFirmwareErrorFlag;
|
||||
#define FULL_LOGGING_KEY "fl"
|
||||
|
||||
#if EFI_PROD_CODE || EFI_SIMULATOR
|
||||
|
|
|
@ -29,7 +29,9 @@ int warning(obd_code_e code, const char *fmt, ...);
|
|||
* todo: better method name?
|
||||
*/
|
||||
void firmwareError(const char *fmt, ...);
|
||||
bool hasFirmwareError(void);
|
||||
|
||||
#define hasFirmwareError() hasFirmwareErrorFlag
|
||||
|
||||
char *getFirmwareError(void);
|
||||
|
||||
/**
|
||||
|
|
|
@ -71,7 +71,7 @@ void turnPinHigh(io_pin_e pin) {
|
|||
|
||||
#if EFI_WAVE_CHART
|
||||
// explicit check here is a performance optimization to speed up no-chart mode
|
||||
if (!engineConfiguration->isDigitalChartEnabled) {
|
||||
if (engineConfiguration->isDigitalChartEnabled) {
|
||||
// this is a performance optimization - array index is cheaper then invoking a method with 'switch'
|
||||
const char *pinName = namedPinsArray[pin];
|
||||
// dbgDurr = hal_lld_get_counter_value() - dbgStart;
|
||||
|
@ -93,7 +93,7 @@ void turnPinLow(io_pin_e pin) {
|
|||
#endif /* EFI_DEFAILED_LOGGING */
|
||||
|
||||
#if EFI_WAVE_CHART
|
||||
if (!engineConfiguration->isDigitalChartEnabled) {
|
||||
if (engineConfiguration->isDigitalChartEnabled) {
|
||||
// this is a performance optimization - array index is cheaper then invoking a method with 'switch'
|
||||
const char *pinName = namedPinsArray[pin];
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ static LEElement * radiatorFanLogic;
|
|||
|
||||
extern OutputPin outputs[IO_PIN_COUNT];
|
||||
extern pin_output_mode_e *pinDefaultState[IO_PIN_COUNT];
|
||||
|
||||
extern bool hasFirmwareErrorFlag;
|
||||
|
||||
persistent_config_container_s persistentState CCM_OPTIONAL;
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
EXTERN_ENGINE;
|
||||
|
||||
extern bool hasFirmwareErrorFlag;
|
||||
|
||||
#define LCD_WIDTH 20
|
||||
// this value should be even
|
||||
#define NUMBER_OF_DIFFERENT_LINES 4
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
#include "event_registry.h"
|
||||
#include "efiGpio.h"
|
||||
|
||||
EXTERN_ENGINE;
|
||||
EXTERN_ENGINE
|
||||
;
|
||||
|
||||
/*
|
||||
* default Volumetric Efficiency
|
||||
|
@ -40,7 +41,6 @@ EXTERN_ENGINE;
|
|||
// return interpolate(5000, 1.1, 8000, 1, rpm);
|
||||
// return interpolate(500, 0.5, 5000, 1.1, rpm);
|
||||
//}
|
||||
|
||||
/**
|
||||
* @return number of milliseconds in one crankshaft revolution
|
||||
*/
|
||||
|
@ -53,7 +53,7 @@ float getCrankshaftRevolutionTimeMs(int rpm) {
|
|||
* TODO: should be 'crankAngleRange' range?
|
||||
*/
|
||||
float fixAngle(float angle DECLARE_ENGINE_PARAMETER_S) {
|
||||
efiAssert(engineConfiguration->engineCycle!=0, "engine cycle", NAN);
|
||||
efiAssert(engineConfiguration->engineCycle != 0, "engine cycle", NAN);
|
||||
// I guess this implementation would be faster than 'angle % 720'
|
||||
while (angle < 0)
|
||||
angle += engineConfiguration->engineCycle;
|
||||
|
@ -101,14 +101,10 @@ void setSingleCoilDwell(engine_configuration_s *engineConfiguration) {
|
|||
engineConfiguration->sparkDwell[7] = 0;
|
||||
}
|
||||
|
||||
int isCrankingRT(engine_configuration_s *engineConfiguration, int rpm) {
|
||||
return rpm > 0 && rpm < engineConfiguration->crankingSettings.crankingRpm;
|
||||
}
|
||||
|
||||
OutputSignalList injectonSignals CCM_OPTIONAL;
|
||||
|
||||
static void registerSparkEvent(trigger_shape_s * s,
|
||||
IgnitionEventList *list, io_pin_e pin, float localAdvance, float dwell DECLARE_ENGINE_PARAMETER_S) {
|
||||
static void registerSparkEvent(trigger_shape_s * s, IgnitionEventList *list, io_pin_e pin, float localAdvance,
|
||||
float dwell DECLARE_ENGINE_PARAMETER_S) {
|
||||
|
||||
IgnitionEvent *event = list->getNextActuatorEvent();
|
||||
if (event == NULL)
|
||||
|
@ -125,8 +121,8 @@ static void registerSparkEvent(trigger_shape_s * s,
|
|||
findTriggerPosition(s, &event->dwellPosition, localAdvance - dwell PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
|
||||
void initializeIgnitionActions(float advance, float dwellAngle,
|
||||
engine_configuration2_s *engineConfiguration2, IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) {
|
||||
void initializeIgnitionActions(float advance, float dwellAngle, engine_configuration2_s *engineConfiguration2,
|
||||
IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) {
|
||||
|
||||
efiAssertVoid(engineConfiguration->cylindersCount > 0, "cylindersCount");
|
||||
|
||||
|
@ -136,15 +132,17 @@ void initializeIgnitionActions(float advance, float dwellAngle,
|
|||
case IM_ONE_COIL:
|
||||
for (int i = 0; i < engineConfiguration->cylindersCount; i++) {
|
||||
// todo: extract method
|
||||
float localAdvance = advance + (float) engineConfiguration->engineCycle * i / engineConfiguration->cylindersCount;
|
||||
float localAdvance = advance
|
||||
+ (float) engineConfiguration->engineCycle * i / engineConfiguration->cylindersCount;
|
||||
|
||||
registerSparkEvent(&engineConfiguration2->triggerShape, list, SPARKOUT_1_OUTPUT,
|
||||
localAdvance, dwellAngle PASS_ENGINE_PARAMETER);
|
||||
registerSparkEvent(&engineConfiguration2->triggerShape, list, SPARKOUT_1_OUTPUT, localAdvance,
|
||||
dwellAngle PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
break;
|
||||
case IM_WASTED_SPARK:
|
||||
for (int i = 0; i < engineConfiguration->cylindersCount; i++) {
|
||||
float localAdvance = advance + (float) engineConfiguration->engineCycle * i / engineConfiguration->cylindersCount;
|
||||
float localAdvance = advance
|
||||
+ (float) engineConfiguration->engineCycle * i / engineConfiguration->cylindersCount;
|
||||
|
||||
int wastedIndex = i % (engineConfiguration->cylindersCount / 2);
|
||||
|
||||
|
@ -159,7 +157,8 @@ void initializeIgnitionActions(float advance, float dwellAngle,
|
|||
break;
|
||||
case IM_INDIVIDUAL_COILS:
|
||||
for (int i = 0; i < engineConfiguration->cylindersCount; i++) {
|
||||
float localAdvance = advance + (float) engineConfiguration->engineCycle * i / engineConfiguration->cylindersCount;
|
||||
float localAdvance = advance
|
||||
+ (float) engineConfiguration->engineCycle * i / engineConfiguration->cylindersCount;
|
||||
|
||||
io_pin_e pin = (io_pin_e) ((int) SPARKOUT_1_OUTPUT + getCylinderId(engineConfiguration->firingOrder, i) - 1);
|
||||
registerSparkEvent(&engineConfiguration2->triggerShape, list, pin, localAdvance,
|
||||
|
@ -172,8 +171,8 @@ void initializeIgnitionActions(float advance, float dwellAngle,
|
|||
}
|
||||
}
|
||||
|
||||
void FuelSchedule::registerInjectionEvent(trigger_shape_s *s,
|
||||
io_pin_e pin, float angle, bool_t isSimultanious DECLARE_ENGINE_PARAMETER_S) {
|
||||
void FuelSchedule::registerInjectionEvent(trigger_shape_s *s, io_pin_e pin, float angle,
|
||||
bool_t isSimultanious DECLARE_ENGINE_PARAMETER_S) {
|
||||
ActuatorEventList *list = &events;
|
||||
|
||||
if (!isSimultanious && !isPinAssigned(pin)) {
|
||||
|
@ -206,10 +205,9 @@ void FuelSchedule::clear() {
|
|||
memset(hasEvents, 0, sizeof(hasEvents));
|
||||
}
|
||||
|
||||
void FuelSchedule::addFuelEvents(trigger_shape_s *s,
|
||||
injection_mode_e mode DECLARE_ENGINE_PARAMETER_S) {
|
||||
void FuelSchedule::addFuelEvents(trigger_shape_s *s, injection_mode_e mode DECLARE_ENGINE_PARAMETER_S) {
|
||||
ActuatorEventList *list = &events;
|
||||
;
|
||||
;
|
||||
list->resetEventList();
|
||||
|
||||
float baseAngle = engineConfiguration->globalTriggerAngleOffset + engineConfiguration->injectionOffset;
|
||||
|
@ -218,13 +216,15 @@ void FuelSchedule::addFuelEvents(trigger_shape_s *s,
|
|||
case IM_SEQUENTIAL:
|
||||
for (int i = 0; i < engineConfiguration->cylindersCount; i++) {
|
||||
io_pin_e pin = INJECTOR_PIN_BY_INDEX(getCylinderId(engineConfiguration->firingOrder, i) - 1);
|
||||
float angle = baseAngle + (float) engineConfiguration->engineCycle * i / engineConfiguration->cylindersCount;
|
||||
float angle = baseAngle
|
||||
+ (float) engineConfiguration->engineCycle * i / engineConfiguration->cylindersCount;
|
||||
registerInjectionEvent(s, pin, angle, false PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
break;
|
||||
case IM_SIMULTANEOUS:
|
||||
for (int i = 0; i < engineConfiguration->cylindersCount; i++) {
|
||||
float angle = baseAngle + (float) engineConfiguration->engineCycle * i / engineConfiguration->cylindersCount;
|
||||
float angle = baseAngle
|
||||
+ (float) engineConfiguration->engineCycle * i / engineConfiguration->cylindersCount;
|
||||
|
||||
/**
|
||||
* We do not need injector pin here because we will control all injectors
|
||||
|
@ -237,7 +237,8 @@ void FuelSchedule::addFuelEvents(trigger_shape_s *s,
|
|||
for (int i = 0; i < engineConfiguration->cylindersCount; i++) {
|
||||
int index = i % (engineConfiguration->cylindersCount / 2);
|
||||
io_pin_e pin = INJECTOR_PIN_BY_INDEX(index);
|
||||
float angle = baseAngle + i * (float) engineConfiguration->engineCycle / engineConfiguration->cylindersCount;
|
||||
float angle = baseAngle
|
||||
+ i * (float) engineConfiguration->engineCycle / engineConfiguration->cylindersCount;
|
||||
registerInjectionEvent(s, pin, angle, false PASS_ENGINE_PARAMETER);
|
||||
|
||||
/**
|
||||
|
@ -257,12 +258,12 @@ void FuelSchedule::addFuelEvents(trigger_shape_s *s,
|
|||
*/
|
||||
float getSparkDwellMsT(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||
if (isCrankingR(rpm)) {
|
||||
if(engineConfiguration->useConstantDwellDuringCranking) {
|
||||
if (engineConfiguration->useConstantDwellDuringCranking) {
|
||||
return engineConfiguration->ignitionDwellForCrankingMs;
|
||||
} else {
|
||||
// technically this could be implemented via interpolate2d
|
||||
float angle = engineConfiguration->crankingChargeAngle;
|
||||
return getOneDegreeTimeMs(rpm) * angle;
|
||||
// technically this could be implemented via interpolate2d
|
||||
float angle = engineConfiguration->crankingChargeAngle;
|
||||
return getOneDegreeTimeMs(rpm) * angle;
|
||||
}
|
||||
}
|
||||
efiAssert(!cisnan(rpm), "invalid rpm", NAN);
|
||||
|
@ -282,8 +283,8 @@ int getEngineCycleEventCount(engine_configuration_s const *engineConfiguration,
|
|||
return getEngineCycleEventCount2(getOperationMode(engineConfiguration), s);
|
||||
}
|
||||
|
||||
void findTriggerPosition(trigger_shape_s * s,
|
||||
event_trigger_position_s *position, float angleOffset DECLARE_ENGINE_PARAMETER_S) {
|
||||
void findTriggerPosition(trigger_shape_s * s, event_trigger_position_s *position,
|
||||
float angleOffset DECLARE_ENGINE_PARAMETER_S) {
|
||||
|
||||
angleOffset = fixAngle(angleOffset + engineConfiguration->globalTriggerAngleOffset PASS_ENGINE_PARAMETER);
|
||||
|
||||
|
@ -359,18 +360,18 @@ int getCylinderId(firing_order_e firingOrder, int index) {
|
|||
void prepareOutputSignals(Engine *engine) {
|
||||
|
||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
|
||||
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
|
||||
|
||||
// todo: move this reset into decoder
|
||||
engineConfiguration2->triggerShape.calculateTriggerSynchPoint(engineConfiguration, &engineConfiguration->triggerConfig, engine);
|
||||
engineConfiguration2->triggerShape.calculateTriggerSynchPoint(engineConfiguration,
|
||||
&engineConfiguration->triggerConfig, engine);
|
||||
|
||||
trigger_shape_s * ts = &engineConfiguration2->triggerShape;
|
||||
|
||||
injectonSignals.clear();
|
||||
engineConfiguration2->crankingInjectionEvents.addFuelEvents(ts,
|
||||
engineConfiguration->crankingInjectionMode PASS_ENGINE_PARAMETER);
|
||||
engineConfiguration2->injectionEvents.addFuelEvents(ts,
|
||||
engineConfiguration->injectionMode PASS_ENGINE_PARAMETER);
|
||||
engineConfiguration2->injectionEvents.addFuelEvents(ts, engineConfiguration->injectionMode PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
|
||||
void setFuelRpmBin(engine_configuration_s *engineConfiguration, float l, float r) {
|
||||
|
|
|
@ -53,8 +53,7 @@ inline float getOneDegreeTimeMs(int rpm) {
|
|||
|
||||
float getCrankshaftRevolutionTimeMs(int rpm);
|
||||
|
||||
int isCrankingRT(engine_configuration_s *engineConfiguration, int rpm);
|
||||
#define isCrankingR(rpm) isCrankingRT(engineConfiguration, rpm)
|
||||
#define isCrankingR(rpm) ((rpm) > 0 && (rpm) < engineConfiguration->crankingSettings.crankingRpm)
|
||||
|
||||
float getEngineLoadT(Engine *engine);
|
||||
#define getEngineLoad() getEngineLoadT(engine)
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
|
||||
EXTERN_ENGINE
|
||||
;
|
||||
extern bool hasFirmwareErrorFlag;
|
||||
|
||||
static LocalVersionHolder localVersion;
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ extern "C" {
|
|||
}
|
||||
#include "trigger_emulator.h"
|
||||
|
||||
extern bool hasFirmwareErrorFlag;
|
||||
|
||||
static THD_WORKING_AREA(eeThreadStack, UTILITY_THREAD_STACK_SIZE);
|
||||
|
||||
#define DIAG_PORT GPIOD
|
||||
|
|
|
@ -31,6 +31,7 @@ EXTERN_ENGINE;
|
|||
#define MAX_ICU_COUNT 5
|
||||
|
||||
extern WaveChart waveChart;
|
||||
extern bool hasFirmwareErrorFlag;
|
||||
|
||||
/**
|
||||
* Difference between current 1st trigger event and previous 1st trigger event.
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "ec2.h"
|
||||
|
||||
extern engine_configuration2_s * engineConfiguration2;
|
||||
extern bool hasFirmwareErrorFlag;
|
||||
|
||||
static bool isSpiInitialized[5] = { false, false, false, false, false };
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ int main_loop_started = FALSE;
|
|||
|
||||
static MemoryStream firmwareErrorMessageStream;
|
||||
uint8_t errorMessageBuffer[200];
|
||||
static bool hasFirmwareErrorFlag = FALSE;
|
||||
bool hasFirmwareErrorFlag = false;
|
||||
extern engine_configuration_s *engineConfiguration;
|
||||
extern board_configuration_s *boardConfiguration;
|
||||
extern engine_configuration2_s *engineConfiguration2;
|
||||
|
@ -231,11 +231,6 @@ void chDbgStackOverflowPanic(Thread *otp) {
|
|||
chDbgPanic3(panicMessage, __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
// todo: make this a macro, noone can trust these compilers
|
||||
bool hasFirmwareError(void) {
|
||||
return hasFirmwareErrorFlag;
|
||||
}
|
||||
|
||||
// todo: why is this method here and not in error_handling.c ?
|
||||
void firmwareError(const char *fmt, ...) {
|
||||
if (hasFirmwareErrorFlag)
|
||||
|
|
|
@ -144,9 +144,7 @@ int warning(obd_code_e code, const char *fmt, ...) {
|
|||
printf("Warning: %s\r\n", fmt);
|
||||
}
|
||||
|
||||
bool hasFirmwareError(void) {
|
||||
return false;
|
||||
}
|
||||
bool hasFirmwareErrorFlag = false;
|
||||
|
||||
void firmwareError(const char *fmt, ...) {
|
||||
printf(fmt);
|
||||
|
|
|
@ -103,9 +103,7 @@ bool isConsoleReady(void) {
|
|||
return isSerialOverTcpReady;
|
||||
}
|
||||
|
||||
bool_t hasFirmwareError(void) {
|
||||
return FALSE;
|
||||
}
|
||||
bool hasFirmwareErrorFlag = false;
|
||||
|
||||
void onFatalError(const char *msg, const char * file, int line) {
|
||||
printf("onFatalError %s %s%d", msg, file, line);
|
||||
|
|
Loading…
Reference in New Issue