2019-11-11 18:25:40 -08:00
|
|
|
/*
|
2019-04-12 05:05:53 -07:00
|
|
|
* @file trigger_input.cpp
|
2015-07-10 06:01:56 -07:00
|
|
|
*
|
2019-11-11 18:25:40 -08:00
|
|
|
* @date Nov 11, 2019
|
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2019
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
2018-09-16 19:26:57 -07:00
|
|
|
#include "global.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "trigger_input.h"
|
2019-04-12 05:05:53 -07:00
|
|
|
|
2019-11-11 18:45:15 -08:00
|
|
|
#if (EFI_PROD_CODE && EFI_SHAFT_POSITION_INPUT) || defined(__DOXYGEN__)
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-11-11 19:19:35 -08:00
|
|
|
EXTERN_ENGINE;
|
|
|
|
|
|
|
|
#if (HAL_USE_ICU == TRUE) || (HAL_TRIGGER_USE_PAL == TRUE)
|
|
|
|
void stopTriggerInputPins(void) {
|
|
|
|
for (int i = 0; i < TRIGGER_SUPPORTED_CHANNELS; i++) {
|
|
|
|
if (isConfigurationChanged(bc.triggerInputPins[i])) {
|
|
|
|
turnOffTriggerInputPin(activeConfiguration.bc.triggerInputPins[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < CAM_INPUTS_COUNT; i++) {
|
|
|
|
if (isConfigurationChanged(camInputs[i])) {
|
|
|
|
turnOffTriggerInputPin(activeConfiguration.camInputs[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void startTriggerInputPins(void) {
|
|
|
|
for (int i = 0; i < TRIGGER_SUPPORTED_CHANNELS; i++) {
|
|
|
|
if (isConfigurationChanged(bc.triggerInputPins[i])) {
|
|
|
|
const char * msg = (i == 0 ? "trigger#1" : (i == 1 ? "trigger#2" : "trigger#3"));
|
2019-11-13 19:56:43 -08:00
|
|
|
turnOnTriggerInputPin(msg, i, true);
|
2019-11-11 19:19:35 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < CAM_INPUTS_COUNT; i++) {
|
|
|
|
if (isConfigurationChanged(camInputs[i])) {
|
2019-11-13 19:56:43 -08:00
|
|
|
turnOnTriggerInputPin("cam", i, false);
|
2019-11-11 19:19:35 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setPrimaryChannel(CONFIGB(triggerInputPins)[0]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2019-04-09 19:15:55 -07:00
|
|
|
void applyNewTriggerInputPins(void) {
|
2019-04-12 05:05:53 -07:00
|
|
|
// first we will turn off all the changed pins
|
2019-04-09 19:15:55 -07:00
|
|
|
stopTriggerInputPins();
|
2019-04-12 05:05:53 -07:00
|
|
|
// then we will enable all the changed pins
|
2019-04-09 19:15:55 -07:00
|
|
|
startTriggerInputPins();
|
|
|
|
}
|
|
|
|
|
2019-11-11 18:25:40 -08:00
|
|
|
#endif /* EFI_SHAFT_POSITION_INPUT */
|