Add a check on the aux input system to make sure pin isn't already in use
This commit is contained in:
parent
c77072d187
commit
5c7a7c7891
|
@ -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));
|
||||
|
|
|
@ -65,15 +65,35 @@ void initialiseADC()
|
|||
}
|
||||
else if ((configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 2) //if current input channel is enabled as analog local pin
|
||||
{
|
||||
//Channel is active and analog
|
||||
pinMode( (configPage9.Auxinpina[currentStatus.current_caninchannel]&127), INPUT);
|
||||
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 mmethod of reporting this back to the user
|
||||
}
|
||||
else
|
||||
{
|
||||
//Channel is active and analog
|
||||
pinMode( pinNumber, INPUT);
|
||||
auxIsEnabled = true;
|
||||
}
|
||||
}
|
||||
else if ((configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 3) //if current input channel is enabled as digital local pin
|
||||
{
|
||||
//Channel is active and digital
|
||||
pinMode( (configPage9.Auxinpinb[currentStatus.current_caninchannel]&127), INPUT);
|
||||
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 mmethod of reporting this back to the user
|
||||
}
|
||||
else
|
||||
{
|
||||
//Channel is active and analog
|
||||
pinMode( pinNumber, INPUT);
|
||||
auxIsEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue