Reset Control
Changed reset lock feature to a more general "reset control" feature. Moved reset control settings to the general Settings menu. added a serial U command that will halt comms and set the control pin low when another byte is received to facilitate reset control for devices that lack an AtmegaXXu2 usb controller. Improved context help for reset control. Corrected reset lock status indicator on / off labels. moved reset control setup to utils.ino.
This commit is contained in:
parent
03e6c2d476
commit
ae8ea08d41
|
@ -282,8 +282,8 @@ page = 4
|
|||
sparkDur = scalar, U08, 7, "ms", 0.1, 0, 0, 25.5, 1 ; Spark duration
|
||||
unused4-8 = scalar, U08, 8, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
unused4-9 = scalar, U08, 9, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
resetLock = bits, U08, 10,[0:1], "Never", "When Running", "Always", "INVALID"
|
||||
resetLockPin = bits, U08, 10,[2:7], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "INVALID"
|
||||
resetControl = bits, U08, 10,[0:1], "Disabled", "Prevent When Running", "Prevent Always", "Serial Command"
|
||||
resetControlPin = bits, U08, 10,[2:7], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "INVALID"
|
||||
SkipCycles = scalar, U08, 11, "cycles", 1, 0, 0, 255, 0
|
||||
|
||||
; name = array, type, offset, shape, units, scale, translate, lo, hi, digits
|
||||
|
@ -754,8 +754,8 @@ page = 10
|
|||
requiresPowerCycle = stagedInjSizePri
|
||||
requiresPowerCycle = stagedInjSizeSec
|
||||
requiresPowerCycle = stagingEnabled
|
||||
requiresPowerCycle = resetLock
|
||||
requiresPowerCycle = resetLockPin
|
||||
requiresPowerCycle = resetControl
|
||||
requiresPowerCycle = resetControlPin
|
||||
|
||||
defaultValue = pinLayout, 1
|
||||
defaultValue = TrigPattern, 0
|
||||
|
@ -804,7 +804,7 @@ page = 10
|
|||
defaultValue = realtime_base_address, 336
|
||||
defaultValue = VVTasOnOff, 0
|
||||
defaultValue = stagingEnabled, 0
|
||||
defaultValue = resetLock, 0
|
||||
defaultValue = resetControl, 0
|
||||
; defaultValue = obd_address, 0
|
||||
|
||||
;Default pins
|
||||
|
@ -815,7 +815,7 @@ page = 10
|
|||
defaultValue = fuelPumpPin, 0
|
||||
defaultValue = tachoPin, 0
|
||||
defaultValue = perToothIgn, 0
|
||||
defaultValue = resetLockPin, 0
|
||||
defaultValue = resetControlPin, 0
|
||||
[Menu]
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
|
@ -850,7 +850,7 @@ menuDialog = main
|
|||
subMenu = triggerSettings, "Trigger Setup"
|
||||
;subMenu = OLED, "OLED Setup"
|
||||
subMenu = airdensity_curve, "IAT Density"
|
||||
|
||||
subMenu = reset_control, "Reset Control"
|
||||
|
||||
menu = "&Tuning"
|
||||
subMenu = std_realtime, "Realtime Display"
|
||||
|
@ -909,10 +909,6 @@ menuDialog = main
|
|||
subMenu = serial3IO, "Secondary Serial IO Interface"
|
||||
#endif
|
||||
|
||||
subMenu = std_separator
|
||||
|
||||
subMenu = reset_lock, "Reset Lock"
|
||||
|
||||
menuDialog = main
|
||||
menu = "T&ools"
|
||||
subMenu = mapCal, "Calibrate MAP"
|
||||
|
@ -1100,9 +1096,9 @@ menuDialog = main
|
|||
|
||||
stagedInjSizePri= "Size of the primary injectors. The sum of the Pri and Sec injectors values MUST match the value used in the req_fuel calculation"
|
||||
stagedInjSizeSec= "Size of the secondary injectors. The sum of the Pri and Sec injectors values MUST match the value used in the req_fuel calculation"
|
||||
|
||||
resetLock = "When the Speeduino should be locked against auto reset by serial connection."
|
||||
resetLockPin = "The Arduino pin that you have connected to pin PB7 on its 8U2 / 16U2 serial comm controller."
|
||||
|
||||
resetControl = "How to control the Arduino's automatic reset feature. NOTE: Some of these settings require modifying your hardware and possibly replacing the Arduino bootloader. See the Wiki for more details.\n\nDisabled: Allow the Arduino to reset when a new serial connection is made.\n\nPrevent When Running: Hold the control pin high while the engine is running.\n\nPrevent Always: Always hold the control pin high.\n\nSerial Command: Normally hold the control pin high, but pull it low when the 'U' serial command is issued and reset upon receiving more data."
|
||||
resetControlPin = "The Arduino pin used to control resets."
|
||||
|
||||
[UserDefined]
|
||||
|
||||
|
@ -1809,9 +1805,9 @@ menuDialog = main
|
|||
topicHelp = "http://speeduino.com/wiki/index.php/Serial3_IO_interface"
|
||||
field = "Enable Second Serial", enable_canbus
|
||||
|
||||
dialog = reset_lock, "Reset Lock"
|
||||
field = "Use Reset Lock", resetLock
|
||||
field = "Reset Lock Pin", resetLockPin
|
||||
dialog = reset_control, "Reset Control"
|
||||
field = "Control Type", resetControl
|
||||
field = "Control Pin", resetControlPin
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
; General help text
|
||||
|
@ -2246,7 +2242,7 @@ cmdtestspk450dc = "E\x03\x0C"
|
|||
indicator = { hardLimitOn }, "Hard Limit OFF","Hard Limiter", white, black, red, black
|
||||
indicator = { boostCutOut }, "Ign Cut OFF", "Ign Cut (Boost)", white, black, red, black
|
||||
indicator = { sync }, "No Sync", "Sync", white, black, green, black
|
||||
indicator = { resetLockOn }, "Reset Lock ON", "Reset Lock OFF", white, black, green, black
|
||||
indicator = { resetLockOn }, "Reset Lock OFF","Reset Lock ON", red, black, green, black
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -183,6 +183,15 @@ void command()
|
|||
|
||||
break;
|
||||
|
||||
case 'U': //User wants to reset the Arduino (probably for FW update)
|
||||
#ifndef SMALL_FLASH_MODE
|
||||
if (!cmdPending) { Serial.println(F("Comms halted. Next byte will reset the Arduino.")); }
|
||||
#endif
|
||||
|
||||
while (Serial.available() == 0) { }
|
||||
digitalWrite(pinResetControl, LOW);
|
||||
break;
|
||||
|
||||
case 'V': // send VE table and constants in binary
|
||||
sendPage(false);
|
||||
break;
|
||||
|
@ -320,6 +329,7 @@ void command()
|
|||
"Z - Display calibration values\n"
|
||||
"T - Displays 256 tooth log entries in binary\n"
|
||||
"r - Displays 256 tooth log entries\n"
|
||||
"U - Prepare for firmware update. The next byte received will cause the Arduino to reset.\n"
|
||||
"? - Displays this help page"
|
||||
));
|
||||
#endif
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
#define BIT_TIMER_15HZ 3
|
||||
#define BIT_TIMER_30HZ 4
|
||||
|
||||
#define BIT_STATUS3_RESET_LOCK 0 //Indicates whether reset lock is active
|
||||
#define BIT_STATUS3_RESET_PREVENT 0 //Indicates whether reset prevention is enabled
|
||||
#define BIT_STATUS3_UNUSED2 1
|
||||
#define BIT_STATUS3_UNUSED3 2
|
||||
#define BIT_STATUS3_UNUSED4 3
|
||||
|
@ -145,9 +145,10 @@
|
|||
#define STAGING_MODE_TABLE 0
|
||||
#define STAGING_MODE_AUTO 1
|
||||
|
||||
#define RESET_LOCK_DISABLED 0
|
||||
#define RESET_LOCK_WHEN_RUNNING 1
|
||||
#define RESET_LOCK_ALWAYS 2
|
||||
#define RESET_CONTROL_DISABLED 0
|
||||
#define RESET_CONTROL_PREVENT_WHEN_RUNNING 1
|
||||
#define RESET_CONTROL_PREVENT_ALWAYS 2
|
||||
#define RESET_CONTROL_SERIAL_COMMAND 3
|
||||
|
||||
#define MAX_RPM 18000 //This is the maximum rpm that the ECU will attempt to run at. It is NOT related to the rev limiter, but is instead dictates how fast certain operations will be allowed to run. Lower number gives better performance
|
||||
#define engineSquirtsPerCycle 2 //Would be 1 for a 2 stroke
|
||||
|
@ -238,6 +239,9 @@ int ignition4EndAngle = 0;
|
|||
//This is used across multiple files
|
||||
unsigned long revolutionTime; //The time in uS that one revolution would take at current speed (The time tooth 1 was last seen, minus the time it was seen prior to that)
|
||||
|
||||
//This needs to be here because using the config page directly can prevent burning the setting
|
||||
byte resetControl = RESET_CONTROL_DISABLED;
|
||||
|
||||
volatile byte TIMER_mask;
|
||||
volatile byte LOOP_TIMER;
|
||||
|
||||
|
@ -445,8 +449,8 @@ struct config2 {
|
|||
byte unused4_9;
|
||||
|
||||
//byte unused4_10;
|
||||
byte resetLock : 2; // When to lock the 8u2/16u2 against reset on DTR (0=Never, 1=With Sync, 2=Always, 4=Not currently used)
|
||||
byte resetLockPin : 6;
|
||||
byte resetControl : 2; //Which method of reset control to use (0=None, 1=Prevent When Running, 2=Prevent Always, 3=Serial Command)
|
||||
byte resetControlPin : 6;
|
||||
|
||||
byte StgCycles; //The number of initial cycles before the ignition should fire when first cranking
|
||||
|
||||
|
@ -722,7 +726,7 @@ byte pinLaunch;
|
|||
byte pinIgnBypass; //The pin used for an ignition bypass (Optional)
|
||||
byte pinFlex; //Pin with the flex sensor attached
|
||||
byte pinBaro; //Pin that an external barometric pressure sensor is attached to (If used)
|
||||
byte pinResetLock; // Output pin used to tell the 8u2/16u2 not to reset on DTR
|
||||
byte pinResetControl; // Output pin used control resetting the Arduino
|
||||
|
||||
// global variables // from speeduino.ino
|
||||
extern struct statuses currentStatus; // from speeduino.ino
|
||||
|
|
|
@ -665,24 +665,6 @@ void setup()
|
|||
setFuelSchedule3(100, (unsigned long)(configPage1.primePulse * 100));
|
||||
setFuelSchedule4(100, (unsigned long)(configPage1.primePulse * 100));
|
||||
|
||||
//Setup reset lock initial state
|
||||
switch (configPage2.resetLock) {
|
||||
case RESET_LOCK_WHEN_RUNNING:
|
||||
//Set the reset lock pin LOW and change it to HIGH later when we get sync.
|
||||
digitalWrite(pinResetLock, LOW);
|
||||
BIT_CLEAR(currentStatus.status3, BIT_STATUS3_RESET_LOCK);
|
||||
break;
|
||||
case RESET_LOCK_ALWAYS:
|
||||
//Set the reset lock pin HIGH and never touch it again.
|
||||
digitalWrite(pinResetLock, HIGH);
|
||||
BIT_SET(currentStatus.status3, BIT_STATUS3_RESET_LOCK);
|
||||
break;
|
||||
default:
|
||||
//Either disabled or set to an invalid value. Do nothing.
|
||||
BIT_CLEAR(currentStatus.status3, BIT_STATUS3_RESET_LOCK);
|
||||
break;
|
||||
}
|
||||
|
||||
initialisationComplete = true;
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
}
|
||||
|
@ -1554,16 +1536,16 @@ void loop()
|
|||
}
|
||||
} //Ignition schedules on
|
||||
|
||||
if (!BIT_CHECK(currentStatus.status3, BIT_STATUS3_RESET_LOCK) && configPage2.resetLock == RESET_LOCK_WHEN_RUNNING) {
|
||||
//Reset lock is supposed to be set while synced but isn't. Fix that.
|
||||
digitalWrite(pinResetLock, HIGH);
|
||||
BIT_SET(currentStatus.status3, BIT_STATUS3_RESET_LOCK);
|
||||
if (!BIT_CHECK(currentStatus.status3, BIT_STATUS3_RESET_PREVENT) && resetControl == RESET_CONTROL_PREVENT_WHEN_RUNNING) {
|
||||
//Reset prevention is supposed to be on while the engine is running but isn't. Fix that.
|
||||
digitalWrite(pinResetControl, HIGH);
|
||||
BIT_SET(currentStatus.status3, BIT_STATUS3_RESET_PREVENT);
|
||||
}
|
||||
} //Has sync and RPM
|
||||
else if (BIT_CHECK(currentStatus.status3, BIT_STATUS3_RESET_LOCK) && configPage2.resetLock == RESET_LOCK_WHEN_RUNNING) {
|
||||
digitalWrite(pinResetLock, LOW);
|
||||
BIT_CLEAR(currentStatus.status3, BIT_STATUS3_RESET_LOCK);
|
||||
}
|
||||
else if (BIT_CHECK(currentStatus.status3, BIT_STATUS3_RESET_PREVENT) && resetControl == RESET_CONTROL_PREVENT_WHEN_RUNNING) {
|
||||
digitalWrite(pinResetControl, LOW);
|
||||
BIT_CLEAR(currentStatus.status3, BIT_STATUS3_RESET_PREVENT);
|
||||
}
|
||||
} //loop()
|
||||
|
||||
/*
|
||||
|
|
|
@ -48,6 +48,32 @@ byte pinTranslate(byte rawPin)
|
|||
return outputPin;
|
||||
}
|
||||
|
||||
void setResetControlPinState()
|
||||
{
|
||||
BIT_CLEAR(currentStatus.status3, BIT_STATUS3_RESET_PREVENT);
|
||||
|
||||
/* Setup reset control initial state */
|
||||
switch (resetControl)
|
||||
{
|
||||
case RESET_CONTROL_PREVENT_WHEN_RUNNING:
|
||||
/* Set the reset control pin LOW and change it to HIGH later when we get sync. */
|
||||
digitalWrite(pinResetControl, LOW);
|
||||
BIT_CLEAR(currentStatus.status3, BIT_STATUS3_RESET_PREVENT);
|
||||
break;
|
||||
case RESET_CONTROL_PREVENT_ALWAYS:
|
||||
/* Set the reset control pin HIGH and never touch it again. */
|
||||
digitalWrite(pinResetControl, HIGH);
|
||||
BIT_SET(currentStatus.status3, BIT_STATUS3_RESET_PREVENT);
|
||||
break;
|
||||
case RESET_CONTROL_SERIAL_COMMAND:
|
||||
/* Set the reset control pin HIGH. There currently isn't any practical difference
|
||||
between this and PREVENT_ALWAYS but it doesn't hurt anything to have them separate. */
|
||||
digitalWrite(pinResetControl, HIGH);
|
||||
BIT_CLEAR(currentStatus.status3, BIT_STATUS3_RESET_PREVENT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void setPinMapping(byte boardID)
|
||||
{
|
||||
switch (boardID)
|
||||
|
@ -80,7 +106,7 @@ void setPinMapping(byte boardID)
|
|||
pinFuelPump = 4; //Fuel pump output
|
||||
pinTachOut = 49; //Tacho output pin
|
||||
pinFlex = 19; // Flex sensor (Must be external interrupt enabled)
|
||||
pinResetLock = 43; //Reset lock output
|
||||
pinResetControl = 43; //Reset control output
|
||||
#endif
|
||||
break;
|
||||
case 1:
|
||||
|
@ -113,7 +139,7 @@ void setPinMapping(byte boardID)
|
|||
pinFan = 47; //Pin for the fan output
|
||||
pinFuelPump = 4; //Fuel pump output
|
||||
pinFlex = 2; // Flex sensor (Must be external interrupt enabled)
|
||||
pinResetLock = 43; //Reset lock output
|
||||
pinResetControl = 43; //Reset control output
|
||||
break;
|
||||
#endif
|
||||
case 2:
|
||||
|
@ -150,7 +176,7 @@ void setPinMapping(byte boardID)
|
|||
pinFan = A13; //Pin for the fan output
|
||||
pinLaunch = 12; //Can be overwritten below
|
||||
pinFlex = 2; // Flex sensor (Must be external interrupt enabled)
|
||||
pinResetLock = 50; //Reset lock output
|
||||
pinResetControl = 50; //Reset control output
|
||||
|
||||
#if defined(CORE_TEENSY)
|
||||
pinTrigger = 23;
|
||||
|
@ -199,7 +225,7 @@ void setPinMapping(byte boardID)
|
|||
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)
|
||||
pinResetLock = 43; //Reset lock output
|
||||
pinResetControl = 43; //Reset control output
|
||||
|
||||
#if defined(CORE_TEENSY)
|
||||
pinTrigger = 23;
|
||||
|
@ -309,7 +335,7 @@ void setPinMapping(byte boardID)
|
|||
pinFan = 35; //Pin for the fan output
|
||||
pinLaunch = 12; //Can be overwritten below
|
||||
pinFlex = 3; // Flex sensor (Must be external interrupt enabled)
|
||||
pinResetLock = 44; //Reset lock output
|
||||
pinResetControl = 44; //Reset control output
|
||||
|
||||
#if defined(CORE_TEENSY)
|
||||
pinTrigger = 23;
|
||||
|
@ -359,7 +385,7 @@ void setPinMapping(byte boardID)
|
|||
pinFan = 47; //Pin for the fan output
|
||||
pinTachOut = 49; //Tacho output pin
|
||||
pinFlex = 2; // Flex sensor (Must be external interrupt enabled)
|
||||
pinResetLock = 26; //Reset lock output
|
||||
pinResetControl = 26; //Reset control output
|
||||
|
||||
#endif
|
||||
break;
|
||||
|
@ -396,7 +422,7 @@ void setPinMapping(byte boardID)
|
|||
pinFan = 47; //Pin for the fan output
|
||||
pinFuelPump = 4; //Fuel pump output
|
||||
pinTachOut = 49; //Tacho output pin
|
||||
pinResetLock = 26; //Reset lock output
|
||||
pinResetControl = 26; //Reset control output
|
||||
#endif
|
||||
break;
|
||||
|
||||
|
@ -479,7 +505,7 @@ void setPinMapping(byte boardID)
|
|||
pinSpareLOut1 = 32; //low current output spare1 - ONLY WITH DB
|
||||
pinSpareLOut2 = 34; //low current output spare2 - ONLY WITH DB
|
||||
pinSpareLOut3 = 36; //low current output spare3 - ONLY WITH DB
|
||||
pinResetLock = 26; //Reset lock output
|
||||
pinResetControl = 26; //Reset control output
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -512,7 +538,7 @@ void setPinMapping(byte boardID)
|
|||
pinFlex = 3; // Flex sensor (Must be external interrupt enabled)
|
||||
pinBoost = 5;
|
||||
pinIdle1 = 6;
|
||||
pinResetLock = 43; //Reset lock output
|
||||
pinResetControl = 43; //Reset control output
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
@ -527,7 +553,17 @@ void setPinMapping(byte boardID)
|
|||
if ( (configPage3.boostPin != 0) && (configPage3.boostPin < BOARD_NR_GPIO_PINS) ) { pinBoost = pinTranslate(configPage3.boostPin); }
|
||||
if ( (configPage3.vvtPin != 0) && (configPage3.vvtPin < BOARD_NR_GPIO_PINS) ) { pinVVT_1 = pinTranslate(configPage3.vvtPin); }
|
||||
if ( (configPage3.useExtBaro != 0) && (configPage3.baroPin < BOARD_NR_GPIO_PINS) ) { pinBaro = configPage3.baroPin + A0; }
|
||||
if ( (configPage2.resetLock != 0) && (configPage2.resetLockPin < BOARD_NR_GPIO_PINS) ) { pinResetLock = pinTranslate(configPage2.resetLockPin); }
|
||||
|
||||
/* Reset control is a special case. If reset control is enabled, it needs its initial state set BEFORE its pinMode.
|
||||
If that doesn't happen and reset control is in "Serial Command" mode, the Arduino will end up in a reset loop
|
||||
because the control pin will go low as soon as the pinMode is set to OUTPUT. */
|
||||
if ( (configPage2.resetControl != 0) && (configPage2.resetControlPin < BOARD_NR_GPIO_PINS) )
|
||||
{
|
||||
resetControl = configPage2.resetControl;
|
||||
pinResetControl = pinTranslate(configPage2.resetControlPin);
|
||||
setResetControlPinState();
|
||||
pinMode(pinResetControl, OUTPUT);
|
||||
}
|
||||
|
||||
//Finally, set the relevant pin modes for outputs
|
||||
pinMode(pinCoil1, OUTPUT);
|
||||
|
@ -551,7 +587,6 @@ void setPinMapping(byte boardID)
|
|||
pinMode(pinStepperEnable, OUTPUT);
|
||||
pinMode(pinBoost, OUTPUT);
|
||||
pinMode(pinVVT_1, OUTPUT);
|
||||
pinMode(pinResetLock, OUTPUT);
|
||||
|
||||
inj1_pin_port = portOutputRegister(digitalPinToPort(pinInjector1));
|
||||
inj1_pin_mask = digitalPinToBitMask(pinInjector1);
|
||||
|
|
Loading…
Reference in New Issue