auto-sync
This commit is contained in:
parent
e2f78be75d
commit
835ee84546
|
@ -141,8 +141,6 @@ typedef enum {
|
||||||
Force_4b_engine_type = ENUM_32_BITS,
|
Force_4b_engine_type = ENUM_32_BITS,
|
||||||
} engine_type_e;
|
} engine_type_e;
|
||||||
|
|
||||||
#define DEFAULT_ENGINE_TYPE CUSTOM_ENGINE
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TT_TOOTHED_WHEEL = 0,
|
TT_TOOTHED_WHEEL = 0,
|
||||||
TT_FORD_ASPIRE = 1,
|
TT_FORD_ASPIRE = 1,
|
||||||
|
|
|
@ -309,42 +309,6 @@ static ALWAYS_INLINE void ignitionMathCalc(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||||
uint32_t *cyccnt = (uint32_t*) &DWT->CYCCNT;
|
uint32_t *cyccnt = (uint32_t*) &DWT->CYCCNT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static ALWAYS_INLINE void scheduleIgnitionAndFuelEvents(int rpm, int revolutionIndex DECLARE_ENGINE_PARAMETER_S) {
|
|
||||||
|
|
||||||
engine->m.beforeIgnitionSch = GET_TIMESTAMP();
|
|
||||||
/**
|
|
||||||
* TODO: warning. there is a bit of a hack here, todo: improve.
|
|
||||||
* currently output signals/times signalTimerUp from the previous revolutions could be
|
|
||||||
* still used because they have crossed the revolution boundary
|
|
||||||
* but we are already re-purposing the output signals, but everything works because we
|
|
||||||
* are not affecting that space in memory. todo: use two instances of 'ignitionSignals'
|
|
||||||
*/
|
|
||||||
float maxAllowedDwellAngle = (int) (getEngineCycle(engineConfiguration->operationMode) / 2); // the cast is about making Coverity happy
|
|
||||||
|
|
||||||
if (engineConfiguration->ignitionMode == IM_ONE_COIL) {
|
|
||||||
maxAllowedDwellAngle = getEngineCycle(engineConfiguration->operationMode) / engineConfiguration->specs.cylindersCount / 1.1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (engine->engineState.dwellAngle == 0) {
|
|
||||||
warning(CUSTOM_OBD_32, "dwell is zero?");
|
|
||||||
}
|
|
||||||
if (engine->engineState.dwellAngle > maxAllowedDwellAngle) {
|
|
||||||
warning(CUSTOM_OBD_33, "dwell angle too long: %f", engine->engineState.dwellAngle);
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo: add some check for dwell overflow? like 4 times 6 ms while engine cycle is less then that
|
|
||||||
|
|
||||||
IgnitionEventList *list = &engine->engineConfiguration2->ignitionEvents[revolutionIndex];
|
|
||||||
|
|
||||||
if (cisnan(ENGINE(engineState.timingAdvance))) {
|
|
||||||
// error should already be reported
|
|
||||||
list->reset(); // reset is needed to clear previous ignition schedule
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
initializeIgnitionActions(ENGINE(engineState.timingAdvance), ENGINE(engineState.dwellAngle), list PASS_ENGINE_PARAMETER);
|
|
||||||
engine->m.ignitionSchTime = GET_TIMESTAMP() - engine->m.beforeIgnitionSch;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the main trigger event handler.
|
* This is the main trigger event handler.
|
||||||
* Both injection and ignition are controlled from this method.
|
* Both injection and ignition are controlled from this method.
|
||||||
|
@ -429,9 +393,6 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D
|
||||||
ENGINE(m.ignitionMathTime) = GET_TIMESTAMP() - ENGINE(m.beforeIgnitionMath);
|
ENGINE(m.ignitionMathTime) = GET_TIMESTAMP() - ENGINE(m.beforeIgnitionMath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trgEventIndex == 0) {
|
|
||||||
scheduleIgnitionAndFuelEvents(rpm, revolutionIndex PASS_ENGINE_PARAMETER);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For fuel we schedule start of injection based on trigger angle, and then inject for
|
* For fuel we schedule start of injection based on trigger angle, and then inject for
|
||||||
|
@ -441,7 +402,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D
|
||||||
/**
|
/**
|
||||||
* For spark we schedule both start of coil charge and actual spark based on trigger angle
|
* For spark we schedule both start of coil charge and actual spark based on trigger angle
|
||||||
*/
|
*/
|
||||||
handleSpark(limitedSpark, trgEventIndex, rpm,
|
handleSpark(revolutionIndex, limitedSpark, trgEventIndex, rpm,
|
||||||
&engine->engineConfiguration2->ignitionEvents[revolutionIndex] PASS_ENGINE_PARAMETER);
|
&engine->engineConfiguration2->ignitionEvents[revolutionIndex] PASS_ENGINE_PARAMETER);
|
||||||
#if (EFI_HISTOGRAMS && EFI_PROD_CODE) || defined(__DOXYGEN__)
|
#if (EFI_HISTOGRAMS && EFI_PROD_CODE) || defined(__DOXYGEN__)
|
||||||
int diff = hal_lld_get_counter_value() - beforeCallback;
|
int diff = hal_lld_get_counter_value() - beforeCallback;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "engine_math.h"
|
#include "engine_math.h"
|
||||||
#include "utlist.h"
|
#include "utlist.h"
|
||||||
#include "event_queue.h"
|
#include "event_queue.h"
|
||||||
|
#include "efilib2.h"
|
||||||
|
|
||||||
EXTERN_ENGINE;
|
EXTERN_ENGINE;
|
||||||
|
|
||||||
|
@ -116,8 +117,48 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSpark(bool limitedSpark, uint32_t trgEventIndex, int rpm,
|
static ALWAYS_INLINE void prepareIgnitionSchedule(int rpm, int revolutionIndex DECLARE_ENGINE_PARAMETER_S) {
|
||||||
|
|
||||||
|
engine->m.beforeIgnitionSch = GET_TIMESTAMP();
|
||||||
|
/**
|
||||||
|
* TODO: warning. there is a bit of a hack here, todo: improve.
|
||||||
|
* currently output signals/times signalTimerUp from the previous revolutions could be
|
||||||
|
* still used because they have crossed the revolution boundary
|
||||||
|
* but we are already re-purposing the output signals, but everything works because we
|
||||||
|
* are not affecting that space in memory. todo: use two instances of 'ignitionSignals'
|
||||||
|
*/
|
||||||
|
float maxAllowedDwellAngle = (int) (getEngineCycle(engineConfiguration->operationMode) / 2); // the cast is about making Coverity happy
|
||||||
|
|
||||||
|
if (engineConfiguration->ignitionMode == IM_ONE_COIL) {
|
||||||
|
maxAllowedDwellAngle = getEngineCycle(engineConfiguration->operationMode) / engineConfiguration->specs.cylindersCount / 1.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (engine->engineState.dwellAngle == 0) {
|
||||||
|
warning(CUSTOM_OBD_32, "dwell is zero?");
|
||||||
|
}
|
||||||
|
if (engine->engineState.dwellAngle > maxAllowedDwellAngle) {
|
||||||
|
warning(CUSTOM_OBD_33, "dwell angle too long: %f", engine->engineState.dwellAngle);
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo: add some check for dwell overflow? like 4 times 6 ms while engine cycle is less then that
|
||||||
|
|
||||||
|
IgnitionEventList *list = &engine->engineConfiguration2->ignitionEvents[revolutionIndex];
|
||||||
|
|
||||||
|
if (cisnan(ENGINE(engineState.timingAdvance))) {
|
||||||
|
// error should already be reported
|
||||||
|
list->reset(); // reset is needed to clear previous ignition schedule
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
initializeIgnitionActions(ENGINE(engineState.timingAdvance), ENGINE(engineState.dwellAngle), list PASS_ENGINE_PARAMETER);
|
||||||
|
engine->m.ignitionSchTime = GET_TIMESTAMP() - engine->m.beforeIgnitionSch;
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleSpark(int revolutionIndex, bool limitedSpark, uint32_t trgEventIndex, int rpm,
|
||||||
IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) {
|
IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) {
|
||||||
|
if (trgEventIndex == 0) {
|
||||||
|
prepareIgnitionSchedule(rpm, revolutionIndex PASS_ENGINE_PARAMETER);
|
||||||
|
}
|
||||||
|
|
||||||
if (!isValidRpm(rpm) || !CONFIG(isIgnitionEnabled)) {
|
if (!isValidRpm(rpm) || !CONFIG(isIgnitionEnabled)) {
|
||||||
// this might happen for instance in case of a single trigger event after a pause
|
// this might happen for instance in case of a single trigger event after a pause
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
int isInjectionEnabled(engine_configuration_s *engineConfiguration);
|
int isInjectionEnabled(engine_configuration_s *engineConfiguration);
|
||||||
void handleSpark(bool limitedSpark, uint32_t trgEventIndex, int rpm,
|
void handleSpark(int revolutionIndex, bool limitedSpark, uint32_t trgEventIndex, int rpm,
|
||||||
IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S);
|
IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S);
|
||||||
void initSparkLogic(Logging *sharedLogger);
|
void initSparkLogic(Logging *sharedLogger);
|
||||||
void turnSparkPinHigh(NamedOutputPin *output);
|
void turnSparkPinHigh(NamedOutputPin *output);
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include <hal.h>
|
#include <hal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#define DEFAULT_ENGINE_TYPE CUSTOM_ENGINE
|
||||||
|
|
||||||
// this is about MISRA not liking 'time.h'. todo: figure out something
|
// this is about MISRA not liking 'time.h'. todo: figure out something
|
||||||
#if defined __GNUC__
|
#if defined __GNUC__
|
||||||
// GCC
|
// GCC
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#ifndef GLOBAL_H_
|
#ifndef GLOBAL_H_
|
||||||
#define GLOBAL_H_
|
#define GLOBAL_H_
|
||||||
|
|
||||||
|
#define DEFAULT_ENGINE_TYPE CUSTOM_ENGINE
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
Loading…
Reference in New Issue