preparing for #974

code comments & refactoring
This commit is contained in:
rusefi 2019-10-14 16:04:28 -04:00
parent 1f4a06e993
commit 5a4c7b38cd
3 changed files with 5 additions and 8 deletions

View File

@ -53,10 +53,8 @@ FsioState::FsioState() {
void Engine::eInitializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_SUFFIX) {
#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
#if !EFI_UNIT_TEST
// we have a confusing threading model so some synchronization would not hurt
bool alreadyLocked = lockAnyContext();
#endif /* EFI_UNIT_TEST */
TRIGGER_SHAPE(initializeTriggerShape(logger,
engineConfiguration->ambiguousOperationMode,
@ -86,11 +84,9 @@ void Engine::eInitializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_SU
engine->engineCycleEventCount = TRIGGER_SHAPE(getLength());
}
#if !EFI_UNIT_TEST
if (!alreadyLocked) {
unlockAnyContext();
}
#endif /* EFI_UNIT_TEST */
if (!TRIGGER_SHAPE(shapeDefinitionError)) {
prepareOutputSignals(PASS_ENGINE_PARAMETER_SIGNATURE);

View File

@ -110,18 +110,15 @@ static bool isAveraging = false;
static void startAveraging(void *arg) {
(void) arg;
efiAssertVoid(CUSTOM_ERR_6649, getCurrentRemainingStack() > 128, "lowstck#9");
#if !EFI_UNIT_TEST
bool wasLocked = lockAnyContext();
#endif
// with locking we would have a consistent state
mapAdcAccumulator = 0;
mapMeasurementsCounter = 0;
isAveraging = true;
#if !EFI_UNIT_TEST
if (!wasLocked) {
unlockAnyContext();
}
#endif /* !EFI_UNIT_TEST */
mapAveragingPin.setHigh();
}

View File

@ -100,4 +100,8 @@ void print(const char *fmt, ...);
#define CONFIG_PARAM(x) (x)
#define lockAnyContext() false
#define unlockAnyContext() {}
#endif /* GLOBAL_H_ */