auto-sync
This commit is contained in:
parent
fa0bdbf01b
commit
b1fc7a28a3
|
@ -76,7 +76,7 @@ static trigger_wheel_e eventIndex[6] = { T_PRIMARY, T_PRIMARY, T_SECONDARY, T_SE
|
||||||
|
|
||||||
#define nextTriggerEvent() \
|
#define nextTriggerEvent() \
|
||||||
{ \
|
{ \
|
||||||
efitime_t prevTime = currentCycle.timeOfPreviousEventNt[triggerWheel]; \
|
uint32_t prevTime = currentCycle.timeOfPreviousEventNt[triggerWheel]; \
|
||||||
if (prevTime != 0) { \
|
if (prevTime != 0) { \
|
||||||
/* even event - apply the value*/ \
|
/* even event - apply the value*/ \
|
||||||
currentCycle.totalTimeNt[triggerWheel] += (nowNt - prevTime); \
|
currentCycle.totalTimeNt[triggerWheel] += (nowNt - prevTime); \
|
||||||
|
|
|
@ -20,21 +20,28 @@ class TriggerState;
|
||||||
typedef void (*TriggerStateCallback)(TriggerState *);
|
typedef void (*TriggerStateCallback)(TriggerState *);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/**
|
|
||||||
* Here we accumulate the amount of time this signal was ON within current trigger cycle
|
|
||||||
*/
|
|
||||||
int totalTimeNt[PWM_PHASE_MAX_WAVE_PER_PWM];
|
|
||||||
/**
|
/**
|
||||||
* index within trigger revolution, from 0 to trigger event count
|
* index within trigger revolution, from 0 to trigger event count
|
||||||
*/
|
*/
|
||||||
uint32_t current_index;
|
uint32_t current_index;
|
||||||
/**
|
/**
|
||||||
* Number of actual events within current trigger cycle
|
* Number of actual events of each channel within current trigger cycle, these
|
||||||
|
* values are used to detect trigger signal errors.
|
||||||
* see TriggerShape
|
* see TriggerShape
|
||||||
*/
|
*/
|
||||||
uint32_t eventCount[PWM_PHASE_MAX_WAVE_PER_PWM];
|
uint32_t eventCount[PWM_PHASE_MAX_WAVE_PER_PWM];
|
||||||
efitime_t timeOfPreviousEventNt[PWM_PHASE_MAX_WAVE_PER_PWM];
|
/**
|
||||||
|
* This array is used to calculate duty cycle of each trigger channel.
|
||||||
|
* Current implementation is a bit funny - it does not really consider if an event
|
||||||
|
* is a rise or a fall, it works based on the event order within synchronization cycle.
|
||||||
|
*
|
||||||
|
* 32 bit value is good enough here, overflows will happen but they would work just fine.
|
||||||
|
*/
|
||||||
|
uint32_t timeOfPreviousEventNt[PWM_PHASE_MAX_WAVE_PER_PWM];
|
||||||
|
/**
|
||||||
|
* Here we accumulate the amount of time this signal was ON within current trigger cycle
|
||||||
|
*/
|
||||||
|
uint32_t totalTimeNt[PWM_PHASE_MAX_WAVE_PER_PWM];
|
||||||
} current_cycle_state_s;
|
} current_cycle_state_s;
|
||||||
|
|
||||||
class TriggerState {
|
class TriggerState {
|
||||||
|
@ -65,6 +72,7 @@ public:
|
||||||
current_cycle_state_s currentCycle;
|
current_cycle_state_s currentCycle;
|
||||||
/**
|
/**
|
||||||
* Total time result for previous trigger cycle
|
* Total time result for previous trigger cycle
|
||||||
|
* See totalTimeNt
|
||||||
*/
|
*/
|
||||||
uint32_t prevTotalTime[PWM_PHASE_MAX_WAVE_PER_PWM];
|
uint32_t prevTotalTime[PWM_PHASE_MAX_WAVE_PER_PWM];
|
||||||
int expectedTotalTime[PWM_PHASE_MAX_WAVE_PER_PWM];
|
int expectedTotalTime[PWM_PHASE_MAX_WAVE_PER_PWM];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.rusefi.config;
|
package com.rusefi.config;
|
||||||
|
|
||||||
// this file was generated automatically by ConfigDefinition.jar Mon Aug 31 13:06:37 EDT 2015
|
// this file was generated automatically by ConfigDefinition.jar Sat Sep 12 14:31:14 EDT 2015
|
||||||
public class Fields {
|
public class Fields {
|
||||||
public static final Field ENGINETYPE = new Field("ENGINETYPE", 0, FieldType.INT);
|
public static final Field ENGINETYPE = new Field("ENGINETYPE", 0, FieldType.INT);
|
||||||
public static final Field HEADERMAGICVALUE = new Field("HEADERMAGICVALUE", 4, FieldType.INT);
|
public static final Field HEADERMAGICVALUE = new Field("HEADERMAGICVALUE", 4, FieldType.INT);
|
||||||
|
@ -76,7 +76,7 @@ public class Fields {
|
||||||
public static final Field TPSADCCHANNEL = new Field("TPSADCCHANNEL", 524, FieldType.INT, adc_channel_e);
|
public static final Field TPSADCCHANNEL = new Field("TPSADCCHANNEL", 524, FieldType.INT, adc_channel_e);
|
||||||
public static final Field OVERRIDECRANKINGIGNITION = new Field("OVERRIDECRANKINGIGNITION", 528, FieldType.INT);
|
public static final Field OVERRIDECRANKINGIGNITION = new Field("OVERRIDECRANKINGIGNITION", 528, FieldType.INT);
|
||||||
public static final Field SENSORCHARTFREQUENCY = new Field("SENSORCHARTFREQUENCY", 532, FieldType.INT);
|
public static final Field SENSORCHARTFREQUENCY = new Field("SENSORCHARTFREQUENCY", 532, FieldType.INT);
|
||||||
public static final String[] trigger_type_e = {"custom toothed wheel", "ford aspire", "dodge neon", "Miata NA", "Miata NB", "GM_7X", "Cooper", "Mazda SOHC 4", "60/2", "36/1", "Accord CD", "MITSU", "ACCORD 2", "ACCORD DIP", "Neon 2003", "MAZDA D 1+4", "1+1", "1+60/2", "Single Tooth", "Dodge Ram 1+16", "60/2 VW", "Accord 1+24", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"};
|
public static final String[] trigger_type_e = {"custom toothed wheel", "ford aspire", "dodge neon", "Miata NA", "Miata NB", "GM_7X", "Cooper", "Mazda SOHC 4", "60/2", "36/1", "Accord CD", "MITSU", "ACCORD 2", "ACCORD DIP", "Neon 2003", "MAZDA D 1+4", "1+1", "1+60/2", "Single Tooth", "Dodge Ram 1+16", "60/2 VW", "Accord 1+24", "DODGE STRATUS", "36_2_2_2", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"};
|
||||||
public static final Field TRIGGER_TYPE = new Field("TRIGGER_TYPE", 536, FieldType.INT, trigger_type_e);
|
public static final Field TRIGGER_TYPE = new Field("TRIGGER_TYPE", 536, FieldType.INT, trigger_type_e);
|
||||||
public static final Field TRIGGER_CUSTOMISSYNCHRONIZATIONNEEDED = new Field("TRIGGER_CUSTOMISSYNCHRONIZATIONNEEDED", 540, FieldType.BIT, 0);
|
public static final Field TRIGGER_CUSTOMISSYNCHRONIZATIONNEEDED = new Field("TRIGGER_CUSTOMISSYNCHRONIZATIONNEEDED", 540, FieldType.BIT, 0);
|
||||||
public static final Field TRIGGER_CUSTOMNEEDSECONDTRIGGERINPUT = new Field("TRIGGER_CUSTOMNEEDSECONDTRIGGERINPUT", 540, FieldType.BIT, 1);
|
public static final Field TRIGGER_CUSTOMNEEDSECONDTRIGGERINPUT = new Field("TRIGGER_CUSTOMNEEDSECONDTRIGGERINPUT", 540, FieldType.BIT, 1);
|
||||||
|
|
Loading…
Reference in New Issue