Use the faster div100 function in PW()
This commit is contained in:
parent
1439750731
commit
edd3231102
|
@ -262,7 +262,7 @@ void loop(void)
|
||||||
#endif
|
#endif
|
||||||
readO2();
|
readO2();
|
||||||
readO2_2();
|
readO2_2();
|
||||||
|
|
||||||
#ifdef SD_LOGGING
|
#ifdef SD_LOGGING
|
||||||
if(configPage13.onboard_log_file_rate == LOGGER_RATE_30HZ) { writeSDLogEntry(); }
|
if(configPage13.onboard_log_file_rate == LOGGER_RATE_30HZ) { writeSDLogEntry(); }
|
||||||
#endif
|
#endif
|
||||||
|
@ -1208,11 +1208,12 @@ uint16_t PW(int REQ_FUEL, byte VE, long MAP, uint16_t corrections, int injOpen)
|
||||||
if (corrections > 511 ) { bitShift = 6; }
|
if (corrections > 511 ) { bitShift = 6; }
|
||||||
if (corrections > 1023) { bitShift = 5; }
|
if (corrections > 1023) { bitShift = 5; }
|
||||||
|
|
||||||
iVE = ((unsigned int)VE << 7) / 100;
|
//iVE = ((unsigned int)VE << 7) / 100;
|
||||||
//iVE = divu100(((unsigned int)VE << 7));
|
iVE = div100(((unsigned int)VE << 7));
|
||||||
|
|
||||||
//Check whether either of the multiply MAP modes is turned on
|
//Check whether either of the multiply MAP modes is turned on
|
||||||
if ( configPage2.multiplyMAP == MULTIPLY_MAP_MODE_100) { iMAP = ((unsigned int)MAP << 7) / 100; }
|
//if ( configPage2.multiplyMAP == MULTIPLY_MAP_MODE_100) { iMAP = ((unsigned int)MAP << 7) / 100; }
|
||||||
|
if ( configPage2.multiplyMAP == MULTIPLY_MAP_MODE_100) { iMAP = div100( ((uint16_t)MAP << 7U) ); }
|
||||||
else if( configPage2.multiplyMAP == MULTIPLY_MAP_MODE_BARO) { iMAP = ((unsigned int)MAP << 7) / currentStatus.baro; }
|
else if( configPage2.multiplyMAP == MULTIPLY_MAP_MODE_BARO) { iMAP = ((unsigned int)MAP << 7) / currentStatus.baro; }
|
||||||
|
|
||||||
if ( (configPage2.includeAFR == true) && (configPage6.egoType == EGO_TYPE_WIDE) && (currentStatus.runSecs > configPage6.ego_sdelay) ) {
|
if ( (configPage2.includeAFR == true) && (configPage6.egoType == EGO_TYPE_WIDE) && (currentStatus.runSecs > configPage6.ego_sdelay) ) {
|
||||||
|
@ -1221,8 +1222,8 @@ uint16_t PW(int REQ_FUEL, byte VE, long MAP, uint16_t corrections, int injOpen)
|
||||||
if ( (configPage2.incorporateAFR == true) && (configPage2.includeAFR == false) ) {
|
if ( (configPage2.incorporateAFR == true) && (configPage2.includeAFR == false) ) {
|
||||||
iAFR = ((unsigned int)configPage2.stoich << 7) / currentStatus.afrTarget; //Incorporate stoich vs target AFR, if enabled.
|
iAFR = ((unsigned int)configPage2.stoich << 7) / currentStatus.afrTarget; //Incorporate stoich vs target AFR, if enabled.
|
||||||
}
|
}
|
||||||
iCorrections = (corrections << bitShift) / 100;
|
//iCorrections = (corrections << bitShift) / 100;
|
||||||
//iCorrections = divu100((corrections << bitShift));
|
iCorrections = div100((corrections << bitShift));
|
||||||
|
|
||||||
|
|
||||||
uint32_t intermediate = ((uint32_t)REQ_FUEL * (uint32_t)iVE) >> 7; //Need to use an intermediate value to avoid overflowing the long
|
uint32_t intermediate = ((uint32_t)REQ_FUEL * (uint32_t)iVE) >> 7; //Need to use an intermediate value to avoid overflowing the long
|
||||||
|
@ -1251,9 +1252,9 @@ uint16_t PW(int REQ_FUEL, byte VE, long MAP, uint16_t corrections, int injOpen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( intermediate > 65535)
|
if ( intermediate > UINT16_MAX)
|
||||||
{
|
{
|
||||||
intermediate = 65535; //Make sure this won't overflow when we convert to uInt. This means the maximum pulsewidth possible is 65.535mS
|
intermediate = UINT16_MAX; //Make sure this won't overflow when we convert to uInt. This means the maximum pulsewidth possible is 65.535mS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (unsigned int)(intermediate);
|
return (unsigned int)(intermediate);
|
||||||
|
|
Loading…
Reference in New Issue