MISRA cleanup

This commit is contained in:
Josh Stewart 2019-12-02 14:47:30 +11:00
parent 8cb7876406
commit df22b1d41b
14 changed files with 71 additions and 66 deletions

View File

@ -94,7 +94,7 @@ No text specified
Rule 9.5
No text specified
Rule 10.1
Arguments of a conditional operation must be of an essentially boolean type
Operations must be of an essentially correct type (Eg no shift on signed values, comparison is not boolean, incrementing/decrementing a bool etc)
Rule 10.2
No text specified
Rule 10.3

View File

@ -38,14 +38,14 @@ void fanControl()
if ( configPage2.fanWhenOff ) { fanPermit = true; }
else { fanPermit = BIT_CHECK(currentStatus.engine, BIT_ENGINE_RUN); }
if ( currentStatus.coolant >= onTemp && fanPermit )
if ( (currentStatus.coolant >= onTemp) && (fanPermit == true) )
{
//Fan needs to be turned on. Checked for normal or inverted fan signal
if( configPage6.fanInv == 0 ) { FAN_PIN_HIGH(); }
else { FAN_PIN_LOW(); }
currentStatus.fanOn = true;
}
else if ( currentStatus.coolant <= offTemp || !fanPermit )
else if ( (currentStatus.coolant <= offTemp) || (!fanPermit) )
{
//Fan needs to be turned off. Checked for normal or inverted fan signal
if( configPage6.fanInv == 0 ) { FAN_PIN_LOW(); }
@ -245,11 +245,12 @@ void vvtControl()
if(currentStatus.vvtTargetAngle > 0)
{
vvtPID.Compute(false);
bool PID_compute = vvtPID.Compute(false);
//vvtPID.Compute2(currentStatus.vvtTargetAngle, currentStatus.vvtAngle, false);
//vvt_pwm_target_value = percentage(40, vvt_pwm_max_count);
//if (currentStatus.vvtAngle > currentStatus.vvtTargetAngle) { vvt_pwm_target_value = 0; }
currentStatus.vvtDuty = (vvt_pwm_value * 100) / vvt_pwm_max_count;
if(PID_compute == true) { currentStatus.vvtDuty = (vvt_pwm_value * 100) / vvt_pwm_max_count; }
}
else
{

View File

@ -160,7 +160,7 @@ void sendcanValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portTy
}
#endif
currentStatus.spark ^= (-currentStatus.hasSync ^ currentStatus.spark) & (1 << BIT_SPARK_SYNC); //Set the sync bit of the Spark variable to match the hasSync variable
currentStatus.spark ^= (-currentStatus.hasSync ^ currentStatus.spark) & (1U << BIT_SPARK_SYNC); //Set the sync bit of the Spark variable to match the hasSync variable
fullStatus[0] = currentStatus.secl; //secl is simply a counter that increments each second. Used to track unexpected resets (Which will reset this count to 0)
fullStatus[1] = currentStatus.status1; //status1 Bitfield

View File

@ -11,7 +11,7 @@ static inline byte correctionsFuel() __attribute__((always_inline));
static inline byte correctionWUE() __attribute__((always_inline)); //Warmup enrichment
static inline byte correctionCranking() __attribute__((always_inline)); //Cranking enrichment
static inline byte correctionASE() __attribute__((always_inline)); //After Start Enrichment
static inline int16_t correctionAccel() __attribute__((always_inline)); //Acceleration Enrichment
static inline uint16_t correctionAccel() __attribute__((always_inline)); //Acceleration Enrichment
static inline byte correctionFloodClear() __attribute__((always_inline)); //Check for flood clear on cranking
static inline byte correctionAFRClosedLoop() __attribute__((always_inline)); //Closed loop AFR adjustment
static inline byte correctionFlex() __attribute__((always_inline)); //Flex fuel adjustment

View File

@ -107,7 +107,6 @@ static inline byte correctionWUE()
{
//This prevents us doing the 2D lookup if we're already up to temp
BIT_CLEAR(currentStatus.engine, BIT_ENGINE_WARMUP);
//WUEValue = WUETable.values[9]; //Set the current value to be whatever the final value on the curve is.
WUEValue = table2D_getRawValue(&WUETable, 9);
}
else
@ -169,10 +168,10 @@ static inline byte correctionASE()
* Calculates the % change of the throttle over time (%/second) and performs a lookup based on this
* When the enrichment is turned on, it runs at that amount for a fixed period of time (taeTime)
*
* @return int16_t The Acceleration enrichment modifier as a %. 100% = No modification.
* As the maximum enrichment amount is +255%, the overall return value from this function can be 100+255=355. Hence this function returns a int16_t rather than byte
* @return uint16_t The Acceleration enrichment modifier as a %. 100% = No modification.
* As the maximum enrichment amount is +255%, the overall return value from this function can be 100+255=355. Hence this function returns a uint16_t rather than byte
*/
static inline int16_t correctionAccel()
static inline uint16_t correctionAccel()
{
int16_t accelValue = 100;
//First, check whether the accel. enrichment is already running
@ -452,9 +451,10 @@ static inline byte correctionAFRClosedLoop()
PID_O2 = (long)(currentStatus.O2);
PID_AFRTarget = (long)(currentStatus.afrTarget);
egoPID.Compute();
bool PID_compute = egoPID.Compute();
//currentStatus.egoCorrection = 100 + PID_output;
AFRValue = 100 + PID_output;
if(PID_compute == true) { AFRValue = 100 + PID_output; }
}
else { AFRValue = 100; } // Occurs if the egoAlgorithm is set to 0 (No Correction)
} //Ignition count check
@ -538,20 +538,20 @@ static inline int8_t correctionIdleAdvance(int8_t advance)
int8_t ignIdleValue = advance;
//Adjust the advance based on idle target rpm.
if( (configPage2.idleAdvEnabled) >= 1 && (currentStatus.runSecs >= configPage2.IdleAdvDelay))
if( (configPage2.idleAdvEnabled >= 1) && (currentStatus.runSecs >= configPage2.IdleAdvDelay))
{
currentStatus.CLIdleTarget = (byte)table2D_getValue(&idleTargetTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET); //All temps are offset by 40 degrees
int idleRPMdelta = (currentStatus.CLIdleTarget - currentStatus.RPM / 10) + 50;
int idleRPMdelta = (currentStatus.CLIdleTarget - (currentStatus.RPM / 10) ) + 50;
// Limit idle rpm delta between -500rpm - 500rpm
if(idleRPMdelta > 100) { idleRPMdelta = 100; }
if(idleRPMdelta < 0) { idleRPMdelta = 0; }
if(configPage2.idleAdvAlgorithm == 0 && ((currentStatus.RPM < (unsigned int)(configPage2.idleAdvRPM * 100)) && (currentStatus.TPS < configPage2.idleAdvTPS))) // TPS based idle state
if( (configPage2.idleAdvAlgorithm == 0) && ((currentStatus.RPM < (unsigned int)(configPage2.idleAdvRPM * 100)) && (currentStatus.TPS < configPage2.idleAdvTPS))) // TPS based idle state
{
int8_t advanceIdleAdjust = (int16_t)(table2D_getValue(&idleAdvanceTable, idleRPMdelta)) - 15;
if(configPage2.idleAdvEnabled == 1) { ignIdleValue = (advance + advanceIdleAdjust); }
else if(configPage2.idleAdvEnabled == 2) { ignIdleValue = advanceIdleAdjust; }
}
else if(configPage2.idleAdvAlgorithm == 1 && (currentStatus.RPM < (unsigned int)(configPage2.idleAdvRPM * 100) && currentStatus.CTPSActive == 1)) // closed throttle position sensor (CTPS) based idle state
else if( (configPage2.idleAdvAlgorithm == 1) && (currentStatus.RPM < (unsigned int)(configPage2.idleAdvRPM * 100) && (currentStatus.CTPSActive == 1) )) // closed throttle position sensor (CTPS) based idle state
{
int8_t advanceIdleAdjust = (int16_t)(table2D_getValue(&idleAdvanceTable, idleRPMdelta)) - 15;
if(configPage2.idleAdvEnabled == 1) { ignIdleValue = (advance + advanceIdleAdjust); }

View File

@ -109,8 +109,8 @@ void doCrankSpeedCalcs()
}
else { angle1 = triggerToothAngle; angle2 = triggerToothAngle; }
long toothDeltaV = (1000000L * angle2 / toothHistory[toothHistoryIndex]) - (1000000L * angle1 / toothHistory[toothHistoryIndex-1]);
long toothDeltaT = toothHistory[toothHistoryIndex];
uint32_t toothDeltaV = (1000000L * angle2 / toothHistory[toothHistoryIndex]) - (1000000L * angle1 / toothHistory[toothHistoryIndex-1]);
uint32_t toothDeltaT = toothHistory[toothHistoryIndex];
//long timeToLastTooth = micros() - toothLastToothTime;
rpmDelta = (toothDeltaV << 10) / (6 * toothDeltaT);

View File

@ -153,7 +153,7 @@ volatile unsigned long lastGap;
volatile unsigned long targetGap;
volatile unsigned long compositeLastToothTime;
volatile int toothCurrentCount = 0; //The current number of teeth (Onec sync has been achieved, this can never actually be 0
volatile uint16_t toothCurrentCount = 0; //The current number of teeth (Onec sync has been achieved, this can never actually be 0
volatile byte toothSystemCount = 0; //Used for decoders such as Audi 135 where not every tooth is used for calculating crank angle. This variable stores the actual number of teeth, not the number being used to calculate crank angle
volatile unsigned long toothSystemLastToothTime = 0; //As below, but used for decoders where not every tooth count is used for calculation
volatile unsigned long toothLastToothTime = 0; //The time (micros()) that the last tooth was registered
@ -171,7 +171,7 @@ volatile unsigned int secondaryToothCount; //Used for identifying the current se
volatile unsigned long secondaryLastToothTime = 0; //The time (micros()) that the last tooth was registered (Cam input)
volatile unsigned long secondaryLastToothTime1 = 0; //The time (micros()) that the last tooth was registered (Cam input)
volatile int triggerActualTeeth;
volatile uint16_t triggerActualTeeth;
volatile unsigned long triggerFilterTime; // The shortest time (in uS) that pulses will be accepted (Used for debounce filtering)
volatile unsigned long triggerSecFilterTime; // The shortest time (in uS) that pulses will be accepted (Used for debounce filtering) for the secondary input
volatile bool validTrigger; //Is set true when the last trigger (Primary or secondary) was valid (ie passed filters)
@ -189,10 +189,10 @@ unsigned long lastCrankAngleCalc;
int16_t lastToothCalcAdvance = 99; //Invalid value here forces calculation of this on first main loop
unsigned long lastVVTtime; //The time between the vvt reference pulse and the last crank pulse
int16_t ignition1EndTooth = 0;
int16_t ignition2EndTooth = 0;
int16_t ignition3EndTooth = 0;
int16_t ignition4EndTooth = 0;
uint16_t ignition1EndTooth = 0;
uint16_t ignition2EndTooth = 0;
uint16_t ignition3EndTooth = 0;
uint16_t ignition4EndTooth = 0;
int16_t toothAngles[24]; //An array for storing fixed tooth angles. Currently sized at 24 for the GM 24X decoder, but may grow later if there are other decoders that use this style

View File

@ -741,7 +741,7 @@ uint16_t getRPM_BasicDistributor()
uint16_t tempRPM;
if( currentStatus.RPM < currentStatus.crankRPM)
{
tempRPM = crankingGetRPM(triggerActualTeeth) << 1; //crankGetRPM uses teeth per 360 degrees. As triggerActualTeeh is total teeth in 720 degrees, we divide the tooth count by 2
tempRPM = crankingGetRPM(triggerActualTeeth) / 2; //crankGetRPM uses teeth per 360 degrees. As triggerActualTeeh is total teeth in 720 degrees, we divide the tooth count by 2
revolutionTime = revolutionTime >> 1; //Revolution time has to be divided by 2 as otherwise it would be over 720 degrees (triggerActualTeeth = nCylinders)
}
else { tempRPM = stdGetRPM(720); } //Multiply RPM by 2 due to tracking over 720 degrees now rather than 360
@ -2251,7 +2251,7 @@ void triggerSetup_non360()
{
triggerToothAngle = (360 * configPage4.TrigAngMul) / configPage4.triggerTeeth; //The number of degrees that passes from tooth to tooth multiplied by the additional multiplier
toothCurrentCount = 255; //Default value
triggerFilterTime = (int)(1000000 / (MAX_RPM / 60 * configPage4.triggerTeeth)); //Trigger filter time is the shortest possible time (in uS) that there can be between crank teeth (ie at max RPM). Any pulses that occur faster than this time will be disgarded as noise
triggerFilterTime = (uint32_t)(1000000 / (MAX_RPM / 60 * configPage4.triggerTeeth)); //Trigger filter time is the shortest possible time (in uS) that there can be between crank teeth (ie at max RPM). Any pulses that occur faster than this time will be disgarded as noise
triggerSecFilterTime = (int)(1000000 / (MAX_RPM / 60 * 2)) / 2; //Same as above, but fixed at 2 teeth on the secondary input and divided by 2 (for cam speed)
secondDerivEnabled = false;
decoderIsSequential = true;
@ -2513,7 +2513,7 @@ int getCrankAngle_Nissan360()
interrupts();
crankAngle = ( (tempToothCurrentCount - 1) * 2) + configPage4.triggerAngle;
unsigned long halfTooth = (tempToothLastToothTime - tempToothLastMinusOneToothTime) >> 1;
unsigned long halfTooth = (tempToothLastToothTime - tempToothLastMinusOneToothTime) / 2;
if (elapsedTime > halfTooth)
{
//Means we're over halfway to the next tooth, so add on 1 degree
@ -2530,15 +2530,15 @@ int getCrankAngle_Nissan360()
void triggerSetEndTeeth_Nissan360()
{
//This uses 4 prior teeth, just to ensure there is sufficient time to set the schedule etc
ignition1EndTooth = ( (ignition1EndAngle - configPage4.triggerAngle) / 2 ) - 4;
ignition2EndTooth = ( (ignition2EndAngle - configPage4.triggerAngle) / 2 ) - 4;
ignition3EndTooth = ( (ignition3EndAngle - configPage4.triggerAngle) / 2 ) - 4;
ignition4EndTooth = ( (ignition4EndAngle - configPage4.triggerAngle) / 2 ) - 4;
if(ignition1EndTooth < 0) { ignition1EndTooth += 360; }
if(ignition2EndTooth < 0) { ignition2EndTooth += 360; }
if(ignition3EndTooth < 0) { ignition3EndTooth += 360; }
if(ignition4EndTooth < 0) { ignition4EndTooth += 360; }
byte offset_teeth = 4;
if((ignition1EndAngle - offset_teeth) > configPage4.triggerAngle) { ignition1EndTooth = ( (ignition1EndAngle - configPage4.triggerAngle) / 2 ) - offset_teeth; }
else { ignition1EndTooth = ( (ignition1EndAngle + 720 - configPage4.triggerAngle) / 2 ) - offset_teeth; }
if((ignition2EndAngle - offset_teeth) > configPage4.triggerAngle) { ignition2EndTooth = ( (ignition2EndAngle - configPage4.triggerAngle) / 2 ) - offset_teeth; }
else { ignition2EndTooth = ( (ignition2EndAngle + 720 - configPage4.triggerAngle) / 2 ) - offset_teeth; }
if((ignition3EndAngle - offset_teeth) > configPage4.triggerAngle) { ignition3EndTooth = ( (ignition3EndAngle - configPage4.triggerAngle) / 2 ) - offset_teeth; }
else { ignition3EndTooth = ( (ignition3EndAngle + 720 - configPage4.triggerAngle) / 2 ) - offset_teeth; }
if((ignition4EndAngle - offset_teeth) > configPage4.triggerAngle) { ignition4EndTooth = ( (ignition4EndAngle - configPage4.triggerAngle) / 2 ) - offset_teeth; }
else { ignition4EndTooth = ( (ignition4EndAngle + 720 - configPage4.triggerAngle) / 2 ) - offset_teeth; }
lastToothCalcAdvance = currentStatus.advance;
}

View File

@ -425,7 +425,7 @@ struct statuses {
byte battery10; /**< The current BRV in volts (multiplied by 10. Eg 12.5V = 125) */
int8_t advance; /**< Signed 8 bit as advance can now go negative (ATDC) */
byte corrections; /**< The total current corrections % amount */
int16_t AEamount; /**< The amount of accleration enrichment currently being applied */
uint16_t AEamount; /**< The amount of accleration enrichment currently being applied. 100=No change. Varies above 255 */
byte egoCorrection; /**< The amount of closed loop AFR enrichment currently being applied */
byte wueCorrection; /**< The amount of warmup enrichment currently being applied */
byte batCorrection; /**< The amount of battery voltage enrichment currently being applied */

View File

@ -38,7 +38,7 @@ struct table2D iacCrankDutyTable;
struct StepperIdle idleStepper;
bool idleOn; //Simply tracks whether idle was on last time around
byte idleInitComplete = 99; //TRacks which idle method was initialised. 99 is a method that will never exist
unsigned int iacStepTime;
unsigned int iacStepTime_uS;
unsigned int iacCoolTime;
unsigned int completedHomeSteps;

View File

@ -109,7 +109,7 @@ void initialiseIdle()
iacCrankStepsTable.axisSize = SIZE_BYTE;
iacCrankStepsTable.values = configPage6.iacCrankSteps;
iacCrankStepsTable.axisX = configPage6.iacCrankBins;
iacStepTime = configPage6.iacStepTime * 1000;
iacStepTime_uS = configPage6.iacStepTime * 1000;
iacCoolTime = configPage9.iacCoolTime * 1000;
completedHomeSteps = 0;
@ -141,7 +141,7 @@ void initialiseIdle()
iacCrankStepsTable.axisSize = SIZE_BYTE;
iacCrankStepsTable.values = configPage6.iacCrankSteps;
iacCrankStepsTable.axisX = configPage6.iacCrankBins;
iacStepTime = configPage6.iacStepTime * 1000;
iacStepTime_uS = configPage6.iacStepTime * 1000;
iacCoolTime = configPage9.iacCoolTime * 1000;
completedHomeSteps = 0;
@ -187,6 +187,7 @@ void idleControl()
}
else { currentStatus.idleUpActive = false; }
bool PID_computed = false;
switch(configPage6.iacAlgorithm)
{
case IAC_ALGORITHM_NONE: //Case 0 is no idle control ('None')
@ -240,18 +241,21 @@ void idleControl()
idle_cl_target_rpm = (uint16_t)currentStatus.CLIdleTarget * 10; //Multiply the byte target value back out by 10
if( (idleCounter & 31) == 1) { idlePID.SetTunings(configPage6.idleKP, configPage6.idleKI, configPage6.idleKD); } //This only needs to be run very infrequently, once every 32 calls to idleControl(). This is approx. once per second
idlePID.Compute(true);
idle_pwm_target_value = idle_pid_target_value;
if( idle_pwm_target_value == 0 )
{
disableIdle();
BIT_CLEAR(currentStatus.spark, BIT_SPARK_IDLE); //Turn the idle control flag off
break;
}
BIT_SET(currentStatus.spark, BIT_SPARK_IDLE); //Turn the idle control flag on
currentStatus.idleLoad = ((unsigned long)(idle_pwm_target_value * 100UL) / idle_pwm_max_count) >> 1;
if(currentStatus.idleUpActive == true) { currentStatus.idleDuty += configPage2.idleUpAdder; } //Add Idle Up amount if active
PID_computed = idlePID.Compute(true);
if(PID_computed == true)
{
idle_pwm_target_value = idle_pid_target_value;
if( idle_pwm_target_value == 0 )
{
disableIdle();
BIT_CLEAR(currentStatus.spark, BIT_SPARK_IDLE); //Turn the idle control flag off
break;
}
BIT_SET(currentStatus.spark, BIT_SPARK_IDLE); //Turn the idle control flag on
currentStatus.idleLoad = ((unsigned long)(idle_pwm_target_value * 100UL) / idle_pwm_max_count) >> 1;
if(currentStatus.idleUpActive == true) { currentStatus.idleDuty += configPage2.idleUpAdder; } //Add Idle Up amount if active
}
idleCounter++;
break;
@ -267,7 +271,7 @@ void idleControl()
if(currentStatus.idleUpActive == true) { idleStepper.targetIdleStep += configPage2.idleUpAdder; } //Add Idle Up amount if active
//limit to the configured max steps. This must include any idle up adder, to prevent over-opening.
if (idleStepper.targetIdleStep > configPage9.iacMaxSteps * 3)
if (idleStepper.targetIdleStep > (configPage9.iacMaxSteps * 3) )
{
idleStepper.targetIdleStep = configPage9.iacMaxSteps * 3;
}
@ -283,18 +287,18 @@ void idleControl()
//Only do a lookup of the required value around 4 times per second. Any more than this can create too much jitter and require a hyster value that is too high
idleStepper.targetIdleStep = table2D_getValue(&iacStepTable, (currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET)) * 3; //All temps are offset by 40 degrees. Step counts are divided by 3 in TS. Multiply back out here
if(currentStatus.idleUpActive == true) { idleStepper.targetIdleStep += configPage2.idleUpAdder; } //Add Idle Up amount if active
iacStepTime = configPage6.iacStepTime * 1000;
iacStepTime_uS = configPage6.iacStepTime * 1000;
iacCoolTime = configPage9.iacCoolTime * 1000;
//limit to the configured max steps. This must include any idle up adder, to prevent over-opening.
if (idleStepper.targetIdleStep > configPage9.iacMaxSteps * 3)
if (idleStepper.targetIdleStep > (configPage9.iacMaxSteps * 3) )
{
idleStepper.targetIdleStep = configPage9.iacMaxSteps * 3;
}
}
doStep();
}
currentStatus.idleLoad = idleStepper.curIdleStep >> 1; //Current step count (Divided by 2 for byte)
currentStatus.idleLoad = idleStepper.curIdleStep / 2; //Current step count (Divided by 2 for byte)
}
//Set or clear the idle active flag
if(idleStepper.targetIdleStep != idleStepper.curIdleStep) { BIT_SET(currentStatus.spark, BIT_SPARK_IDLE); }
@ -309,24 +313,24 @@ void idleControl()
{
//This only needs to be run very infrequently, once every 32 calls to idleControl(). This is approx. once per second
idlePID.SetTunings(configPage6.idleKP, configPage6.idleKI, configPage6.idleKD);
iacStepTime = configPage6.iacStepTime * 1000;
iacStepTime_uS = configPage6.iacStepTime * 1000;
iacCoolTime = configPage9.iacCoolTime * 1000;
}
currentStatus.CLIdleTarget = (byte)table2D_getValue(&iacClosedLoopTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET); //All temps are offset by 40 degrees
idle_cl_target_rpm = (uint16_t)currentStatus.CLIdleTarget * 10; //All temps are offset by 40 degrees
if(currentStatus.idleUpActive == true) { idle_pid_target_value += configPage2.idleUpAdder; } //Add Idle Up amount if active
idlePID.Compute(true);
PID_computed = idlePID.Compute(true);
idleStepper.targetIdleStep = idle_pid_target_value;
//limit to the configured max steps. This must include any idle up adder, to prevent over-opening.
if (idleStepper.targetIdleStep > configPage9.iacMaxSteps * 3)
if (idleStepper.targetIdleStep > (configPage9.iacMaxSteps * 3) )
{
idleStepper.targetIdleStep = configPage9.iacMaxSteps * 3;
}
doStep();
currentStatus.idleLoad = idleStepper.curIdleStep >> 1; //Current step count (Divided by 2 for byte)
currentStatus.idleLoad = idleStepper.curIdleStep / 2; //Current step count (Divided by 2 for byte)
idleCounter++;
}
//Set or clear the idle active flag
@ -378,7 +382,7 @@ static inline byte checkForStepping()
{
if (idleStepper.stepperStatus == STEPPING)
{
timeCheck = iacStepTime;
timeCheck = iacStepTime_uS;
}
else
{
@ -472,7 +476,7 @@ static inline void disableIdle()
if(currentStatus.idleUpActive == true) { idleStepper.targetIdleStep += configPage2.idleUpAdder; } //Add Idle Up amount if active?
//limit to the configured max steps. This must include any idle up adder, to prevent over-opening.
if (idleStepper.targetIdleStep > configPage9.iacMaxSteps * 3)
if (idleStepper.targetIdleStep > (configPage9.iacMaxSteps * 3) )
{
idleStepper.targetIdleStep = configPage9.iacMaxSteps * 3;
}

View File

@ -296,7 +296,7 @@ void initialiseAll()
currentStatus.fuelPumpOn = false;
triggerFilterTime = 0; //Trigger filter time is the shortest possible time (in uS) that there can be between crank teeth (ie at max RPM). Any pulses that occur faster than this time will be disgarded as noise. This is simply a default value, the actual values are set in the setup() functinos of each decoder
dwellLimit_uS = (1000 * configPage4.dwellLimit);
currentStatus.nChannels = (INJ_CHANNELS << 4) + IGN_CHANNELS; //First 4 bits store the number of injection channels, 2nd 4 store the number of ignition channels
currentStatus.nChannels = ((uint8_t)INJ_CHANNELS << 4) + IGN_CHANNELS; //First 4 bits store the number of injection channels, 2nd 4 store the number of ignition channels
fpPrimeTime = 0;
noInterrupts();

View File

@ -12,7 +12,7 @@
#ifndef SPEEDUINO_H
#define SPEEDUINO_H
uint16_t PW(int REQ_FUEL, byte VE, long MAP, int corrections, int injOpen);
uint16_t PW(int REQ_FUEL, byte VE, long MAP, uint16_t corrections, int injOpen);
byte getVE1();
byte getVE2();
byte getAdvance();

View File

@ -1235,7 +1235,7 @@ void loop()
* @param injOpen Injector opening time. The time the injector take to open minus the time it takes to close (Both in uS)
* @return uint16_t The injector pulse width in uS
*/
uint16_t PW(int REQ_FUEL, byte VE, long MAP, int corrections, int injOpen)
uint16_t PW(int REQ_FUEL, byte VE, long MAP, uint16_t corrections, int injOpen)
{
//Standard float version of the calculation
//return (REQ_FUEL * (float)(VE/100.0) * (float)(MAP/100.0) * (float)(TPS/100.0) * (float)(corrections/100.0) + injOpen);
@ -1255,7 +1255,7 @@ uint16_t PW(int REQ_FUEL, byte VE, long MAP, int corrections, int injOpen)
iCorrections = (corrections << 7) / 100;
unsigned long intermediate = ((long)REQ_FUEL * (long)iVE) >> 7; //Need to use an intermediate value to avoid overflowing the long
unsigned long intermediate = ((uint32_t)REQ_FUEL * (uint32_t)iVE) >> 7; //Need to use an intermediate value to avoid overflowing the long
if ( configPage2.multiplyMAP == true ) {
intermediate = (intermediate * (unsigned long)iMAP) >> 7;
}