MISRA cleanup

This commit is contained in:
Josh Stewart 2018-11-05 16:30:26 +11:00
parent 8ba2d75f47
commit 7820d5c2c4
5 changed files with 11 additions and 23 deletions

View File

@ -26,10 +26,6 @@ void canCommand()
sendcanValues(0, CAN_PACKET_SIZE, 0x30, 1); //send values to serial3 sendcanValues(0, CAN_PACKET_SIZE, 0x30, 1); //send values to serial3
break; break;
//case 'A': // send x bytes of realtime values from the TS list
// sendValues(0, SERIAL_PACKET_SIZE, 0x30, 3); //send values to serial0
// break;
case 'G': // this is the reply command sent by the Can interface case 'G': // this is the reply command sent by the Can interface
byte destcaninchannel; byte destcaninchannel;
if (CANSerial.available() >= 9) if (CANSerial.available() >= 9)

View File

@ -724,12 +724,8 @@ int getCrankAngle_BasicDistributor()
int crankAngle = ((tempToothCurrentCount - 1) * triggerToothAngle) + configPage4.triggerAngle; //Number of teeth that have passed since tooth 1, multiplied by the angle each tooth represents, plus the angle that tooth 1 is ATDC. This gives accuracy only to the nearest tooth. int crankAngle = ((tempToothCurrentCount - 1) * triggerToothAngle) + configPage4.triggerAngle; //Number of teeth that have passed since tooth 1, multiplied by the angle each tooth represents, plus the angle that tooth 1 is ATDC. This gives accuracy only to the nearest tooth.
//Estimate the number of degrees travelled since the last tooth} //Estimate the number of degrees travelled since the last tooth}
elapsedTime = (lastCrankAngleCalc - tempToothLastToothTime); elapsedTime = (lastCrankAngleCalc - tempToothLastToothTime);
//if(elapsedTime < SHRT_MAX ) { crankAngle += div((int)elapsedTime, timePerDegree).quot; } //This option is much faster, but only available for smaller values of elapsedTime
//else { crankAngle += ldiv(elapsedTime, timePerDegree).quot; }
//crankAngle += timeToAngle(elapsedTime, CRANKMATH_METHOD_INTERVAL_REV); //crankAngle += timeToAngle(elapsedTime, CRANKMATH_METHOD_INTERVAL_REV);
crankAngle += timeToAngle(elapsedTime, CRANKMATH_METHOD_INTERVAL_TOOTH); crankAngle += timeToAngle(elapsedTime, CRANKMATH_METHOD_INTERVAL_TOOTH);
@ -2517,7 +2513,6 @@ void triggerPri_Subaru67()
else if(toothCurrentCount == 2) { triggerToothAngle = 93; } //Special case for tooth 2 else if(toothCurrentCount == 2) { triggerToothAngle = 93; } //Special case for tooth 2
else { triggerToothAngle = toothAngles[(toothCurrentCount-1)] - toothAngles[(toothCurrentCount-2)]; } else { triggerToothAngle = toothAngles[(toothCurrentCount-1)] - toothAngles[(toothCurrentCount-2)]; }
triggerToothAngleIsCorrect = true; triggerToothAngleIsCorrect = true;
//triggerToothAngleIsCorrect = false;
} }
@ -2527,7 +2522,7 @@ void triggerPri_Subaru67()
int16_t crankAngle = toothAngles[(toothCurrentCount - 1)] + configPage4.triggerAngle; int16_t crankAngle = toothAngles[(toothCurrentCount - 1)] + configPage4.triggerAngle;
if( (configPage4.sparkMode != IGN_MODE_SEQUENTIAL) ) if( (configPage4.sparkMode != IGN_MODE_SEQUENTIAL) )
{ {
uint16_t crankAngle = ignitionLimits( toothAngles[(toothCurrentCount-1)] ); crankAngle = ignitionLimits( toothAngles[(toothCurrentCount-1)] );
//Handle non-sequential tooth counts //Handle non-sequential tooth counts
if( (configPage4.sparkMode != IGN_MODE_SEQUENTIAL) && (toothCurrentCount > 6) ) { checkPerToothTiming(crankAngle, (toothCurrentCount-6) ); } if( (configPage4.sparkMode != IGN_MODE_SEQUENTIAL) && (toothCurrentCount > 6) ) { checkPerToothTiming(crankAngle, (toothCurrentCount-6) ); }

View File

@ -80,7 +80,8 @@ void initialiseIdle()
FTM2_C1SC &= ~FTM_CSC_MSB; //According to Pg 965 of the K64 datasheet, this should not be needed as MSB is reset to 0 upon reset, but the channel interrupt fails to fire without it FTM2_C1SC &= ~FTM_CSC_MSB; //According to Pg 965 of the K64 datasheet, this should not be needed as MSB is reset to 0 upon reset, but the channel interrupt fails to fire without it
FTM2_C1SC |= FTM_CSC_MSA; //Enable Compare mode FTM2_C1SC |= FTM_CSC_MSA; //Enable Compare mode
//FTM2_C1SC |= FTM_CSC_CHIE; //Enable channel compare interrupt //Enable channel compare interrupt (This is currently disabled as not in use)
//FTM2_C1SC |= FTM_CSC_CHIE;
// enable IRQ Interrupt // enable IRQ Interrupt
NVIC_ENABLE_IRQ(IRQ_FTM2); NVIC_ENABLE_IRQ(IRQ_FTM2);

View File

@ -64,7 +64,7 @@ void initialiseADC()
auxIsEnabled = true; auxIsEnabled = true;
} }
else if ((((configPage9.enable_secondarySerial == 1) || ((configPage9.enable_intcan == 1) && (configPage9.intcan_available == 1))) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&12) == 8) else if ((((configPage9.enable_secondarySerial == 1) || ((configPage9.enable_intcan == 1) && (configPage9.intcan_available == 1))) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&12) == 8)
|| (((configPage9.enable_secondarySerial == 0) && (configPage9.enable_intcan == 1 && configPage9.intcan_available == 0 )) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 2) || (((configPage9.enable_secondarySerial == 0) && ( (configPage9.enable_intcan == 1) && (configPage9.intcan_available == 0) )) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 2)
|| (((configPage9.enable_secondarySerial == 0) && (configPage9.enable_intcan == 0)) && ((configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 2))) || (((configPage9.enable_secondarySerial == 0) && (configPage9.enable_intcan == 0)) && ((configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 2)))
{ //if current input channel is enabled as analog local pin check caninput_selxb(bits 2:3) with &12 and caninput_selxa(bits 0:1) with &3 { //if current input channel is enabled as analog local pin check caninput_selxb(bits 2:3) with &12 and caninput_selxa(bits 0:1) with &3
byte pinNumber = (configPage9.Auxinpina[currentStatus.current_caninchannel]&127); byte pinNumber = (configPage9.Auxinpina[currentStatus.current_caninchannel]&127);
@ -82,7 +82,7 @@ void initialiseADC()
} }
} }
else if ((((configPage9.enable_secondarySerial == 1) || ((configPage9.enable_intcan == 1) && (configPage9.intcan_available == 1))) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&12) == 12) else if ((((configPage9.enable_secondarySerial == 1) || ((configPage9.enable_intcan == 1) && (configPage9.intcan_available == 1))) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&12) == 12)
|| (((configPage9.enable_secondarySerial == 0) && (configPage9.enable_intcan == 1 && configPage9.intcan_available == 0 )) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 3) || (((configPage9.enable_secondarySerial == 0) && ( (configPage9.enable_intcan == 1) && (configPage9.intcan_available == 0) )) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 3)
|| (((configPage9.enable_secondarySerial == 0) && (configPage9.enable_intcan == 0)) && ((configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 3))) || (((configPage9.enable_secondarySerial == 0) && (configPage9.enable_intcan == 0)) && ((configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 3)))
{ //if current input channel is enabled as digital local pin check caninput_selxb(bits 2:3) wih &12 and caninput_selxa(bits 0:1) with &3 { //if current input channel is enabled as digital local pin check caninput_selxb(bits 2:3) wih &12 and caninput_selxa(bits 0:1) with &3
byte pinNumber = (configPage9.Auxinpinb[currentStatus.current_caninchannel]&127); byte pinNumber = (configPage9.Auxinpinb[currentStatus.current_caninchannel]&127);

View File

@ -1033,18 +1033,12 @@ void loop()
if(auxIsEnabled == true) if(auxIsEnabled == true)
{ {
//TODO dazq to clean this right up :)
//check through the Aux input channels if enabed for Can or local use //check through the Aux input channels if enabed for Can or local use
for (byte AuxinChan = 0; AuxinChan <16 ; AuxinChan++) for (byte AuxinChan = 0; AuxinChan <16 ; AuxinChan++)
{ {
currentStatus.current_caninchannel = AuxinChan; currentStatus.current_caninchannel = AuxinChan;
//Dev test use only!
//currentStatus.canin[13] = ((configPage9.Auxinpinb[currentStatus.current_caninchannel]&127)+1);
//currentStatus.canin[14] = (configPage9.caninput_sel[1]);
//currentStatus.canin[12] = (configPage9.caninput_sel[1]&12);
//currentStatus.canin[14] = configPage9.enable_secondarySerial; //> 0)((configPage9.Auxinpinb[currentStatus.current_caninchannel]&127)+1);
//currentStatus.canin[13] = (configPage9.caninput_sel[currentStatus.current_caninchannel]&3);
if (((configPage9.caninput_sel[currentStatus.current_caninchannel]&12) == 4) if (((configPage9.caninput_sel[currentStatus.current_caninchannel]&12) == 4)
&& (((configPage9.enable_secondarySerial == 1) && ((configPage9.enable_intcan == 0)&&(configPage9.intcan_available == 1))) && (((configPage9.enable_secondarySerial == 1) && ((configPage9.enable_intcan == 0)&&(configPage9.intcan_available == 1)))
|| ((configPage9.enable_secondarySerial == 1) && ((configPage9.enable_intcan == 1)&&(configPage9.intcan_available == 1))&& || ((configPage9.enable_secondarySerial == 1) && ((configPage9.enable_intcan == 1)&&(configPage9.intcan_available == 1))&&
@ -1076,7 +1070,7 @@ void loop()
#endif #endif
} }
else if ((((configPage9.enable_secondarySerial == 1) || ((configPage9.enable_intcan == 1) && (configPage9.intcan_available == 1))) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&12) == 8) else if ((((configPage9.enable_secondarySerial == 1) || ((configPage9.enable_intcan == 1) && (configPage9.intcan_available == 1))) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&12) == 8)
|| (((configPage9.enable_secondarySerial == 0) && (configPage9.enable_intcan == 1 && configPage9.intcan_available == 0 )) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 2) || (((configPage9.enable_secondarySerial == 0) && ( (configPage9.enable_intcan == 1) && (configPage9.intcan_available == 0) )) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 2)
|| (((configPage9.enable_secondarySerial == 0) && (configPage9.enable_intcan == 0)) && ((configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 2))) || (((configPage9.enable_secondarySerial == 0) && (configPage9.enable_intcan == 0)) && ((configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 2)))
{ //if current input channel is enabled as analog local pin { //if current input channel is enabled as analog local pin
//read analog channel specified //read analog channel specified
@ -1084,7 +1078,7 @@ void loop()
currentStatus.canin[currentStatus.current_caninchannel] = readAuxanalog(configPage9.Auxinpina[currentStatus.current_caninchannel]&127); currentStatus.canin[currentStatus.current_caninchannel] = readAuxanalog(configPage9.Auxinpina[currentStatus.current_caninchannel]&127);
} }
else if ((((configPage9.enable_secondarySerial == 1) || ((configPage9.enable_intcan == 1) && (configPage9.intcan_available == 1))) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&12) == 12) else if ((((configPage9.enable_secondarySerial == 1) || ((configPage9.enable_intcan == 1) && (configPage9.intcan_available == 1))) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&12) == 12)
|| (((configPage9.enable_secondarySerial == 0) && (configPage9.enable_intcan == 1 && configPage9.intcan_available == 0 )) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 3) || (((configPage9.enable_secondarySerial == 0) && ( (configPage9.enable_intcan == 1) && (configPage9.intcan_available == 0) )) && (configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 3)
|| (((configPage9.enable_secondarySerial == 0) && (configPage9.enable_intcan == 0)) && ((configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 3))) || (((configPage9.enable_secondarySerial == 0) && (configPage9.enable_intcan == 0)) && ((configPage9.caninput_sel[currentStatus.current_caninchannel]&3) == 3)))
{ //if current input channel is enabled as digital local pin { //if current input channel is enabled as digital local pin
//read digital channel specified //read digital channel specified
@ -1271,6 +1265,7 @@ void loop()
PWdivTimerPerDegree = div(currentStatus.PW3, timePerDegree).quot; //Need to redo this for PW3 as it will be dramatically different to PW1 when staging PWdivTimerPerDegree = div(currentStatus.PW3, timePerDegree).quot; //Need to redo this for PW3 as it will be dramatically different to PW1 when staging
injector3StartAngle = calculateInjector3StartAngle(PWdivTimerPerDegree); injector3StartAngle = calculateInjector3StartAngle(PWdivTimerPerDegree);
} }
break;
//2 cylinders //2 cylinders
case 2: case 2:
/* /*
@ -1426,6 +1421,7 @@ void loop()
*/ */
injector4StartAngle = calculateInjector4StartAngle(PWdivTimerPerDegree); injector4StartAngle = calculateInjector4StartAngle(PWdivTimerPerDegree);
break; break;
//Will hit the default case on 1 cylinder or >8 cylinders. Do nothing in these cases //Will hit the default case on 1 cylinder or >8 cylinders. Do nothing in these cases
default: default:
break; break;