Software controlled auto-reset prevention
This feature enables the Speeduino to set a pin high that will tell the Arduino's 8U2/16U2 firmware not to reset on new serial connections. This requires a slightly modified firmware for the 8U2/16U2 that will only reset on DTR when PB7 is also held low.
This commit is contained in:
parent
507ebc83d6
commit
03e6c2d476
|
@ -282,7 +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
|
||||
unused4-10 = scalar, U08, 10, "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"
|
||||
SkipCycles = scalar, U08, 11, "cycles", 1, 0, 0, 255, 0
|
||||
|
||||
; name = array, type, offset, shape, units, scale, translate, lo, hi, digits
|
||||
|
@ -753,6 +754,8 @@ page = 10
|
|||
requiresPowerCycle = stagedInjSizePri
|
||||
requiresPowerCycle = stagedInjSizeSec
|
||||
requiresPowerCycle = stagingEnabled
|
||||
requiresPowerCycle = resetLock
|
||||
requiresPowerCycle = resetLockPin
|
||||
|
||||
defaultValue = pinLayout, 1
|
||||
defaultValue = TrigPattern, 0
|
||||
|
@ -801,6 +804,7 @@ page = 10
|
|||
defaultValue = realtime_base_address, 336
|
||||
defaultValue = VVTasOnOff, 0
|
||||
defaultValue = stagingEnabled, 0
|
||||
defaultValue = resetLock, 0
|
||||
; defaultValue = obd_address, 0
|
||||
|
||||
;Default pins
|
||||
|
@ -811,6 +815,7 @@ page = 10
|
|||
defaultValue = fuelPumpPin, 0
|
||||
defaultValue = tachoPin, 0
|
||||
defaultValue = perToothIgn, 0
|
||||
defaultValue = resetLockPin, 0
|
||||
[Menu]
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
|
@ -904,6 +909,10 @@ 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"
|
||||
|
@ -1091,6 +1100,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."
|
||||
|
||||
[UserDefined]
|
||||
|
||||
|
@ -1797,6 +1809,10 @@ 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
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
; General help text
|
||||
|
||||
|
@ -2230,6 +2246,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
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
|
||||
|
@ -2240,7 +2257,7 @@ cmdtestspk450dc = "E\x03\x0C"
|
|||
; you change it.
|
||||
|
||||
ochGetCommand = "r\$tsCanId\x30%2o%2c"
|
||||
ochBlockSize = 81
|
||||
ochBlockSize = 82
|
||||
|
||||
secl = scalar, U08, 0, "sec", 1.000, 0.000
|
||||
status1 = scalar, U08, 1, "bits", 1.000, 0.000
|
||||
|
@ -2327,6 +2344,9 @@ cmdtestspk450dc = "E\x03\x0C"
|
|||
pulseWidth2 = scalar, U16, 75, "ms", 0.001, 0.000
|
||||
pulseWidth3 = scalar, U16, 77, "ms", 0.001, 0.000
|
||||
pulseWidth4 = scalar, U16, 79, "ms", 0.001, 0.000
|
||||
status3 = scalar, U08, 81, "bits", 1.000, 0.000
|
||||
resetLockOn = bits, U08, 81, [0:0]
|
||||
unused81_1-7 = bits, U08, 81, [1:7]
|
||||
|
||||
#if CELSIUS
|
||||
coolant = { coolantRaw - 40 } ; Temperature readings are offset by 40 to allow for negatives
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#define canbusPage 9//Config Page 9
|
||||
#define warmupPage 10 //Config Page 10
|
||||
|
||||
#define SERIAL_PACKET_SIZE 81
|
||||
#define SERIAL_PACKET_SIZE 82
|
||||
|
||||
byte currentPage = 1;//Not the same as the speeduino config page numbers
|
||||
bool isMap = true;
|
||||
|
|
|
@ -457,6 +457,8 @@ void sendValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portNum)
|
|||
fullStatus[79] = lowByte(currentStatus.PW4); //Pulsewidth 4 multiplied by 10 in ms. Have to convert from uS to mS.
|
||||
fullStatus[80] = highByte(currentStatus.PW4); //Pulsewidth 4 multiplied by 10 in ms. Have to convert from uS to mS.
|
||||
|
||||
fullStatus[81] = currentStatus.status3;
|
||||
|
||||
for(byte x=0; x<packetLength; x++)
|
||||
{
|
||||
if (portNum == 0) { Serial.write(fullStatus[offset+x]); }
|
||||
|
@ -1479,4 +1481,4 @@ void commandButtons()
|
|||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,6 +98,14 @@
|
|||
#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_UNUSED2 1
|
||||
#define BIT_STATUS3_UNUSED3 2
|
||||
#define BIT_STATUS3_UNUSED4 3
|
||||
#define BIT_STATUS3_UNUSED5 4
|
||||
#define BIT_STATUS3_UNUSED6 5
|
||||
#define BIT_STATUS3_UNUSED7 6
|
||||
|
||||
#define VALID_MAP_MAX 1022 //The largest ADC value that is valid for the MAP sensor
|
||||
#define VALID_MAP_MIN 2 //The smallest ADC value that is valid for the MAP sensor
|
||||
|
||||
|
@ -137,6 +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 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
|
||||
|
||||
|
@ -299,6 +311,7 @@ struct statuses {
|
|||
uint16_t canin[16]; //16bit raw value of selected canin data for channel 0-15
|
||||
uint8_t current_caninchannel = 0; //start off at channel 0
|
||||
uint16_t crankRPM = 400; //The actual cranking RPM limit. Saves us multiplying it everytime from the config page
|
||||
volatile byte status3;
|
||||
|
||||
//Helpful bitwise operations:
|
||||
//Useful reference: http://playground.arduino.cc/Code/BitMath
|
||||
|
@ -430,7 +443,11 @@ struct config2 {
|
|||
byte sparkDur; //Spark duration in ms * 10
|
||||
byte unused4_8;
|
||||
byte unused4_9;
|
||||
byte unused4_10;
|
||||
|
||||
//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 StgCycles; //The number of initial cycles before the ignition should fire when first cranking
|
||||
|
||||
byte dwellCont : 1; //Fixed duty dwell control
|
||||
|
@ -705,6 +722,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
|
||||
|
||||
// global variables // from speeduino.ino
|
||||
extern struct statuses currentStatus; // from speeduino.ino
|
||||
|
@ -728,4 +746,4 @@ extern byte iatCalibrationTable[CALIBRATION_TABLE_SIZE];
|
|||
extern byte o2CalibrationTable[CALIBRATION_TABLE_SIZE];
|
||||
|
||||
|
||||
#endif // GLOBALS_H
|
||||
#endif // GLOBALS_H
|
||||
|
|
|
@ -664,6 +664,25 @@ void setup()
|
|||
setFuelSchedule2(100, (unsigned long)(configPage1.primePulse * 100));
|
||||
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);
|
||||
}
|
||||
|
@ -1534,7 +1553,17 @@ 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);
|
||||
}
|
||||
} //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);
|
||||
}
|
||||
} //loop()
|
||||
|
||||
/*
|
||||
|
@ -1583,4 +1612,4 @@ static inline unsigned int PW(int REQ_FUEL, byte VE, long MAP, int corrections,
|
|||
}
|
||||
}
|
||||
return (unsigned int)(intermediate);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,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
|
||||
#endif
|
||||
break;
|
||||
case 1:
|
||||
|
@ -112,6 +113,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
|
||||
break;
|
||||
#endif
|
||||
case 2:
|
||||
|
@ -148,6 +150,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
|
||||
|
||||
#if defined(CORE_TEENSY)
|
||||
pinTrigger = 23;
|
||||
|
@ -196,6 +199,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
|
||||
|
||||
#if defined(CORE_TEENSY)
|
||||
pinTrigger = 23;
|
||||
|
@ -305,6 +309,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
|
||||
|
||||
#if defined(CORE_TEENSY)
|
||||
pinTrigger = 23;
|
||||
|
@ -354,6 +359,8 @@ 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
|
||||
|
||||
#endif
|
||||
break;
|
||||
|
||||
|
@ -389,6 +396,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
|
||||
#endif
|
||||
break;
|
||||
|
||||
|
@ -471,6 +479,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
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -503,6 +512,7 @@ void setPinMapping(byte boardID)
|
|||
pinFlex = 3; // Flex sensor (Must be external interrupt enabled)
|
||||
pinBoost = 5;
|
||||
pinIdle1 = 6;
|
||||
pinResetLock = 43; //Reset lock output
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
@ -517,6 +527,7 @@ 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); }
|
||||
|
||||
//Finally, set the relevant pin modes for outputs
|
||||
pinMode(pinCoil1, OUTPUT);
|
||||
|
@ -540,6 +551,7 @@ 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