Add check to prevent system hanging on startup with fresh board if invalid flex pin is attempted

This commit is contained in:
Josh Stewart 2017-08-03 23:45:51 +10:00
parent 32b5c4684e
commit e4207d9ee3
2 changed files with 13 additions and 5 deletions

View File

@ -209,7 +209,12 @@ void setup()
loadCalibration();
//Set the pin mappings
if(configPage1.pinMapping > BOARD_NR_GPIO_PINS) { setPinMapping(3); } //First time running? set to v0.4
if(configPage1.pinMapping > BOARD_NR_GPIO_PINS)
{
//First time running on this board
setPinMapping(3); //Force board to v0.4
configPage1.flexEnabled = false; //Have to disable flex. If this isn't done and the wrong flex pin is interrupt attached below, system can hang.
}
else { setPinMapping(configPage1.pinMapping); }
//Need to check early on whether the coil charging is inverted. If this is not set straight away it can cause an unwanted spark at bootup
@ -270,7 +275,6 @@ void setup()
}
}
//Check whether the flex sensor is enabled and if so, attach an interupt for it
if(configPage1.flexEnabled)
{
@ -344,7 +348,6 @@ void setup()
pinMode(pinTrigger3, INPUT);
//digitalWrite(pinTrigger, HIGH);
//Set the trigger function based on the decoder in the config
switch (configPage2.TrigPattern)
{
@ -955,6 +958,7 @@ void loop()
currentStatus.PW1 = 0;
currentStatus.VE = 0;
toothLastToothTime = 0;
//toothLastMinusOneToothTime = 0;
currentStatus.hasSync = false;
currentStatus.runSecs = 0; //Reset the counter for number of seconds running.
secCounter = 0; //Reset our seconds counter.

View File

@ -300,13 +300,14 @@ void setPinMapping(byte boardID)
pinDisplayReset = 48; // OLED reset pin
pinTachOut = 49; //Tacho output pin (Goes to ULN2803)
pinIdle1 = 2; //Single wire idle control
pinIdle2 = 3; //2 wire idle control (Note this is shared with boost!!!)
pinBoost = 4;
pinIdle2 = 4; //2 wire idle control (Note this is shared with boost!!!)
pinFuelPump = 37; //Fuel pump output (Goes to ULN2803)
pinStepperDir = 16; //Direction pin for DRV8825 driver
pinStepperStep = 17; //Step pin for DRV8825 driver
pinFan = 47; //Pin for the fan output (Goes to ULN2803)
pinLaunch = 12; //Can be overwritten below
pinFlex = 2; // Flex sensor (Must be external interrupt enabled)
pinFlex = 3; // Flex sensor (Must be external interrupt enabled)
break;
case 10:
@ -441,6 +442,9 @@ void setPinMapping(byte boardID)
pinFan = 47; //Pin for the fan output
pinFuelPump = 4; //Fuel pump output
pinTachOut = 49; //Tacho output pin
pinFlex = 3; // Flex sensor (Must be external interrupt enabled)
pinBoost = 5;
pinIdle1 = 6;
break;
}