not great solution to code duplication, also helping QC build

This commit is contained in:
rusefi 2021-02-13 11:19:39 -05:00
parent f97d3b9044
commit 67f5b18f34
3 changed files with 38 additions and 18 deletions

View File

@ -13,6 +13,19 @@
#include "trigger_structure.h"
#include "trigger_central.h"
#define TRIGGER_BAIL_IF_DISABLED \
if (!engine->hwTriggerInputEnabled) { \
return; \
}
#define TRIGGER_BAIL_IF_SELF_STIM \
if (engine->directSelfStimulation) { \
/* sensor noise + self-stim = loss of trigger sync */ \
return; \
}
#define TRIGGER_SUPPORTED_CHANNELS 2
void turnOnTriggerInputPins(Logging *sharedLogger);

View File

@ -31,9 +31,11 @@ static ioline_t camLines[CAM_INPUTS_COUNT];
static void shaft_callback(void *arg) {
// do the time sensitive things as early as possible!
efitick_t stamp = getTimeNowNt();
if (!engine->hwTriggerInputEnabled) {
return;
}
TRIGGER_BAIL_IF_DISABLED
#if HW_CHECK_MODE
TRIGGER_BAIL_IF_SELF_STIM
#endif
int index = (int)arg;
ioline_t pal_line = shaftLines[index];
bool rise = (palReadLine(pal_line) == PAL_HIGH);
@ -63,9 +65,10 @@ static void shaft_callback(void *arg) {
static void cam_callback(void *arg) {
efitick_t stamp = getTimeNowNt();
if (!engine->hwTriggerInputEnabled) {
return;
}
TRIGGER_BAIL_IF_DISABLED
#if HW_CHECK_MODE
TRIGGER_BAIL_IF_SELF_STIM
#endif
int index = (int)arg;
ioline_t pal_line = camLines[index];

View File

@ -29,9 +29,10 @@ static Logging *logger;
static void vvtRisingCallback(void *arg) {
efitick_t now = getTimeNowNt();
if (!engine->hwTriggerInputEnabled) {
return;
}
TRIGGER_BAIL_IF_DISABLED
#if HW_CHECK_MODE
TRIGGER_BAIL_IF_SELF_STIM
#endif
int index = (int)arg;
#if EFI_TOOTH_LOGGER
@ -45,9 +46,10 @@ static void vvtRisingCallback(void *arg) {
static void vvtFallingCallback(void * arg) {
efitick_t now = getTimeNowNt();
if (!engine->hwTriggerInputEnabled) {
return;
}
TRIGGER_BAIL_IF_DISABLED
#if HW_CHECK_MODE
TRIGGER_BAIL_IF_SELF_STIM
#endif
int index = (int)arg;
#if EFI_TOOTH_LOGGER
if (!CONFIG(displayLogicLevelsInEngineSniffer)) {
@ -63,9 +65,10 @@ static void vvtFallingCallback(void * arg) {
static void shaftRisingCallback(bool isPrimary) {
efitick_t stamp = getTimeNowNt();
if (!engine->hwTriggerInputEnabled) {
return;
}
TRIGGER_BAIL_IF_DISABLED
#if HW_CHECK_MODE
TRIGGER_BAIL_IF_SELF_STIM
#endif
icuRisingCallbackCounter++;
// todo: support for 3rd trigger input channel
@ -82,9 +85,10 @@ static void shaftRisingCallback(bool isPrimary) {
static void shaftFallingCallback(bool isPrimary) {
efitick_t stamp = getTimeNowNt();
if (!engine->hwTriggerInputEnabled) {
return;
}
TRIGGER_BAIL_IF_DISABLED
#if HW_CHECK_MODE
TRIGGER_BAIL_IF_SELF_STIM
#endif
icuFallingCallbackCounter++;