2015-02-14 05:11:43 -08:00
# ifndef GLOBALS_H
# define GLOBALS_H
2013-07-08 17:43:41 -07:00
# include <Arduino.h>
2016-05-31 20:19:31 -07:00
//const byte ms_version = 20;
2014-02-06 01:48:19 -08:00
const byte signature = 20 ;
2016-05-31 20:19:31 -07:00
//const char signature[] = "speeduino";
const char displaySignature [ ] = " Speeduino " ;
const char TSfirmwareVersion [ ] = " 2016.05 " ;
2014-02-06 01:48:19 -08:00
const byte data_structure_version = 2 ; //This identifies the data structure when reading / writing.
2015-06-05 00:28:31 -07:00
const byte page_size = 64 ;
const int map_page_size = 288 ;
2013-07-09 17:26:16 -07:00
2013-09-19 03:49:28 -07:00
//Handy bitsetting macros
# define BIT_SET(a,b) ((a) |= (1<<(b)))
# define BIT_CLEAR(a,b) ((a) &= ~(1<<(b)))
2014-05-06 04:07:49 -07:00
# define BIT_CHECK(var,pos) ((var) & (1<<(pos)))
2013-09-19 03:49:28 -07:00
2014-05-06 04:07:49 -07:00
//Define bit positions within engine virable
# define BIT_ENGINE_RUN 0 // Engine running
# define BIT_ENGINE_CRANK 1 // Engine cranking
# define BIT_ENGINE_ASE 2 // after start enrichment (ASE)
# define BIT_ENGINE_WARMUP 3 // Engine in warmup
2016-03-25 14:45:48 -07:00
# define BIT_ENGINE_ACC 4 // in TPS acceleration model
2015-01-27 15:01:12 -08:00
# define BIT_ENGINE_DCC 5 // in deceleration mode
2014-05-06 04:07:49 -07:00
# define BIT_ENGINE_MAP 6 // in MAP acceleration mode
# define BIT_ENGINE_IDLE 7 // idle on
2014-01-29 21:28:21 -08:00
2014-01-30 16:49:50 -08:00
//Define masks for Squirt
2015-10-25 04:13:58 -07:00
# define BIT_SQUIRT_INJ1 0 //inj1 Squirt
# define BIT_SQUIRT_INJ2 1 //inj2 Squirt
# define BIT_SQUIRT_INJ3 2 //inj3 Squirt
# define BIT_SQUIRT_INJ4 3 //inj4 Squirt
2016-04-12 06:22:14 -07:00
# define BIT_SQUIRT_DFCO 4 //Decelleration fuel cutoff
# define BIT_SQUIRT_BOOSTCUT 5 //Fuel component of MAP based boost cut out
2015-10-25 04:13:58 -07:00
# define BIT_SQUIRT_TOOTHLOG1READY 6 //Used to flag if tooth log 1 is ready
# define BIT_SQUIRT_TOOTHLOG2READY 7 //Used to flag if tooth log 2 is ready (Log is not currently used)
2014-01-29 21:28:21 -08:00
2016-03-30 03:34:55 -07:00
//Define masks for spark variable
2016-04-05 03:44:11 -07:00
# define BIT_SPARK_HLAUNCH 0 //Hard Launch indicator
# define BIT_SPARK_SLAUNCH 1 //Soft Launch indicator
2016-03-30 03:34:55 -07:00
# define BIT_SPARK_HRDLIM 2 //Hard limiter indicator
2016-04-05 03:44:11 -07:00
# define BIT_SPARK_SFTLIM 3 //Soft limiter indicator
2016-04-12 06:22:14 -07:00
# define BIT_SPARK_BOOSTCUT 4 //Spark component of MAP based boost cut out
2016-03-30 03:34:55 -07:00
# define BIT_SPARK_UNUSED3 5 //
# define BIT_SPARK_UNUSED4 6 //
# define BIT_SPARK_UNUSED5 7 //
2015-12-12 14:24:08 -08:00
# 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
2015-10-30 02:35:45 -07:00
# define TOOTH_LOG_SIZE 128
# define TOOTH_LOG_BUFFER 256
2015-10-25 12:21:12 -07:00
2016-02-13 21:03:25 -08:00
# define INJ_SIMULTANEOUS 0
# define INJ_SEMISEQUENTIAL 1
# define INJ_SEQUENTIAL 2
2014-05-12 04:28:24 -07:00
# define SIZE_BYTE 8
# define SIZE_INT 16
2014-12-10 15:21:59 -08:00
//Table sizes
# define CALIBRATION_TABLE_SIZE 512
2014-12-15 05:34:02 -08:00
# define CALIBRATION_TEMPERATURE_OFFSET 40 // All temperature measurements are stored offset by 40 degrees. This is so we can use an unsigned byte (0-255) to represent temperature ranges from -40 to 215
2014-12-10 15:21:59 -08:00
2015-01-26 00:40:48 -08:00
# define SERIAL_BUFFER_THRESHOLD 32 // When the serial buffer is filled to greater than this threshold value, the serial processing operations will be performed more urgently in order to avoid it overflowing. Serial buffer is 64 bytes long, so the threshold is set at half this as a reasonable figure
2015-09-29 21:47:48 -07:00
//These are for the direct port manipulation of the injectors and coils
volatile byte * inj1_pin_port ;
volatile byte inj1_pin_mask ;
volatile byte * inj2_pin_port ;
volatile byte inj2_pin_mask ;
volatile byte * inj3_pin_port ;
volatile byte inj3_pin_mask ;
volatile byte * inj4_pin_port ;
volatile byte inj4_pin_mask ;
2015-10-30 02:11:16 -07:00
volatile byte * ign1_pin_port ;
volatile byte ign1_pin_mask ;
2015-12-30 21:25:57 -08:00
volatile byte * ign2_pin_port ;
volatile byte ign2_pin_mask ;
volatile byte * ign3_pin_port ;
volatile byte ign3_pin_mask ;
volatile byte * ign4_pin_port ;
volatile byte ign4_pin_mask ;
2015-10-30 02:11:16 -07:00
2013-07-09 17:26:16 -07:00
//The status struct contains the current values for all 'live' variables
2013-07-16 05:29:17 -07:00
//In current version this is 64 bytes
2013-07-09 17:26:16 -07:00
struct statuses {
volatile boolean hasSync ;
unsigned int RPM ;
2016-05-15 04:05:49 -07:00
long longRPM ;
2015-09-16 05:23:06 -07:00
int mapADC ;
2016-05-31 20:19:31 -07:00
long MAP ; //Has to be a long for PID calcs (Boost control)
int baro ; //Barometric pressure is simply the inital MAP reading, taken before the engine is running
2014-02-13 14:27:33 -08:00
byte TPS ; //The current TPS reading (0% - 100%)
byte TPSlast ; //The previous TPS reading
2015-02-16 21:31:26 -08:00
unsigned long TPS_time ; //The time the TPS sample was taken
unsigned long TPSlast_time ; //The time the previous TPS sample was taken
2014-02-13 14:27:33 -08:00
byte tpsADC ; //0-255 byte representation of the TPS
2014-05-07 05:55:15 -07:00
byte tpsDOT ;
2015-10-21 04:19:15 -07:00
int rpmDOT ;
2013-07-09 17:26:16 -07:00
byte VE ;
2013-09-23 05:23:34 -07:00
byte O2 ;
2015-09-13 16:16:46 -07:00
byte O2_2 ;
2014-12-15 05:34:02 -08:00
int coolant ;
2014-12-10 15:21:59 -08:00
int cltADC ;
2014-12-15 05:34:02 -08:00
int IAT ;
2014-12-10 15:21:59 -08:00
int iatADC ;
int batADC ;
2015-01-12 02:23:25 -08:00
int O2ADC ;
2015-09-13 16:16:46 -07:00
int O2_2ADC ;
2015-02-06 23:16:08 -08:00
int dwell ;
2015-04-21 23:49:10 -07:00
byte dwellCorrection ; //The amount of correction being applied to the dwell time.
2014-10-14 17:49:11 -07:00
byte battery10 ; //The current BRV in volts (multiplied by 10. Eg 12.5V = 125)
2013-09-24 21:56:38 -07:00
byte advance ;
2014-09-20 15:17:14 -07:00
byte corrections ;
2015-01-27 15:01:12 -08:00
byte TAEamount ; //The amount of accleration enrichment currently being applied
2015-02-04 19:09:01 -08:00
byte egoCorrection ; //The amount of closed loop AFR enrichment currently being applied
2015-04-04 03:10:13 -07:00
byte wueCorrection ; //The amount of warmup enrichment currently being applied
byte batCorrection ; //The amount of battery voltage enrichment currently being applied
2015-10-17 15:29:41 -07:00
byte iatCorrection ; //The amount of inlet air temperature adjustment currently being applied
2015-10-18 05:20:16 -07:00
byte launchCorrection ; //The amount of correction being applied if launch control is active
2015-02-05 18:11:16 -08:00
byte afrTarget ;
2016-01-12 22:06:55 -08:00
byte idleDuty ;
2015-01-27 15:01:12 -08:00
unsigned long TAEEndTime ; //The target end time used whenever TAE is turned on
2013-09-17 23:45:53 -07:00
volatile byte squirt ;
2015-02-09 05:01:46 -08:00
volatile byte spark ;
2013-08-25 21:11:47 -07:00
byte engine ;
2014-09-21 12:52:32 -07:00
unsigned int PW ; //In uS
2014-05-08 03:46:38 -07:00
volatile byte runSecs ; //Counter of seconds since cranking commenced (overflows at 255 obviously)
volatile byte secl ; //Continous
2014-02-23 21:15:13 -08:00
volatile int loopsPerSecond ;
2016-04-05 03:44:11 -07:00
boolean launchingSoft ; //True when in launch control soft limit mode
boolean launchingHard ; //True when in launch control hard limit mode
2015-03-01 16:12:39 -08:00
int freeRAM ;
2013-07-09 17:26:16 -07:00
2013-08-25 21:11:47 -07:00
//Helpful bitwise operations:
//Useful reference: http://playground.arduino.cc/Code/BitMath
// y = (x >> n) & 1; // n=0..15. stores nth bit of x in y. y becomes 0 or 1.
// x &= ~(1 << n); // forces nth bit of x to be 0. all other bits left alone.
// x |= (1 << n); // forces nth bit of x to be 1. all other bits left alone.
2013-07-09 17:26:16 -07:00
} ;
2013-07-16 05:29:17 -07:00
//Page 1 of the config - See the ini file for further reference
//This mostly covers off variables that are required for fuel
struct config1 {
2015-12-15 02:10:30 -08:00
byte unused1 ; //Cold cranking pulsewidth modifier. This is added to the fuel pulsewidth when cranking under a certain temp threshold (ms)
byte unused2 ; //Warm cranking pulsewidth modifier. This is added to the fuel pulsewidth when cranking (ms)
2013-07-18 03:36:36 -07:00
byte asePct ; //Afterstart enrichment (%)
2013-07-16 20:09:18 -07:00
byte aseCount ; //Afterstart enrichment cycles. This is the number of ignition cycles that the afterstart enrichment % lasts for
2014-02-26 20:17:14 -08:00
byte wueValues [ 10 ] ; //Warm up enrichment array (10 bytes)
2015-02-06 13:29:51 -08:00
byte crankingPct ; //Cranking enrichment
2015-03-15 04:54:47 -07:00
byte pinMapping ; // The board / ping mapping to be used
2015-06-06 16:53:28 -07:00
byte unused16 ;
2015-05-28 07:15:27 -07:00
byte tdePct ; // TPS decelleration (%)
2013-07-16 05:29:17 -07:00
byte taeColdA ;
byte tpsThresh ;
byte taeTime ;
2015-02-28 13:27:16 -08:00
//Display config bits
byte displayType : 3 ;
byte display1 : 3 ;
byte display2 : 2 ;
2015-06-06 16:53:28 -07:00
2015-02-28 13:27:16 -08:00
byte display3 : 3 ;
byte display4 : 2 ;
byte display5 : 3 ;
2015-06-06 16:53:28 -07:00
2015-02-28 13:27:16 -08:00
byte displayB1 : 4 ;
byte displayB2 : 4 ;
2013-07-16 05:29:17 -07:00
byte reqFuel ;
byte divider ;
2016-05-31 20:19:31 -07:00
byte injTiming : 1 ;
byte multiplyMAP : 1 ;
2016-05-31 21:57:53 -07:00
byte includeAFR : 1 ;
byte unused26 : 5 ;
2015-05-28 07:15:27 -07:00
byte injOpen ; //Injector opening time (ms * 10)
unsigned int inj1Ang ;
unsigned int inj2Ang ;
unsigned int inj3Ang ;
unsigned int inj4Ang ;
2013-09-16 00:39:24 -07:00
//config1 in ini
2015-10-08 18:42:09 -07:00
byte mapSample : 2 ;
2013-09-15 17:18:33 -07:00
byte strokes : 1 ;
byte injType : 1 ;
byte nCylinders : 4 ; //Number of cylinders
2013-09-16 00:39:24 -07:00
//config2 in ini
2016-03-30 03:34:55 -07:00
byte cltType1 : 2 ;
byte matType1 : 2 ;
2013-09-15 17:18:33 -07:00
byte nInjectors : 4 ; //Number of injectors
2013-09-16 00:39:24 -07:00
2013-09-15 17:18:33 -07:00
2013-09-16 00:39:24 -07:00
//config3 in ini
2013-09-15 17:18:33 -07:00
byte engineType : 1 ;
2015-12-14 22:11:33 -08:00
byte egoType_old : 1 ;
2013-09-15 17:18:33 -07:00
byte algorithm : 1 ; //"Speed Density", "Alpha-N"
byte baroCorr : 1 ;
2016-01-04 13:00:47 -08:00
byte injLayout : 2 ;
2013-09-15 17:18:33 -07:00
2013-07-16 05:29:17 -07:00
byte primePulse ;
2015-06-11 20:18:36 -07:00
byte dutyLim ;
2015-06-06 16:53:28 -07:00
byte unused41 ;
2013-07-16 05:29:17 -07:00
byte egoSwitch ;
byte taeColdM ;
2014-02-06 01:48:19 -08:00
byte tpsMin ;
byte tpsMax ;
2015-09-16 05:23:06 -07:00
byte mapMin ;
unsigned int mapMax ;
2015-12-20 20:45:52 -08:00
byte fpPrime ; //Time (In seconds) that the fuel pump should be primed for on power up
2016-06-20 06:32:51 -07:00
byte stoich ;
2015-06-06 16:53:28 -07:00
byte unused51 ;
byte unused52 ;
byte unused53 ;
byte unused54 ;
byte unused55 ;
byte unused56 ;
byte unused57 ;
byte unused58 ;
byte unused59 ;
byte unused60 ;
byte unused61 ;
byte unused62 ;
byte unused63 ;
2013-07-16 05:29:17 -07:00
} ;
//Page 2 of the config - See the ini file for further reference
//This mostly covers off variables that are required for ignition
struct config2 {
2015-05-16 05:06:05 -07:00
int triggerAngle ;
2013-07-16 05:29:17 -07:00
byte FixAng ;
byte CrankAng ;
byte IgHold ;
2013-09-26 04:23:22 -07:00
2015-05-18 05:46:22 -07:00
byte TrigEdge : 1 ;
byte TrigSpeed : 1 ;
2013-09-26 04:23:22 -07:00
byte IgInv : 1 ;
2015-05-18 05:46:22 -07:00
byte oddfire : 1 ;
byte TrigPattern : 4 ;
2013-09-26 04:23:22 -07:00
2013-07-16 05:29:17 -07:00
byte IdleAdv ;
byte IdleAdvTPS ;
byte IdleAdvRPM ;
2014-08-25 05:03:57 -07:00
byte IdleAdvCLT ; //The temperature below which the idle is advanced
2013-07-16 05:29:17 -07:00
byte IdleDelayTime ;
2014-08-25 05:03:57 -07:00
byte StgCycles ; //The number of initial cycles before the ignition should fire when first cranking
2015-09-07 18:17:47 -07:00
byte dwellCont : 1 ; //Fixed duty dwell control
byte useDwellLim : 1 ; //Whether the dwell limiter is off or on
2015-10-28 12:13:13 -07:00
byte sparkMode : 2 ; //Spark output mode (Eg Wasted spark, single channel or Wasted COP)
2016-02-24 18:11:13 -08:00
byte dfcoEnabled : 1 ; //Whether or not DFCO is turned on
2016-04-16 09:38:06 -07:00
byte triggerFilter : 2 ; //The mode of trigger filter being used (0=Off, 1=Light (Not currently used), 2=Normal, 3=Aggressive)
2016-05-29 02:41:31 -07:00
byte ignCranklock : 1 ; //Whether or not the ignition timing during cranking is locked to a CAS pulse. Only currently valid for Basic distributor and 4G63.
2015-09-07 18:17:47 -07:00
2014-08-25 05:03:57 -07:00
byte dwellCrank ; //Dwell time whilst cranking
byte dwellRun ; //Dwell time whilst running
2013-07-16 05:29:17 -07:00
byte triggerTeeth ; //The full count of teeth on the trigger wheel if there were no gaps
byte triggerMissingTeeth ; //The size of the tooth gap (ie number of missing teeth)
2013-09-19 03:49:28 -07:00
byte crankRPM ; //RPM below which the engine is considered to be cranking
byte floodClear ; //TPS value that triggers flood clear mode (No fuel whilst cranking)
2014-01-09 22:17:10 -08:00
byte SoftRevLim ; //Soft rev limit (RPM/100)
byte SoftLimRetard ; //Amount soft limit retards (degrees)
byte SoftLimMax ; //Time the soft limit can run
byte HardRevLim ; //Hard rev limit (RPM/100)
2014-02-17 02:54:28 -08:00
byte taeBins [ 4 ] ; //TPS based acceleration enrichment bins (%/s)
2014-02-26 20:17:14 -08:00
byte taeValues [ 4 ] ; //TPS based acceleration enrichment rates (% to add)
byte wueBins [ 10 ] ; //Warmup Enrichment bins (Values are in configTable1)
2015-02-09 05:19:58 -08:00
byte dwellLimit ;
2015-03-19 21:13:16 -07:00
byte dwellCorrectionValues [ 6 ] ; //Correction table for dwell vs battery voltage
2016-01-02 12:40:27 -08:00
byte iatRetBins [ 6 ] ; // Inlet Air Temp timing retard curve bins
byte iatRetValues [ 6 ] ; // Inlet Air Temp timing retard curve values
2016-02-24 18:11:13 -08:00
byte dfcoRPM ; //RPM at which DFCO turns off/on at
byte dfcoHyster ; //Hysteris RPM for DFCO
byte dfcoTPSThresh ; //TPS must be below this figure for DFCO to engage
2016-04-24 16:09:04 -07:00
byte ignBypassEnabled : 1 ; //Whether or not the ignition bypass is enabled
byte ignBypassPin : 6 ; //Pin the ignition bypass is activated on
byte ignBypassHiLo : 1 ; //Whether this should be active high or low.
2014-02-17 02:54:28 -08:00
2013-07-16 05:29:17 -07:00
2015-02-03 02:33:22 -08:00
} ;
//Page 3 of the config - See the ini file for further reference
//This mostly covers off variables that are required for AFR targets and closed loop
struct config3 {
byte egoAlgorithm : 2 ;
byte egoType : 2 ;
2015-09-26 16:14:29 -07:00
byte boostEnabled : 1 ;
byte vvtEnabled : 1 ;
2016-04-12 06:22:14 -07:00
byte boostCutType : 2 ;
2015-02-03 02:33:22 -08:00
byte egoKP ;
byte egoKI ;
byte egoKD ;
byte egoTemp ; //The temperature above which closed loop functions
byte egoCount ; //The number of ignition cylces per step
byte egoDelta ; //The step size (In %) when using simple algorithm
byte egoLimit ; //Maximum amount the closed loop will vary the fueling
byte ego_min ; //AFR must be above this for closed loop to function
byte ego_max ; //AFR must be below this for closed loop to function
byte ego_sdelay ; //Time in seconds after engine starts that closed loop becomes available
byte egoRPM ; //RPM must be above this for closed loop to function
byte egoTPSMax ; //TPS must be below this for closed loop to function
byte egoLoadMax ; //Load (TPS or MAP) must be below this for closed loop to function
byte egoLoadMin ; //Load (TPS or MAP) must be above this for closed loop to function
2015-03-23 19:12:35 -07:00
byte voltageCorrectionBins [ 6 ] ; //X axis bins for voltage correction tables
2015-04-10 00:26:38 -07:00
byte injVoltageCorrectionValues [ 6 ] ; //Correction table for injector PW vs battery voltage
2015-04-21 23:49:10 -07:00
byte airDenBins [ 9 ] ;
byte airDenRates [ 9 ] ;
2015-09-26 16:14:29 -07:00
byte boostFreq ; //Frequency of the boost PWM valve
byte vvtFreq ; //Frequency of the vvt PWM valve
2015-09-29 00:21:00 -07:00
byte idleFreq ;
2015-10-18 05:20:16 -07:00
byte launchPin : 6 ;
byte launchEnabled : 1 ;
2016-03-25 14:45:48 -07:00
byte launchHiLo : 1 ;
2015-10-18 05:20:16 -07:00
byte lnchSoftLim ;
byte lnchRetard ;
byte lnchHardLim ;
byte lnchFuelAdd ;
2016-04-06 20:28:13 -07:00
//PID values for idle needed to go here as out of room in the idle page
byte idleKP ;
byte idleKI ;
byte idleKD ;
2016-04-12 06:22:14 -07:00
byte boostLimit ; //Is divided by 2, allowing kPa values up to 511
2016-05-15 04:05:49 -07:00
byte boostKP ;
byte boostKI ;
byte boostKD ;
2015-06-06 16:53:28 -07:00
byte unused60 ;
byte unused61 ;
byte unused62 ;
byte unused63 ;
2015-02-03 02:33:22 -08:00
2013-07-16 05:29:17 -07:00
} ;
2014-09-03 15:19:17 -07:00
2015-12-30 21:25:57 -08:00
2015-05-29 00:33:00 -07:00
//Page 4 of the config mostly deals with idle control
2015-08-20 06:21:27 -07:00
//See ini file for further info (Config Page 7 in the ini)
2015-05-29 00:33:00 -07:00
struct config4 {
byte iacCLValues [ 10 ] ; //Closed loop target RPM value
byte iacOLStepVal [ 10 ] ; //Open loop step values for stepper motors
byte iacOLPWMVal [ 10 ] ; //Open loop duty values for PMWM valves
byte iacBins [ 10 ] ; //Temperature Bins for the above 3 curves
byte iacCrankSteps [ 4 ] ; //Steps to use when cranking (Stepper motor)
byte iacCrankDuty [ 4 ] ; //Duty cycle to use on PWM valves when cranking
byte iacCrankBins [ 4 ] ; //Temperature Bins for the above 2 curves
byte iacAlgorithm : 3 ; //Valid values are: "None", "On/Off", "PWM", "PWM Closed Loop", "Stepper", "Stepper Closed Loop"
byte iacStepTime : 3 ; //How long to pulse the stepper for to ensure the step completes (ms)
2016-01-12 22:06:55 -08:00
byte iacChannels : 1 ; //How many outputs to use in PWM mode (0 = 1 channel, 1 = 2 channels)
2016-05-15 02:29:52 -07:00
byte iacPWMdir : 1 ; //Directino of the PWM valve. 0 = Normal = Higher RPM with more duty. 1 = Reverse = Lower RPM with more duty
2015-05-29 00:33:00 -07:00
byte iacFastTemp ; //Fast idle temp when using a simple on/off valve
byte iacStepHome ; //When using a stepper motor, the number of steps to be taken on startup to home the motor
byte iacStepHyster ; //Hysteresis temperature (*10). Eg 2.2C = 22
2015-06-02 05:56:18 -07:00
byte fanInv : 1 ; // Fan output inversion bit
2016-03-30 03:34:55 -07:00
byte fanEnable : 2 ; // Fan enable bit. 0=Off, 1=On/Off, 2=PWM
byte unused : 5 ;
2015-06-02 05:56:18 -07:00
byte fanSP ; // Cooling fan start temperature
byte fanHyster ; // Fan hysteresis
2016-03-30 03:34:55 -07:00
byte fanFreq ; // Fan PWM frequency
byte fanPWMBins [ 4 ] ; //Temperature Bins for the PWM fan control
2015-05-29 00:33:00 -07:00
} ;
2015-03-15 04:54:47 -07:00
byte pinInjector1 ; //Output pin injector 1
byte pinInjector2 ; //Output pin injector 2
byte pinInjector3 ; //Output pin injector 3 is on
byte pinInjector4 ; //Output pin injector 4 is on
2015-03-19 06:35:41 -07:00
byte pinInjector5 ; //Placeholder only - NOT USED
byte pinInjector6 ; //Placeholder only - NOT USED
byte pinInjector7 ; //Placeholder only - NOT USED
byte pinInjector8 ; //Placeholder only - NOT USED
2015-03-15 04:54:47 -07:00
byte pinCoil1 ; //Pin for coil 1
byte pinCoil2 ; //Pin for coil 2
byte pinCoil3 ; //Pin for coil 3
byte pinCoil4 ; //Pin for coil 4
byte pinTrigger ; //The CAS pin
byte pinTrigger2 ; //The Cam Sensor pin
2015-09-13 16:16:46 -07:00
byte pinTrigger3 ; //the 2nd cam sensor pin
2015-03-15 04:54:47 -07:00
byte pinTPS ; //TPS input pin
byte pinMAP ; //MAP sensor pin
2015-03-19 06:35:41 -07:00
byte pinMAP2 ; //2nd MAP sensor (Currently unused)
2015-03-15 04:54:47 -07:00
byte pinIAT ; //IAT sensor pin
byte pinCLT ; //CLS sensor pin
byte pinO2 ; //O2 Sensor pin
2015-09-13 16:16:46 -07:00
byte pinO2_2 ; //second O2 pin
2015-03-15 04:54:47 -07:00
byte pinBat ; //O2 Sensor pin
byte pinDisplayReset ; // OLED reset pin
2015-04-13 21:41:44 -07:00
byte pinTachOut ; //Tacho output
2015-05-16 04:06:23 -07:00
byte pinFuelPump ; //Fuel pump on/off
byte pinIdle1 ; //Single wire idle control
byte pinIdle2 ; //2 wire idle control (Not currently used)
2015-03-19 06:35:41 -07:00
byte pinSpareTemp1 ; // Future use only
byte pinSpareTemp2 ; // Future use only
2015-03-23 19:11:34 -07:00
byte pinSpareOut1 ; //Generic output
byte pinSpareOut2 ; //Generic output
byte pinSpareOut3 ; //Generic output
byte pinSpareOut4 ; //Generic output
byte pinSpareOut5 ; //Generic output
byte pinSpareOut6 ; //Generic output
2015-09-13 16:16:46 -07:00
byte pinSpareHOut1 ; //spare high current output
byte pinSpareHOut2 ; // spare high current output
byte pinSpareLOut1 ; // spare low current output
byte pinSpareLOut2 ; // spare low current output
byte pinSpareLOut3 ;
byte pinSpareLOut4 ;
byte pinSpareLOut5 ;
byte pinBoost ;
2015-09-26 23:41:07 -07:00
byte pinVVT_1 ; // vvt output 1
2015-09-13 16:16:46 -07:00
byte pinVVt_2 ; // vvt output 2
2015-05-30 12:23:33 -07:00
byte pinFan ; // Cooling fan output
2015-08-20 21:14:47 -07:00
byte pinStepperDir ; //Direction pin for the stepper motor driver
byte pinStepperStep ; //Step pin for the stepper motor driver
2015-10-18 05:20:16 -07:00
byte pinLaunch ;
2016-04-24 16:09:04 -07:00
byte pinIgnBypass ; //The pin used for an ignition bypass (Optional)
2015-02-14 05:11:43 -08:00
2015-02-14 09:04:00 -08:00
// global variables // from speeduino.ino
extern struct statuses currentStatus ; // from speeduino.ino
2015-06-05 00:28:31 -07:00
extern struct table3D fuelTable ; //16x16 fuel map
extern struct table3D ignitionTable ; //16x16 ignition map
extern struct table3D afrTable ; //16x16 afr target map
extern struct table2D taeTable ; //4 bin TPS Acceleration Enrichment map (2D)
2015-02-14 09:04:00 -08:00
extern struct table2D WUETable ; //10 bin Warm Up Enrichment map (2D)
extern struct config1 configPage1 ;
extern struct config2 configPage2 ;
extern struct config3 configPage3 ;
extern unsigned long currentLoopTime ; //The time the current loop started (uS)
extern unsigned long previousLoopTime ; //The time the previous loop started (uS)
extern byte ignitionCount ;
extern byte cltCalibrationTable [ CALIBRATION_TABLE_SIZE ] ;
extern byte iatCalibrationTable [ CALIBRATION_TABLE_SIZE ] ;
extern byte o2CalibrationTable [ CALIBRATION_TABLE_SIZE ] ;
2015-02-14 05:11:43 -08:00
# endif // GLOBALS_H