From efdc1b516290a341a930716ed1f47e743e48062f Mon Sep 17 00:00:00 2001 From: darren siepka Date: Sun, 23 Sep 2018 23:14:53 +0100 Subject: [PATCH] fix sensors merge conflicts --- speeduino/sensors.h | 5 +++++ speeduino/sensors.ino | 34 ++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/speeduino/sensors.h b/speeduino/sensors.h index 3334e694..78901e50 100644 --- a/speeduino/sensors.h +++ b/speeduino/sensors.h @@ -47,6 +47,11 @@ byte cltErrorCount = 0; * But removes the use of floats and uses 8 bits of fixed precision. */ #define ADC_FILTER(input, alpha, prior) (((long)input * (256 - alpha) + ((long)prior * alpha))) >> 8 +//These functions all do checks on a pin to determine if it is already in use by another (higher importance) function +#define pinIsInjector(pin) ( (pin == pinInjector1) || (pin == pinInjector2) || (pin == pinInjector3) || (pin == pinInjector4) ) +#define pinIsIgnition(pin) ( (pin == pinCoil1) || (pin == pinCoil2) || (pin == pinCoil3) || (pin == pinCoil4) ) +#define pinIsSensor(pin) ( (pin == pinCLT) || (pin == pinIAT) || (pin == pinMAP) || (pin == pinTPS) || (pin == pinO2) || (pin == pinBat) ) +#define pinIsUsed(pin) ( pinIsInjector(pin) || pinIsIgnition(pin) || pinIsSensor(pin) ) static inline void instanteneousMAPReading() __attribute__((always_inline)); static inline void readMAP() __attribute__((always_inline)); diff --git a/speeduino/sensors.ino b/speeduino/sensors.ino index 2acaf575..a050b41f 100644 --- a/speeduino/sensors.ino +++ b/speeduino/sensors.ino @@ -67,19 +67,37 @@ void initialiseADC() || (((configPage9.enable_secondarySerial == 0) && (configPage9.enable_intcan == 1 && configPage9.intcan_available == 0 )) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 2) || (((configPage9.enable_secondarySerial == 0) && (configPage9.enable_intcan == 0)) && ((configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 2))) { //if current input channel is enabled as analog local pin check caninput_selxb(bits 2:3) with &12 and caninput_selxa(bits 0:1) with &3 - //Channel is active and analog - pinMode( (configPage9.Auxinpina[currentStatus.current_caninchannel]&127), INPUT); - //currentStatus.canin[14] = 33; Dev test use only! - auxIsEnabled = true; + byte pinNumber = (configPage9.Auxinpina[currentStatus.current_caninchannel]&127); + if( pinIsUsed(pinNumber) ) + { + //Do nothing here as the pin is already in use. + //Need some method of reporting this back to the user + } + else + { + //Channel is active and analog + pinMode( pinNumber, INPUT); + //currentStatus.canin[14] = 33; Dev test use only! + auxIsEnabled = true; + } } else if ((((configPage9.enable_secondarySerial == 1) || ((configPage9.enable_intcan == 1) && (configPage9.intcan_available == 1))) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&12) == 12) || (((configPage9.enable_secondarySerial == 0) && (configPage9.enable_intcan == 1 && configPage9.intcan_available == 0 )) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 3) || (((configPage9.enable_secondarySerial == 0) && (configPage9.enable_intcan == 0)) && ((configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 3))) { //if current input channel is enabled as digital local pin check caninput_selxb(bits 2:3) wih &12 and caninput_selxa(bits 0:1) with &3 - //Channel is active and digital - pinMode( (configPage9.Auxinpinb[currentStatus.current_caninchannel]&127), INPUT); - //currentStatus.canin[14] = 44; Dev test use only! - auxIsEnabled = true; + byte pinNumber = (configPage9.Auxinpinb[currentStatus.current_caninchannel]&127); + if( pinIsUsed(pinNumber) ) + { + //Do nothing here as the pin is already in use. + //Need some method of reporting this back to the user + } + else + { + //Channel is active and digital + pinMode( pinNumber, INPUT); + //currentStatus.canin[14] = 44; Dev test use only! + auxIsEnabled = true; + } } } }