trigger refactoring
This commit is contained in:
parent
6e128a341b
commit
282cd8e1ac
|
@ -127,7 +127,8 @@ void calculateTriggerSynchPoint(TriggerWaveform *shape, TriggerState *state DECL
|
|||
#endif
|
||||
trigger_config_s const*triggerConfig = &engineConfiguration->trigger;
|
||||
|
||||
shape->triggerShapeSynchPointIndex = state->findTriggerZeroEventIndex(shape, triggerConfig PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
engine->triggerErrorDetection.clear();
|
||||
shape->triggerShapeSynchPointIndex = state->findTriggerZeroEventIndex(shape, triggerConfig PASS_CONFIG_PARAMETER_SUFFIX);
|
||||
|
||||
int length = shape->getLength();
|
||||
engine->engineCycleEventCount = length;
|
||||
|
@ -671,12 +672,11 @@ static void onFindIndexCallback(TriggerState *state) {
|
|||
* This function finds the index of synchronization event within TriggerWaveform
|
||||
*/
|
||||
uint32_t TriggerState::findTriggerZeroEventIndex(TriggerWaveform * shape,
|
||||
trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
trigger_config_s const*triggerConfig DECLARE_CONFIG_PARAMETER_SUFFIX) {
|
||||
UNUSED(triggerConfig);
|
||||
#if EFI_PROD_CODE
|
||||
efiAssert(CUSTOM_ERR_ASSERT, getCurrentRemainingStack() > 128, "findPos", -1);
|
||||
#endif
|
||||
engine->triggerErrorDetection.clear();
|
||||
|
||||
|
||||
resetTriggerState();
|
||||
|
@ -689,7 +689,7 @@ uint32_t TriggerState::findTriggerZeroEventIndex(TriggerWaveform * shape,
|
|||
// todo: should this variable be declared 'static' to reduce stack usage?
|
||||
TriggerStimulatorHelper helper;
|
||||
|
||||
uint32_t syncIndex = helper.findTriggerSyncPoint(shape, this PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
uint32_t syncIndex = helper.findTriggerSyncPoint(shape, this PASS_CONFIG_PARAMETER_SUFFIX);
|
||||
if (syncIndex == EFI_ERROR_CODE) {
|
||||
return syncIndex;
|
||||
}
|
||||
|
|
|
@ -118,7 +118,8 @@ public:
|
|||
*/
|
||||
efitick_t startOfCycleNt;
|
||||
|
||||
uint32_t findTriggerZeroEventIndex(TriggerWaveform * shape, trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
uint32_t findTriggerZeroEventIndex(TriggerWaveform * shape, trigger_config_s const*triggerConfig
|
||||
DECLARE_CONFIG_PARAMETER_SUFFIX);
|
||||
|
||||
private:
|
||||
void resetCurrentCycleState();
|
||||
|
|
|
@ -121,14 +121,15 @@ void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(const TriggerSta
|
|||
* @return trigger synchronization point index, or error code if not found
|
||||
*/
|
||||
uint32_t TriggerStimulatorHelper::findTriggerSyncPoint(TriggerWaveform * shape,
|
||||
TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
TriggerState *state DECLARE_CONFIG_PARAMETER_SUFFIX) {
|
||||
for (int i = 0; i < 4 * PWM_PHASE_MAX_COUNT; i++) {
|
||||
feedSimulatedEvent(nullptr, state, shape, i PASS_CONFIG_PARAMETER_SUFFIX);
|
||||
|
||||
if (state->shaft_is_synchronized)
|
||||
if (state->shaft_is_synchronized) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
engine->triggerCentral.triggerShape.setShapeDefinitionError(true);
|
||||
shape->setShapeDefinitionError(true);
|
||||
warning(CUSTOM_ERR_TRIGGER_SYNC, "findTriggerZeroEventIndex() failed");
|
||||
return EFI_ERROR_CODE;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class TriggerStimulatorHelper {
|
|||
public:
|
||||
|
||||
uint32_t findTriggerSyncPoint(TriggerWaveform * shape,
|
||||
TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
TriggerState *state DECLARE_CONFIG_PARAMETER_SUFFIX);
|
||||
|
||||
void assertSyncPositionAndSetDutyCycle(const TriggerStateCallback triggerCycleCallback,
|
||||
const uint32_t index, TriggerState *state, TriggerWaveform * shape
|
||||
|
|
|
@ -41,7 +41,8 @@ static int getTriggerZeroEventIndex(engine_type_e engineType) {
|
|||
initDataStructures(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
TriggerWaveform * shape = ð.engine.triggerCentral.triggerShape;
|
||||
return eth.engine.triggerCentral.triggerState.findTriggerZeroEventIndex(shape, &engineConfiguration->trigger PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
return eth.engine.triggerCentral.triggerState.findTriggerZeroEventIndex(shape, &engineConfiguration->trigger
|
||||
PASS_CONFIG_PARAMETER_SUFFIX);
|
||||
}
|
||||
|
||||
static void testDodgeNeonDecoder(void) {
|
||||
|
|
Loading…
Reference in New Issue