Add safety checks to only set input pin modes when functions are enabled

This commit is contained in:
Josh Stewart 2018-09-20 07:26:43 +10:00
parent a21f0eb63f
commit 40f23ca885
3 changed files with 25 additions and 7 deletions

View File

@ -958,6 +958,7 @@ page = 10
requiresPowerCycle = knock_pin
requiresPowerCycle = knock_trigger
requiresPowerCycle = knock_pullup
requiresPowerCycle = idleUpEnabled
defaultValue = pinLayout, 1
defaultValue = TrigPattern, 0

View File

@ -87,8 +87,13 @@ void initialiseAuxPWM()
n2o_arming_pin_port = portInputRegister(digitalPinToPort(configPage10.n2o_arming_pin));
n2o_arming_pin_mask = digitalPinToBitMask(configPage10.n2o_arming_pin);
if(configPage10.n2o_pin_polarity == 1) { pinMode(configPage10.n2o_arming_pin, INPUT_PULLUP); }
else { pinMode(configPage10.n2o_arming_pin, INPUT); }
if(configPage10.n2o_enable > 0)
{
//The pin modes are only set if the if n2o is enabled to prevent them conflicting with other outputs.
if(configPage10.n2o_pin_polarity == 1) { pinMode(configPage10.n2o_arming_pin, INPUT_PULLUP); }
else { pinMode(configPage10.n2o_arming_pin, INPUT); }
}
#if defined(CORE_STM32) || defined(CORE_TEENSY) //2uS resolution Min 8Hz, Max 5KHz
boost_pwm_max_count = 1000000L / (2 * configPage6.boostFreq * 2); //Converts the frequency in Hz to the number of ticks (at 2uS) it takes to complete 1 cycle. The x2 is there because the frequency is stored at half value (in a byte) to allow freqneucies up to 511Hz

View File

@ -817,11 +817,23 @@ void setPinMapping(byte boardID)
pinMode(pinTrigger, INPUT);
pinMode(pinTrigger2, INPUT);
pinMode(pinTrigger3, INPUT);
pinMode(pinFlex, INPUT); //Standard GM / Continental flex sensor requires pullup, but this should be onboard. The internal pullup will not work (Requires ~3.3k)!
if (configPage6.lnchPullRes == true) { pinMode(pinLaunch, INPUT_PULLUP); }
else { pinMode(pinLaunch, INPUT); } //If Launch Pull Resistor is not set make input float.
if (configPage2.idleUpPolarity == 0) { pinMode(pinIdleUp, INPUT_PULLUP); } //Normal setting
else { pinMode(pinIdleUp, INPUT); } //inverted setting
//Each of the below are only set when their relevant function is enabled. This can help prevent pin conflicts that users aren't aware of with unused functions
if(configPage2.flexEnabled > 0)
{
pinMode(pinFlex, INPUT); //Standard GM / Continental flex sensor requires pullup, but this should be onboard. The internal pullup will not work (Requires ~3.3k)!
}
if(configPage6.launchEnabled > 0)
{
if (configPage6.lnchPullRes == true) { pinMode(pinLaunch, INPUT_PULLUP); }
else { pinMode(pinLaunch, INPUT); } //If Launch Pull Resistor is not set make input float.
}
if(configPage2.idleUpEnabled > 0)
{
if (configPage2.idleUpPolarity == 0) { pinMode(pinIdleUp, INPUT_PULLUP); } //Normal setting
else { pinMode(pinIdleUp, INPUT); } //inverted setting
}
//These must come after the above pinMode statements
triggerPri_pin_port = portInputRegister(digitalPinToPort(pinTrigger));