Expand Analog pin range for fuel/oil to A22 and add proper analog translate
This commit is contained in:
parent
f02d75bfbe
commit
324c1523e8
|
@ -1083,9 +1083,10 @@ page = 10
|
||||||
fuelPressureEnable = bits, U08, 135, [0:0], "Off", "On"
|
fuelPressureEnable = bits, U08, 135, [0:0], "Off", "On"
|
||||||
oilPressureEnable = bits, U08, 135, [1:1], "Off", "On"
|
oilPressureEnable = bits, U08, 135, [1:1], "Off", "On"
|
||||||
oilPressureProtEnbl = bits, U08, 135, [2:2], "Off", "On"
|
oilPressureProtEnbl = bits, U08, 135, [2:2], "Off", "On"
|
||||||
|
oilPressurePin = bits, U08, 135, [3:7], "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "A16", "A17", "A18", "A19", "A20", "A21", "A22", INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID
|
||||||
|
|
||||||
|
fuelPressurePin = bits, U08, 136, [0:4], "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "A16", "A17", "A18", "A19", "A20", "A21", "A22", INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID
|
||||||
|
|
||||||
fuelPressurePin = bits, U08, 136, [0:3], "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15"
|
|
||||||
oilPressurePin = bits, U08, 136, [4:7], "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15"
|
|
||||||
|
|
||||||
fuelPressureMin = scalar, S08, 137, "psi", 1.0, 0.0, -100, 127, 0 ;Note signed int
|
fuelPressureMin = scalar, S08, 137, "psi", 1.0, 0.0, -100, 127, 0 ;Note signed int
|
||||||
fuelPressureMax = scalar, U08, 138, "psi", 1.0, 0.0, 0.0, 255, 0
|
fuelPressureMax = scalar, U08, 138, "psi", 1.0, 0.0, 0.0, 255, 0
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
|
||||||
#define BOARD_MAX_DIGITAL_PINS 54 //digital pins +1
|
#define BOARD_MAX_DIGITAL_PINS 54 //digital pins +1
|
||||||
#define BOARD_MAX_IO_PINS 70 //digital pins + analog channels + 1
|
#define BOARD_MAX_IO_PINS 70 //digital pins + analog channels + 1
|
||||||
|
#define BOARD_MAX_ADC_PINS 15 //Number of analog pins
|
||||||
#ifndef LED_BUILTIN
|
#ifndef LED_BUILTIN
|
||||||
#define LED_BUILTIN 13
|
#define LED_BUILTIN 13
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,15 +37,18 @@
|
||||||
#define CORE_TEENSY35
|
#define CORE_TEENSY35
|
||||||
#define BOARD_H "board_teensy35.h"
|
#define BOARD_H "board_teensy35.h"
|
||||||
#define SD_LOGGING //SD logging enabled by default for Teensy 3.5 as it has the slot built in
|
#define SD_LOGGING //SD logging enabled by default for Teensy 3.5 as it has the slot built in
|
||||||
|
#define BOARD_MAX_ADC_PINS 22 //Number of analog pins
|
||||||
#elif defined(__IMXRT1062__)
|
#elif defined(__IMXRT1062__)
|
||||||
#define CORE_TEENSY41
|
#define CORE_TEENSY41
|
||||||
#define BOARD_H "board_teensy41.h"
|
#define BOARD_H "board_teensy41.h"
|
||||||
|
#define BOARD_MAX_ADC_PINS 17 //Number of analog pins
|
||||||
#endif
|
#endif
|
||||||
#define INJ_CHANNELS 8
|
#define INJ_CHANNELS 8
|
||||||
#define IGN_CHANNELS 8
|
#define IGN_CHANNELS 8
|
||||||
|
|
||||||
#elif defined(STM32_MCU_SERIES) || defined(ARDUINO_ARCH_STM32) || defined(STM32)
|
#elif defined(STM32_MCU_SERIES) || defined(ARDUINO_ARCH_STM32) || defined(STM32)
|
||||||
#define CORE_STM32
|
#define CORE_STM32
|
||||||
|
#define BOARD_MAX_ADC_PINS 15 //Number of analog pins. THIS NEEDS CONFIRMING FOR STM32!
|
||||||
#if defined(STM32F407xx) //F407 can do 8x8 STM32F401/STM32F411 not
|
#if defined(STM32F407xx) //F407 can do 8x8 STM32F401/STM32F411 not
|
||||||
#define INJ_CHANNELS 8
|
#define INJ_CHANNELS 8
|
||||||
#define IGN_CHANNELS 8
|
#define IGN_CHANNELS 8
|
||||||
|
@ -643,7 +647,7 @@ struct statuses {
|
||||||
int16_t ignLoad;
|
int16_t ignLoad;
|
||||||
int16_t ignLoad2;
|
int16_t ignLoad2;
|
||||||
bool fuelPumpOn; /**< Indicator showing the current status of the fuel pump */
|
bool fuelPumpOn; /**< Indicator showing the current status of the fuel pump */
|
||||||
byte syncLossCounter;
|
volatile byte syncLossCounter;
|
||||||
byte knockRetard;
|
byte knockRetard;
|
||||||
bool knockActive;
|
bool knockActive;
|
||||||
bool toothLogEnabled;
|
bool toothLogEnabled;
|
||||||
|
@ -1219,10 +1223,10 @@ struct config10 {
|
||||||
byte fuelPressureEnable : 1;
|
byte fuelPressureEnable : 1;
|
||||||
byte oilPressureEnable : 1;
|
byte oilPressureEnable : 1;
|
||||||
byte oilPressureProtEnbl : 1;
|
byte oilPressureProtEnbl : 1;
|
||||||
byte unused10_135 : 5;
|
byte oilPressurePin : 5;
|
||||||
|
|
||||||
byte fuelPressurePin : 4;
|
byte fuelPressurePin : 5;
|
||||||
byte oilPressurePin : 4;
|
byte unused11_165 : 3;
|
||||||
|
|
||||||
int8_t fuelPressureMin;
|
int8_t fuelPressureMin;
|
||||||
byte fuelPressureMax;
|
byte fuelPressureMax;
|
||||||
|
|
|
@ -2398,7 +2398,6 @@ void setPinMapping(byte boardID)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Setup any devices that are using selectable pins
|
//Setup any devices that are using selectable pins
|
||||||
|
|
||||||
if ( (configPage6.launchPin != 0) && (configPage6.launchPin < BOARD_MAX_IO_PINS) ) { pinLaunch = pinTranslate(configPage6.launchPin); }
|
if ( (configPage6.launchPin != 0) && (configPage6.launchPin < BOARD_MAX_IO_PINS) ) { pinLaunch = pinTranslate(configPage6.launchPin); }
|
||||||
|
@ -2408,13 +2407,13 @@ void setPinMapping(byte boardID)
|
||||||
if ( (configPage6.fanPin != 0) && (configPage6.fanPin < BOARD_MAX_IO_PINS) ) { pinFan = pinTranslate(configPage6.fanPin); }
|
if ( (configPage6.fanPin != 0) && (configPage6.fanPin < BOARD_MAX_IO_PINS) ) { pinFan = pinTranslate(configPage6.fanPin); }
|
||||||
if ( (configPage6.boostPin != 0) && (configPage6.boostPin < BOARD_MAX_IO_PINS) ) { pinBoost = pinTranslate(configPage6.boostPin); }
|
if ( (configPage6.boostPin != 0) && (configPage6.boostPin < BOARD_MAX_IO_PINS) ) { pinBoost = pinTranslate(configPage6.boostPin); }
|
||||||
if ( (configPage6.vvt1Pin != 0) && (configPage6.vvt1Pin < BOARD_MAX_IO_PINS) ) { pinVVT_1 = pinTranslate(configPage6.vvt1Pin); }
|
if ( (configPage6.vvt1Pin != 0) && (configPage6.vvt1Pin < BOARD_MAX_IO_PINS) ) { pinVVT_1 = pinTranslate(configPage6.vvt1Pin); }
|
||||||
if ( (configPage6.useExtBaro != 0) && (configPage6.baroPin < BOARD_MAX_IO_PINS) ) { pinBaro = configPage6.baroPin + A0; }
|
if ( (configPage6.useExtBaro != 0) && (configPage6.baroPin < BOARD_MAX_IO_PINS) ) { pinBaro = pinTranslateAnalog(configPage6.baroPin); }
|
||||||
if ( (configPage6.useEMAP != 0) && (configPage10.EMAPPin < BOARD_MAX_IO_PINS) ) { pinEMAP = configPage10.EMAPPin + A0; }
|
if ( (configPage6.useEMAP != 0) && (configPage10.EMAPPin < BOARD_MAX_IO_PINS) ) { pinEMAP = pinTranslateAnalog(configPage10.EMAPPin); }
|
||||||
if ( (configPage10.fuel2InputPin != 0) && (configPage10.fuel2InputPin < BOARD_MAX_IO_PINS) ) { pinFuel2Input = pinTranslate(configPage10.fuel2InputPin); }
|
if ( (configPage10.fuel2InputPin != 0) && (configPage10.fuel2InputPin < BOARD_MAX_IO_PINS) ) { pinFuel2Input = pinTranslate(configPage10.fuel2InputPin); }
|
||||||
if ( (configPage10.spark2InputPin != 0) && (configPage10.spark2InputPin < BOARD_MAX_IO_PINS) ) { pinSpark2Input = pinTranslate(configPage10.spark2InputPin); }
|
if ( (configPage10.spark2InputPin != 0) && (configPage10.spark2InputPin < BOARD_MAX_IO_PINS) ) { pinSpark2Input = pinTranslate(configPage10.spark2InputPin); }
|
||||||
if ( (configPage2.vssPin != 0) && (configPage2.vssPin < BOARD_MAX_IO_PINS) ) { pinVSS = pinTranslate(configPage2.vssPin); }
|
if ( (configPage2.vssPin != 0) && (configPage2.vssPin < BOARD_MAX_IO_PINS) ) { pinVSS = pinTranslate(configPage2.vssPin); }
|
||||||
if ( (configPage10.fuelPressurePin != 0) && (configPage10.fuelPressurePin < BOARD_MAX_IO_PINS) ) { pinFuelPressure = configPage10.fuelPressurePin + A0; }
|
if ( (configPage10.fuelPressureEnable) && (configPage10.fuelPressurePin < BOARD_MAX_IO_PINS) ) { pinFuelPressure = pinTranslateAnalog(configPage10.fuelPressurePin); }
|
||||||
if ( (configPage10.oilPressurePin != 0) && (configPage10.oilPressurePin < BOARD_MAX_IO_PINS) ) { pinOilPressure = configPage10.oilPressurePin + A0; }
|
if ( (configPage10.oilPressureEnable) && (configPage10.oilPressurePin < BOARD_MAX_IO_PINS) ) { pinOilPressure = pinTranslateAnalog(configPage10.oilPressurePin); }
|
||||||
|
|
||||||
if ( (configPage10.wmiEmptyPin != 0) && (configPage10.wmiEmptyPin < BOARD_MAX_IO_PINS) ) { pinWMIEmpty = pinTranslate(configPage10.wmiEmptyPin); }
|
if ( (configPage10.wmiEmptyPin != 0) && (configPage10.wmiEmptyPin < BOARD_MAX_IO_PINS) ) { pinWMIEmpty = pinTranslate(configPage10.wmiEmptyPin); }
|
||||||
if ( (configPage10.wmiIndicatorPin != 0) && (configPage10.wmiIndicatorPin < BOARD_MAX_IO_PINS) ) { pinWMIIndicator = pinTranslate(configPage10.wmiIndicatorPin); }
|
if ( (configPage10.wmiIndicatorPin != 0) && (configPage10.wmiIndicatorPin < BOARD_MAX_IO_PINS) ) { pinWMIIndicator = pinTranslate(configPage10.wmiIndicatorPin); }
|
||||||
|
|
|
@ -27,6 +27,7 @@ uint8_t pinIsValid = 0;
|
||||||
|
|
||||||
void setResetControlPinState();
|
void setResetControlPinState();
|
||||||
byte pinTranslate(byte);
|
byte pinTranslate(byte);
|
||||||
|
byte pinTranslateAnalog(byte);
|
||||||
uint32_t calculateCRC32(byte);
|
uint32_t calculateCRC32(byte);
|
||||||
void initialiseProgrammableIO();
|
void initialiseProgrammableIO();
|
||||||
void checkProgrammableIO();
|
void checkProgrammableIO();
|
||||||
|
|
|
@ -23,6 +23,54 @@ byte pinTranslate(byte rawPin)
|
||||||
|
|
||||||
return outputPin;
|
return outputPin;
|
||||||
}
|
}
|
||||||
|
//Translates an pin number (0 - 22) to the relevant Ax pin reference.
|
||||||
|
//This is required as some ARM chips do not have all analog pins in order (EG pin A15 != A14 + 1)
|
||||||
|
byte pinTranslateAnalog(byte rawPin)
|
||||||
|
{
|
||||||
|
byte outputPin = rawPin;
|
||||||
|
switch(rawPin)
|
||||||
|
{
|
||||||
|
case 0: outputPin = A0; break;
|
||||||
|
case 1: outputPin = A1; break;
|
||||||
|
case 2: outputPin = A2; break;
|
||||||
|
case 3: outputPin = A3; break;
|
||||||
|
case 4: outputPin = A4; break;
|
||||||
|
case 5: outputPin = A5; break;
|
||||||
|
case 6: outputPin = A6; break;
|
||||||
|
case 7: outputPin = A7; break;
|
||||||
|
case 8: outputPin = A8; break;
|
||||||
|
case 9: outputPin = A9; break;
|
||||||
|
case 10: outputPin = A10; break;
|
||||||
|
case 11: outputPin = A11; break;
|
||||||
|
case 12: outputPin = A12; break;
|
||||||
|
case 13: outputPin = A13; break;
|
||||||
|
case 14: outputPin = A14; break;
|
||||||
|
case 15: outputPin = A15; break;
|
||||||
|
#if BOARD_MAX_ADC_PINS >= 16
|
||||||
|
case 16: outputPin = A16; break;
|
||||||
|
#endif
|
||||||
|
#if BOARD_MAX_ADC_PINS >= 17
|
||||||
|
case 17: outputPin = A17; break;
|
||||||
|
#endif
|
||||||
|
#if BOARD_MAX_ADC_PINS >= 18
|
||||||
|
case 18: outputPin = A18; break;
|
||||||
|
#endif
|
||||||
|
#if BOARD_MAX_ADC_PINS >= 19
|
||||||
|
case 19: outputPin = A19; break;
|
||||||
|
#endif
|
||||||
|
#if BOARD_MAX_ADC_PINS >= 20
|
||||||
|
case 20: outputPin = A20; break;
|
||||||
|
#endif
|
||||||
|
#if BOARD_MAX_ADC_PINS >= 21
|
||||||
|
case 21: outputPin = A21; break;
|
||||||
|
#endif
|
||||||
|
#if BOARD_MAX_ADC_PINS >= 22
|
||||||
|
case 22: outputPin = A22; break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputPin;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void setResetControlPinState()
|
void setResetControlPinState()
|
||||||
|
|
Loading…
Reference in New Issue