Minor fixes (#1437)
* cmpilation warning cleanup * exti trigger: mark pins used, handle errors
This commit is contained in:
parent
18760bb699
commit
e3fd0a186a
|
@ -130,8 +130,6 @@ static void cylinderCleanupControl(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static efitick_t tle8888CrankingResetTime = 0;
|
|
||||||
|
|
||||||
void Engine::periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
void Engine::periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
ScopePerf perf(PE::EnginePeriodicSlowCallback);
|
ScopePerf perf(PE::EnginePeriodicSlowCallback);
|
||||||
|
|
||||||
|
@ -152,6 +150,8 @@ void Engine::periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
standardAirCharge = getStandardAirCharge(PASS_ENGINE_PARAMETER_SIGNATURE);
|
standardAirCharge = getStandardAirCharge(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
#if (BOARD_TLE8888_COUNT > 0)
|
#if (BOARD_TLE8888_COUNT > 0)
|
||||||
|
static efitick_t tle8888CrankingResetTime = 0;
|
||||||
|
|
||||||
if (CONFIG(useTLE8888_cranking_hack) && ENGINE(rpmCalculator).isCranking(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
if (CONFIG(useTLE8888_cranking_hack) && ENGINE(rpmCalculator).isCranking(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
||||||
efitick_t nowNt = getTimeNowNt();
|
efitick_t nowNt = getTimeNowNt();
|
||||||
if (nowNt - tle8888CrankingResetTime > MS2NT(300)) {
|
if (nowNt - tle8888CrankingResetTime > MS2NT(300)) {
|
||||||
|
|
|
@ -442,8 +442,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static char errorMsgBuff[_MAX_FILLER + 2];
|
|
||||||
|
|
||||||
void addChannel(const char *name, adc_channel_e setting, adc_channel_mode_e mode) {
|
void addChannel(const char *name, adc_channel_e setting, adc_channel_mode_e mode) {
|
||||||
if (setting == EFI_ADC_NONE) {
|
if (setting == EFI_ADC_NONE) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -23,23 +23,23 @@
|
||||||
static ioportmask_t ext_used = 0;
|
static ioportmask_t ext_used = 0;
|
||||||
|
|
||||||
// EXT is not able to give you the front direction but you could read the pin in the callback.
|
// EXT is not able to give you the front direction but you could read the pin in the callback.
|
||||||
void efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, palcallback_t cb, void *cb_data) {
|
int efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, palcallback_t cb, void *cb_data) {
|
||||||
|
|
||||||
/* paranoid check, in case of GPIO_UNASSIGNED getHwPort will return NULL
|
/* paranoid check, in case of GPIO_UNASSIGNED getHwPort will return NULL
|
||||||
* and we will fail on next check */
|
* and we will fail on next check */
|
||||||
if (brainPin == GPIO_UNASSIGNED)
|
if (brainPin == GPIO_UNASSIGNED)
|
||||||
return;
|
return -1;
|
||||||
|
|
||||||
ioportid_t port = getHwPort(msg, brainPin);
|
ioportid_t port = getHwPort(msg, brainPin);
|
||||||
if (port == NULL)
|
if (port == NULL)
|
||||||
return;
|
return -1;
|
||||||
|
|
||||||
int index = getHwPin(msg, brainPin);
|
int index = getHwPin(msg, brainPin);
|
||||||
|
|
||||||
/* is this index already used? */
|
/* is this index already used? */
|
||||||
if (ext_used & PAL_PORT_BIT(index)) {
|
if (ext_used & PAL_PORT_BIT(index)) {
|
||||||
firmwareError(CUSTOM_ERR_PIN_ALREADY_USED_2, "%s: pin %d: exti index already used", msg, brainPin);
|
firmwareError(CUSTOM_ERR_PIN_ALREADY_USED_2, "%s: pin %d: exti index already used", msg, brainPin);
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ioline_t line = PAL_LINE(port, index);
|
ioline_t line = PAL_LINE(port, index);
|
||||||
|
@ -48,6 +48,8 @@ void efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, palc
|
||||||
|
|
||||||
/* mark used */
|
/* mark used */
|
||||||
ext_used |= PAL_PORT_BIT(index);
|
ext_used |= PAL_PORT_BIT(index);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void efiExtiDisablePin(brain_pin_e brainPin)
|
void efiExtiDisablePin(brain_pin_e brainPin)
|
||||||
|
|
|
@ -10,6 +10,6 @@
|
||||||
#include "digital_input.h"
|
#include "digital_input.h"
|
||||||
|
|
||||||
#if HAL_USE_PAL
|
#if HAL_USE_PAL
|
||||||
void efiExtiEnablePin(const char *msg, brain_pin_e pin, uint32_t mode, palcallback_t cb, void *cb_data);
|
int efiExtiEnablePin(const char *msg, brain_pin_e pin, uint32_t mode, palcallback_t cb, void *cb_data);
|
||||||
void efiExtiDisablePin(brain_pin_e brainPin);
|
void efiExtiDisablePin(brain_pin_e brainPin);
|
||||||
#endif /* HAL_USE_PAL */
|
#endif /* HAL_USE_PAL */
|
||||||
|
|
|
@ -221,7 +221,6 @@ void stopDigitalCapture(const char *msg, brain_pin_e brainPin) {
|
||||||
if (brainPin == GPIO_UNASSIGNED) {
|
if (brainPin == GPIO_UNASSIGNED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
brain_pin_markUnused(brainPin);
|
|
||||||
|
|
||||||
ICUDriver *driver = getInputCaptureDriver(msg, brainPin);
|
ICUDriver *driver = getInputCaptureDriver(msg, brainPin);
|
||||||
if (driver == NULL) {
|
if (driver == NULL) {
|
||||||
|
|
|
@ -82,6 +82,7 @@ static int turnOnTriggerInputPin(const char *msg, int index, bool isTriggerShaft
|
||||||
shaftTriggerType[index] = TRIGGER_ICU;
|
shaftTriggerType[index] = TRIGGER_ICU;
|
||||||
else
|
else
|
||||||
camTriggerType[index] = TRIGGER_ICU;
|
camTriggerType[index] = TRIGGER_ICU;
|
||||||
|
brain_pin_markUsed(brainPin, msg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -92,6 +93,7 @@ static int turnOnTriggerInputPin(const char *msg, int index, bool isTriggerShaft
|
||||||
shaftTriggerType[index] = TRIGGER_EXTI;
|
shaftTriggerType[index] = TRIGGER_EXTI;
|
||||||
else
|
else
|
||||||
camTriggerType[index] = TRIGGER_EXTI;
|
camTriggerType[index] = TRIGGER_EXTI;
|
||||||
|
brain_pin_markUsed(brainPin, msg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +125,7 @@ static void turnOffTriggerInputPin(int index, bool isTriggerShaft) {
|
||||||
|
|
||||||
camTriggerType[index] = TRIGGER_NONE;
|
camTriggerType[index] = TRIGGER_NONE;
|
||||||
}
|
}
|
||||||
|
brain_pin_markUnused(brainPin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*/
|
/*==========================================================================*/
|
||||||
|
|
|
@ -76,6 +76,7 @@ static void cam_callback(void *arg) {
|
||||||
/*==========================================================================*/
|
/*==========================================================================*/
|
||||||
|
|
||||||
int extiTriggerTurnOnInputPin(const char *msg, int index, bool isTriggerShaft) {
|
int extiTriggerTurnOnInputPin(const char *msg, int index, bool isTriggerShaft) {
|
||||||
|
int ret;
|
||||||
brain_pin_e brainPin = isTriggerShaft ? CONFIG(triggerInputPins)[index] : engineConfiguration->camInputs[index];
|
brain_pin_e brainPin = isTriggerShaft ? CONFIG(triggerInputPins)[index] : engineConfiguration->camInputs[index];
|
||||||
|
|
||||||
scheduleMsg(logger, "extiTriggerTurnOnInputPin %s %s", msg, hwPortname(brainPin));
|
scheduleMsg(logger, "extiTriggerTurnOnInputPin %s %s", msg, hwPortname(brainPin));
|
||||||
|
@ -83,8 +84,10 @@ int extiTriggerTurnOnInputPin(const char *msg, int index, bool isTriggerShaft) {
|
||||||
/* TODO:
|
/* TODO:
|
||||||
* * do not set to both edges if we need only one
|
* * do not set to both edges if we need only one
|
||||||
* * simplify callback in case of one edge */
|
* * simplify callback in case of one edge */
|
||||||
ioline_t pal_line = PAL_LINE(getHwPort("trg", brainPin), getHwPin("trg", brainPin));
|
ioline_t pal_line = PAL_LINE(getHwPort(msg, brainPin), getHwPin(msg, brainPin));
|
||||||
efiExtiEnablePin(msg, brainPin, PAL_EVENT_MODE_BOTH_EDGES, isTriggerShaft ? shaft_callback : cam_callback, (void *)pal_line);
|
ret = efiExtiEnablePin(msg, brainPin, PAL_EVENT_MODE_BOTH_EDGES, isTriggerShaft ? shaft_callback : cam_callback, (void *)pal_line);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue