Further MISRA cleanup work

This commit is contained in:
Josh Stewart 2019-12-15 09:57:22 +11:00
parent fbbeb8a7a1
commit 4be3ffc0e1
8 changed files with 14 additions and 16 deletions

View File

@ -35,7 +35,7 @@ void fanControl()
int offTemp = onTemp - configPage6.fanHyster; int offTemp = onTemp - configPage6.fanHyster;
bool fanPermit = false; bool fanPermit = false;
if ( configPage2.fanWhenOff ) { fanPermit = true; } if ( configPage2.fanWhenOff == true) { fanPermit = true; }
else { fanPermit = BIT_CHECK(currentStatus.engine, BIT_ENGINE_RUN); } else { fanPermit = BIT_CHECK(currentStatus.engine, BIT_ENGINE_RUN); }
if ( (currentStatus.coolant >= onTemp) && (fanPermit == true) ) if ( (currentStatus.coolant >= onTemp) && (fanPermit == true) )

View File

@ -39,7 +39,7 @@ void canCommand()
Gdata[Gx] = CANSerial.read(); Gdata[Gx] = CANSerial.read();
} }
Glow = Gdata[(configPage9.caninput_source_start_byte[destcaninchannel]&7)]; Glow = Gdata[(configPage9.caninput_source_start_byte[destcaninchannel]&7)];
if ((BIT_CHECK(configPage9.caninput_source_num_bytes,destcaninchannel))) //if true then num bytes is 2 if ((BIT_CHECK(configPage9.caninput_source_num_bytes,destcaninchannel) > 0)) //if true then num bytes is 2
{ {
if ((configPage9.caninput_source_start_byte[destcaninchannel]&7) < 8) //you cant have a 2 byte value starting at byte 7(8 on the list) if ((configPage9.caninput_source_start_byte[destcaninchannel]&7) < 8) //you cant have a 2 byte value starting at byte 7(8 on the list)
{ {

View File

@ -1190,7 +1190,7 @@ void sendPageASCII()
Serial.println((const __FlashStringHelper *)&pageTitles[56]); Serial.println((const __FlashStringHelper *)&pageTitles[56]);
Serial.println(configPage4.triggerAngle);// configPsge2.triggerAngle is an int so just display it without complication Serial.println(configPage4.triggerAngle);// configPsge2.triggerAngle is an int so just display it without complication
// Following loop displays byte values after that first int up to but not including the first array in config page 2 // Following loop displays byte values after that first int up to but not including the first array in config page 2
for (pnt_configPage = (int *)&configPage4 + 1; pnt_configPage < &configPage4.taeBins[0]; pnt_configPage = (byte *)pnt_configPage + 1) { Serial.println(*((byte *)pnt_configPage)); } for (pnt_configPage = (byte *)&configPage4 + 1; pnt_configPage < &configPage4.taeBins[0]; pnt_configPage = (byte *)pnt_configPage + 1) { Serial.println(*((byte *)pnt_configPage)); }
for (byte y = 2; y; y--)// Displaying two equal sized arrays for (byte y = 2; y; y--)// Displaying two equal sized arrays
{ {
byte * currentVar;// A placeholder for each array byte * currentVar;// A placeholder for each array

View File

@ -644,7 +644,7 @@ struct config4 {
byte trigPatternSec; //Mode for Missing tooth secondary trigger. Either single tooth cam wheel or 4-1 byte trigPatternSec; //Mode for Missing tooth secondary trigger. Either single tooth cam wheel or 4-1
uint8_t bootloaderCaps; //Capabilities of the bootloader over stock. e.g., 0=Stock, 1=Reset protection, etc. uint8_t bootloaderCaps; //Capabilities of the bootloader over stock. e.g., 0=Stock, 1=Reset protection, etc.
byte resetControl : 2; //Which method of reset control to use (0=None, 1=Prevent When Running, 2=Prevent Always, 3=Serial Command) byte resetControlConfig : 2; //Which method of reset control to use (0=None, 1=Prevent When Running, 2=Prevent Always, 3=Serial Command)
byte resetControlPin : 6; byte resetControlPin : 6;
byte StgCycles; //The number of initial cycles before the ignition should fire when first cranking byte StgCycles; //The number of initial cycles before the ignition should fire when first cranking

View File

@ -39,7 +39,7 @@ struct StepperIdle idleStepper;
bool idleOn; //Simply tracks whether idle was on last time around 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 byte idleInitComplete = 99; //TRacks which idle method was initialised. 99 is a method that will never exist
unsigned int iacStepTime_uS; unsigned int iacStepTime_uS;
unsigned int iacCoolTime; unsigned int iacCoolTime_uS;
unsigned int completedHomeSteps; unsigned int completedHomeSteps;
volatile PORT_TYPE *idle_pin_port; volatile PORT_TYPE *idle_pin_port;

View File

@ -110,7 +110,7 @@ void initialiseIdle()
iacCrankStepsTable.values = configPage6.iacCrankSteps; iacCrankStepsTable.values = configPage6.iacCrankSteps;
iacCrankStepsTable.axisX = configPage6.iacCrankBins; iacCrankStepsTable.axisX = configPage6.iacCrankBins;
iacStepTime_uS = configPage6.iacStepTime * 1000; iacStepTime_uS = configPage6.iacStepTime * 1000;
iacCoolTime = configPage9.iacCoolTime * 1000; iacCoolTime_uS = configPage9.iacCoolTime * 1000;
completedHomeSteps = 0; completedHomeSteps = 0;
idleStepper.curIdleStep = 0; idleStepper.curIdleStep = 0;
@ -142,7 +142,7 @@ void initialiseIdle()
iacCrankStepsTable.values = configPage6.iacCrankSteps; iacCrankStepsTable.values = configPage6.iacCrankSteps;
iacCrankStepsTable.axisX = configPage6.iacCrankBins; iacCrankStepsTable.axisX = configPage6.iacCrankBins;
iacStepTime_uS = configPage6.iacStepTime * 1000; iacStepTime_uS = configPage6.iacStepTime * 1000;
iacCoolTime = configPage9.iacCoolTime * 1000; iacCoolTime_uS = configPage9.iacCoolTime * 1000;
completedHomeSteps = 0; completedHomeSteps = 0;
idleCounter = 0; idleCounter = 0;
@ -288,7 +288,7 @@ void idleControl()
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 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 if(currentStatus.idleUpActive == true) { idleStepper.targetIdleStep += configPage2.idleUpAdder; } //Add Idle Up amount if active
iacStepTime_uS = configPage6.iacStepTime * 1000; iacStepTime_uS = configPage6.iacStepTime * 1000;
iacCoolTime = configPage9.iacCoolTime * 1000; iacCoolTime_uS = configPage9.iacCoolTime * 1000;
//limit to the configured max steps. This must include any idle up adder, to prevent over-opening. //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) )
@ -314,7 +314,7 @@ void idleControl()
//This only needs to be run very infrequently, once every 32 calls to idleControl(). This is approx. once per second //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); idlePID.SetTunings(configPage6.idleKP, configPage6.idleKI, configPage6.idleKD);
iacStepTime_uS = configPage6.iacStepTime * 1000; iacStepTime_uS = configPage6.iacStepTime * 1000;
iacCoolTime = configPage9.iacCoolTime * 1000; iacCoolTime_uS = configPage9.iacCoolTime * 1000;
} }
currentStatus.CLIdleTarget = (byte)table2D_getValue(&iacClosedLoopTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET); //All temps are offset by 40 degrees currentStatus.CLIdleTarget = (byte)table2D_getValue(&iacClosedLoopTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET); //All temps are offset by 40 degrees
@ -386,7 +386,7 @@ static inline byte checkForStepping()
} }
else else
{ {
timeCheck = iacCoolTime; timeCheck = iacCoolTime_uS;
} }
if(micros_safe() > (idleStepper.stepStartTime + timeCheck) ) if(micros_safe() > (idleStepper.stepStartTime + timeCheck) )
@ -398,7 +398,7 @@ static inline byte checkForStepping()
idleStepper.stepStartTime = micros_safe(); idleStepper.stepStartTime = micros_safe();
// if there is no cool time we can miss that step out completely. // if there is no cool time we can miss that step out completely.
if (iacCoolTime > 0) if (iacCoolTime_uS > 0)
{ {
idleStepper.stepperStatus = COOLING; //'Cooling' is the time the stepper needs to sit in LOW state before the next step can be made idleStepper.stepperStatus = COOLING; //'Cooling' is the time the stepper needs to sit in LOW state before the next step can be made
} }

View File

@ -310,7 +310,7 @@ static inline void readMAP()
} }
} }
else { instanteneousMAPReading(); } else { instanteneousMAPReading(); }
break;
default: default:
//Instantaneous MAP readings (Just in case) //Instantaneous MAP readings (Just in case)

View File

@ -433,9 +433,8 @@ void loadConfig()
//Create a pointer to the config page //Create a pointer to the config page
byte* pnt_configPage; byte* pnt_configPage;
//Fuel table (See storage.h for data layout) //Fuel table (See storage.h for data layout)
for(int x=EEPROM_CONFIG1_MAP; x<EEPROM_CONFIG1_XBINS; x++) for(uint16_t x=EEPROM_CONFIG1_MAP; x<EEPROM_CONFIG1_XBINS; x++)
{ {
offset = x - EEPROM_CONFIG1_MAP; offset = x - EEPROM_CONFIG1_MAP;
fuelTable.values[15-(offset/16)][offset%16] = EEPROM.read(x); //Read the 8x8 map fuelTable.values[15-(offset/16)][offset%16] = EEPROM.read(x); //Read the 8x8 map
@ -452,14 +451,13 @@ void loadConfig()
offset = x - EEPROM_CONFIG1_YBINS; offset = x - EEPROM_CONFIG1_YBINS;
fuelTable.axisY[offset] = EEPROM.read(x) * TABLE_LOAD_MULTIPLIER; fuelTable.axisY[offset] = EEPROM.read(x) * TABLE_LOAD_MULTIPLIER;
} }
pnt_configPage = (byte *)&configPage2; //Create a pointer to Page 1 in memory pnt_configPage = (byte *)&configPage2; //Create a pointer to Page 1 in memory
for(int x=EEPROM_CONFIG2_START; x<EEPROM_CONFIG2_END; x++) for(int x=EEPROM_CONFIG2_START; x<EEPROM_CONFIG2_END; x++)
{ {
*(pnt_configPage + byte(x - EEPROM_CONFIG2_START)) = EEPROM.read(x); *(pnt_configPage + byte(x - EEPROM_CONFIG2_START)) = EEPROM.read(x);
} }
//That concludes the reading of the VE table //That concludes the reading of the VE table
//********************************************************************************************************************************************************************************* //*********************************************************************************************************************************************************************************
//IGNITION CONFIG PAGE (2) //IGNITION CONFIG PAGE (2)