refactoring: time to unify digital pin API
This commit is contained in:
parent
8bbd06d165
commit
4ba7842f52
|
@ -30,13 +30,13 @@ 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"));
|
||||
turnOnTriggerInputPin(msg, CONFIGB(triggerInputPins)[i], true);
|
||||
turnOnTriggerInputPin(msg, i, true);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < CAM_INPUTS_COUNT; i++) {
|
||||
if (isConfigurationChanged(camInputs[i])) {
|
||||
turnOnTriggerInputPin("cam", engineConfiguration->camInputs[i], false);
|
||||
turnOnTriggerInputPin("cam", i, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,6 @@ void startTriggerInputPins(void);
|
|||
void stopTriggerInputPins(void);
|
||||
void setPrimaryChannel(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_ */
|
||||
|
|
|
@ -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));
|
||||
|
||||
/* TODO:
|
||||
|
|
|
@ -105,13 +105,18 @@ static ICUConfig cam_icucfg = { ICU_INPUT_ACTIVE_LOW,
|
|||
ICU_CHANNEL_1,
|
||||
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;
|
||||
|
||||
if (brainPin == GPIO_UNASSIGNED) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
//digital_input_s* input = startDigitalCapture("trigger", brainPin, true);
|
||||
if (isVvtShaft) {
|
||||
icucfg = &shaft_icucfg;
|
||||
} else {
|
||||
|
@ -148,6 +153,7 @@ int turnOnTriggerInputPin(const char *msg, brain_pin_e brainPin, bool isVvtShaft
|
|||
}
|
||||
|
||||
void turnOffTriggerInputPin(brain_pin_e brainPin) {
|
||||
|
||||
ICUDriver *driver = getInputCaptureDriver("trigger_off", brainPin);
|
||||
if (driver != NULL) {
|
||||
icuDisableNotifications(driver);
|
||||
|
|
Loading…
Reference in New Issue