refactoring: time to unify digital pin API

This commit is contained in:
rusefi 2019-11-12 00:25:10 -05:00
parent 8bbd06d165
commit 4ba7842f52
4 changed files with 13 additions and 5 deletions

View File

@ -30,13 +30,13 @@ void startTriggerInputPins(void) {
for (int i = 0; i < TRIGGER_SUPPORTED_CHANNELS; i++) { for (int i = 0; i < TRIGGER_SUPPORTED_CHANNELS; i++) {
if (isConfigurationChanged(bc.triggerInputPins[i])) { if (isConfigurationChanged(bc.triggerInputPins[i])) {
const char * msg = (i == 0 ? "trigger#1" : (i == 1 ? "trigger#2" : "trigger#3")); const char * msg = (i == 0 ? "trigger#1" : (i == 1 ? "trigger#2" : "trigger#3"));
turnOnTriggerInputPin(msg, CONFIGB(triggerInputPins)[i], true); turnOnTriggerInputPin(msg, i, true);
} }
} }
for (int i = 0; i < CAM_INPUTS_COUNT; i++) { for (int i = 0; i < CAM_INPUTS_COUNT; i++) {
if (isConfigurationChanged(camInputs[i])) { if (isConfigurationChanged(camInputs[i])) {
turnOnTriggerInputPin("cam", engineConfiguration->camInputs[i], false); turnOnTriggerInputPin("cam", i, false);
} }
} }

View File

@ -22,6 +22,6 @@ void startTriggerInputPins(void);
void stopTriggerInputPins(void); void stopTriggerInputPins(void);
void setPrimaryChannel(brain_pin_e brainPin); void setPrimaryChannel(brain_pin_e brainPin);
void turnOffTriggerInputPin(brain_pin_e brainPin); void turnOffTriggerInputPin(brain_pin_e brainPin);
int turnOnTriggerInputPin(const char *msg, brain_pin_e brainPin, bool isVvtShaft); int turnOnTriggerInputPin(const char *msg, int index, bool isVvtShaft);
#endif /* CRANK_INPUT_H_ */ #endif /* CRANK_INPUT_H_ */

View File

@ -64,7 +64,9 @@ static void cam_callback(void *arg) {
} }
} }
int turnOnTriggerInputPin(const char *msg, brain_pin_e brainPin, bool isVvtShaft) { int turnOnTriggerInputPin(const char *msg, int index, bool isVvtShaft) {
brain_pin_e brainPin = isVvtShaft ? engineConfiguration->camInputs[index] : CONFIGB(triggerInputPins)[index];
scheduleMsg(logger, "turnOnTriggerInputPin(PAL) %s %s", msg, hwPortname(brainPin)); scheduleMsg(logger, "turnOnTriggerInputPin(PAL) %s %s", msg, hwPortname(brainPin));
/* TODO: /* TODO:

View File

@ -105,13 +105,18 @@ static ICUConfig cam_icucfg = { ICU_INPUT_ACTIVE_LOW,
ICU_CHANNEL_1, ICU_CHANNEL_1,
0}; 0};
int turnOnTriggerInputPin(const char *msg, brain_pin_e brainPin, bool isVvtShaft) { int turnOnTriggerInputPin(const char *msg, int index, bool isVvtShaft) {
brain_pin_e brainPin = isVvtShaft ? engineConfiguration->camInputs[index] : CONFIGB(triggerInputPins)[index];
ICUConfig *icucfg; ICUConfig *icucfg;
if (brainPin == GPIO_UNASSIGNED) { if (brainPin == GPIO_UNASSIGNED) {
return -1; return -1;
} }
//digital_input_s* input = startDigitalCapture("trigger", brainPin, true);
if (isVvtShaft) { if (isVvtShaft) {
icucfg = &shaft_icucfg; icucfg = &shaft_icucfg;
} else { } else {
@ -148,6 +153,7 @@ int turnOnTriggerInputPin(const char *msg, brain_pin_e brainPin, bool isVvtShaft
} }
void turnOffTriggerInputPin(brain_pin_e brainPin) { void turnOffTriggerInputPin(brain_pin_e brainPin) {
ICUDriver *driver = getInputCaptureDriver("trigger_off", brainPin); ICUDriver *driver = getInputCaptureDriver("trigger_off", brainPin);
if (driver != NULL) { if (driver != NULL) {
icuDisableNotifications(driver); icuDisableNotifications(driver);