auto-sync

This commit is contained in:
rusEfi 2016-09-22 00:03:00 -04:00
parent 53ebcf4c17
commit cc4a0af658
8 changed files with 50 additions and 45 deletions

View File

@ -141,8 +141,6 @@ typedef enum {
Force_4b_engine_type = ENUM_32_BITS,
} engine_type_e;
#define DEFAULT_ENGINE_TYPE CUSTOM_ENGINE
typedef enum {
TT_TOOTHED_WHEEL = 0,
TT_FORD_ASPIRE = 1,

View File

@ -309,42 +309,6 @@ static ALWAYS_INLINE void ignitionMathCalc(int rpm DECLARE_ENGINE_PARAMETER_S) {
uint32_t *cyccnt = (uint32_t*) &DWT->CYCCNT;
#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.
* 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);
}
if (trgEventIndex == 0) {
scheduleIgnitionAndFuelEvents(rpm, revolutionIndex PASS_ENGINE_PARAMETER);
}
/**
* 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
*/
handleSpark(limitedSpark, trgEventIndex, rpm,
handleSpark(revolutionIndex, limitedSpark, trgEventIndex, rpm,
&engine->engineConfiguration2->ignitionEvents[revolutionIndex] PASS_ENGINE_PARAMETER);
#if (EFI_HISTOGRAMS && EFI_PROD_CODE) || defined(__DOXYGEN__)
int diff = hal_lld_get_counter_value() - beforeCallback;

View File

@ -8,6 +8,7 @@
#include "engine_math.h"
#include "utlist.h"
#include "event_queue.h"
#include "efilib2.h"
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) {
if (trgEventIndex == 0) {
prepareIgnitionSchedule(rpm, revolutionIndex PASS_ENGINE_PARAMETER);
}
if (!isValidRpm(rpm) || !CONFIG(isIgnitionEnabled)) {
// this might happen for instance in case of a single trigger event after a pause
return;

View File

@ -11,7 +11,7 @@
#include "engine.h"
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);
void initSparkLogic(Logging *sharedLogger);
void turnSparkPinHigh(NamedOutputPin *output);

View File

@ -12,6 +12,8 @@
#include <hal.h>
#include <string.h>
#define DEFAULT_ENGINE_TYPE CUSTOM_ENGINE
// this is about MISRA not liking 'time.h'. todo: figure out something
#if defined __GNUC__
// GCC

View File

@ -8,6 +8,8 @@
#ifndef GLOBAL_H_
#define GLOBAL_H_
#define DEFAULT_ENGINE_TYPE CUSTOM_ENGINE
#include <time.h>
#include <string.h>
#include <stdbool.h>

View File

@ -1,4 +1,6 @@
#define DEFAULT_ENGINE_TYPE FORD_ESCORT_GT
#include <ch.h>
#include <hal.h>
#include <time.h>

View File

@ -31,7 +31,6 @@
#include "map_averaging.h"
#define DEFAULT_SIM_RPM 1200
#define DEFAULT_ENGINE_TYPE FORD_ESCORT_GT
#define DEFAULT_SNIFFER_THR 2500
EXTERN_ENGINE;