diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index dc1c5b9a70..a8ceef02d1 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -37,20 +37,7 @@ // return interpolate(5000, 1.1, 8000, 1, rpm); // return interpolate(500, 0.5, 5000, 1.1, rpm); //} -/** - * @return time needed to rotate crankshaft by one degree, in milliseconds. - * @deprecated - */ -float getOneDegreeTimeMs(int rpm) { - return 1000.0f * 60 / 360 / rpm; -} -/** - * @return time needed to rotate crankshaft by one degree, in microseconds. - */ -float getOneDegreeTimeUs(int rpm) { - return 1000000.0f * 60 / 360 / rpm; -} /** * @return number of milliseconds in one crankshaft revolution diff --git a/firmware/controllers/math/engine_math.h b/firmware/controllers/math/engine_math.h index 4f3a19dbd7..bb47bb2c13 100644 --- a/firmware/controllers/math/engine_math.h +++ b/firmware/controllers/math/engine_math.h @@ -32,8 +32,22 @@ extern "C" float getDefaultFuel(int rpm, float map); -float getOneDegreeTimeMs(int rpm); -float getOneDegreeTimeUs(int rpm); +/** + * So that's how 'inline' syntax for both GCC and IAR + * It is interesting to mention that GCC compiler chooses not to inline this function. + * + * @return time needed to rotate crankshaft by one degree, in milliseconds. + * @deprecated use at least Us, maybe event Nt + */ +inline float getOneDegreeTimeMs(int rpm) { + return 1000.0f * 60 / 360 / rpm; +} + +/** + * @return time needed to rotate crankshaft by one degree, in microseconds. + */ +#define getOneDegreeTimeUs(rpm) (1000000.0f * 60 / 360 / (rpm)) + float getCrankshaftRevolutionTimeMs(int rpm); int isCrankingRT(engine_configuration_s *engineConfiguration, int rpm); diff --git a/firmware/controllers/trigger/rpm_calculator.cpp b/firmware/controllers/trigger/rpm_calculator.cpp index a5ec834c4b..6ddb5c6325 100644 --- a/firmware/controllers/trigger/rpm_calculator.cpp +++ b/firmware/controllers/trigger/rpm_calculator.cpp @@ -173,11 +173,9 @@ int getRevolutionCounter(void) { * @return Current crankshaft angle, 0 to 720 for four-stroke */ float getCrankshaftAngle(uint64_t timeUs) { - uint64_t timeSinceZeroAngle = timeUs - rpmState.lastRpmEventTimeUs; + uint64_t timeSinceZeroAngleUs = timeUs - rpmState.lastRpmEventTimeUs; - float cRevolutionTimeMs = getCrankshaftRevolutionTimeMs(rpmState.rpm()); - - return 360.0 * timeSinceZeroAngle / cRevolutionTimeMs / 1000; + return timeSinceZeroAngleUs / getOneDegreeTimeUs(rpmState.rpm()); } void initRpmCalculator(void) { diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index fa5a610246..5b730c0d1b 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -235,5 +235,5 @@ void firmwareError(const char *fmt, ...) { } int getRusEfiVersion(void) { - return 20140911; + return 20140912; } diff --git a/firmware/svnversion.h b/firmware/svnversion.h index 903015d194..3e5ff8792a 100644 --- a/firmware/svnversion.h +++ b/firmware/svnversion.h @@ -1,5 +1,5 @@ // This file was generated by Version2Header -// Thu Sep 11 18:42:44 EDT 2014 +// Fri Sep 12 10:36:39 EDT 2014 #ifndef VCS_VERSION -#define VCS_VERSION "4633" +#define VCS_VERSION "4660" #endif