auto-sync

This commit is contained in:
rusEfi 2014-11-14 16:03:57 -06:00
parent 9cc4efd454
commit 5b1e8c9798
7 changed files with 18 additions and 19 deletions

View File

@ -14,7 +14,7 @@
#include "global.h"
#include "bmw_e34.h"
void setBmwE43(engine_configuration_s *engineConfiguration) {
void setBmwE34(engine_configuration_s *engineConfiguration) {
engineConfiguration->rpmHardLimit = 6000;
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);

View File

@ -10,6 +10,6 @@
#include "engine_configuration.h"
void setBmwE43(engine_configuration_s *engineConfiguration);
void setBmwE34(engine_configuration_s *engineConfiguration);
#endif /* BMW_E34_H_ */

View File

@ -546,7 +546,7 @@ void resetConfigurationExt(Logging * logger, engine_type_e engineType, Engine *e
setSubaru2003Wrx(engineConfiguration, boardConfiguration);
break;
case BMW_E34:
setBmwE43(engineConfiguration);
setBmwE34(engineConfiguration);
break;
default:
firmwareError("Unexpected engine type: %d", engineType);

View File

@ -99,7 +99,6 @@ void TriggerCentral::handleShaftSignal(Engine *engine, trigger_event_e signal) {
efiAssertVoid(engine!=NULL, "configuration");
uint64_t nowNt = getTimeNowNt();
uint64_t nowUs = NT2US(nowNt);
efiAssertVoid(engine->engineConfiguration!=NULL, "engineConfiguration");
efiAssertVoid(engine->engineConfiguration2!=NULL, "engineConfiguration2");

View File

@ -338,7 +338,7 @@ void TriggerStimulatorHelper::nextStep(TriggerState *state, trigger_shape_s * sh
static void onFindIndex(TriggerState *state) {
for (int i = 0; i < PWM_PHASE_MAX_WAVE_PER_PWM; i++) {
// todo: that's not the best place for this intermediate data storage, fix it!
state->expectedTotalTime[i] = state->totalTime[i];
state->expectedTotalTime[i] = state->totalTimeNt[i];
}
}

View File

@ -24,7 +24,7 @@ public:
uint64_t getTotalEventCounter();
uint64_t getStartOfRevolutionIndex();
void nextRevolution(int triggerEventCount, uint64_t nowUs);
void nextTriggerEvent(trigger_wheel_e triggerWheel, uint64_t nowUs);
void nextTriggerEvent(trigger_wheel_e triggerWheel, uint64_t nowNt);
void decodeTriggerEvent(trigger_shape_s const*triggerShape, trigger_config_s const*triggerConfig, trigger_event_e const signal, uint64_t nowUs);
float getTriggerDutyCycle(int index);
@ -41,7 +41,7 @@ public:
/**
* Here we accumulate the amount of time this signal was ON within current trigger cycle
*/
int totalTime[PWM_PHASE_MAX_WAVE_PER_PWM];
int totalTimeNt[PWM_PHASE_MAX_WAVE_PER_PWM];
/**
* Total time result for previous trigger cycle
*/
@ -60,12 +60,12 @@ private:
* see trigger_shape_s
*/
uint32_t eventCount[PWM_PHASE_MAX_WAVE_PER_PWM];
uint64_t timeOfPreviousEvent[PWM_PHASE_MAX_WAVE_PER_PWM];
uint64_t timeOfPreviousEventNt[PWM_PHASE_MAX_WAVE_PER_PWM];
uint64_t totalEventCountBase;
uint32_t totalRevolutionCounter;
bool isFirstEvent;
uint64_t prevCycleDuration;
uint64_t startOfCycle;
uint64_t startOfCycleNt;
};
class TriggerStimulatorHelper {

View File

@ -141,9 +141,9 @@ void TriggerState::nextRevolution(int triggerEventCount, uint64_t nowNt) {
if (cycleCallback != NULL) {
cycleCallback(this);
}
memcpy(prevTotalTime, totalTime, sizeof(prevTotalTime));
prevCycleDuration = nowNt - startOfCycle;
startOfCycle = nowNt;
memcpy(prevTotalTime, totalTimeNt, sizeof(prevTotalTime));
prevCycleDuration = nowNt - startOfCycleNt;
startOfCycleNt = nowNt;
clear();
totalRevolutionCounter++;
totalEventCountBase += triggerEventCount;
@ -153,15 +153,15 @@ int TriggerState::getTotalRevolutionCounter() {
return totalRevolutionCounter;
}
void TriggerState::nextTriggerEvent(trigger_wheel_e triggerWheel, uint64_t nowUs) {
uint64_t prevTime = timeOfPreviousEvent[triggerWheel];
void TriggerState::nextTriggerEvent(trigger_wheel_e triggerWheel, uint64_t nowNt) {
uint64_t prevTime = timeOfPreviousEventNt[triggerWheel];
if (prevTime != 0) {
// even event - apply the value
totalTime[triggerWheel] += (nowUs - prevTime);
timeOfPreviousEvent[triggerWheel] = 0;
totalTimeNt[triggerWheel] += (nowNt - prevTime);
timeOfPreviousEventNt[triggerWheel] = 0;
} else {
// odd event - start accumulation
timeOfPreviousEvent[triggerWheel] = nowUs;
timeOfPreviousEventNt[triggerWheel] = nowNt;
}
current_index++;
@ -169,8 +169,8 @@ void TriggerState::nextTriggerEvent(trigger_wheel_e triggerWheel, uint64_t nowUs
void TriggerState::clear() {
memset(eventCount, 0, sizeof(eventCount));
memset(timeOfPreviousEvent, 0, sizeof(timeOfPreviousEvent));
memset(totalTime, 0, sizeof(totalTime));
memset(timeOfPreviousEventNt, 0, sizeof(timeOfPreviousEventNt));
memset(totalTimeNt, 0, sizeof(totalTimeNt));
current_index = 0;
}