Index: firmware/App/Services/Timers.c =================================================================== diff -u -reff7b1575f008f81b29ef906f6346fac6012d3ab -r1156c9be51ef9f40054860355ebee40b49ef03ca --- firmware/App/Services/Timers.c (.../Timers.c) (revision eff7b1575f008f81b29ef906f6346fac6012d3ab) +++ firmware/App/Services/Timers.c (.../Timers.c) (revision 1156c9be51ef9f40054860355ebee40b49ef03ca) @@ -101,3 +101,33 @@ return result; } + +/************************************************************************* + * @brief calcTimeSince + * The calcTimeSince function calculates the time (in ms) from a given start \n + * time until now. + * @details + * Inputs : msTimerCount + * Outputs : none + * @param startMSCount : the ms count at the start of the timeout period + * @return ms since given start time + *************************************************************************/ +U32 calcTimeSince( U32 startMSCount ) +{ + U32 result; + U32 currMSCount = msTimerCount; + + // no wrap + if ( currMSCount >= startMSCount ) + { + result = currMSCount - startMSCount; + } + else + { + result = ( 0xFFFFFFFF - startMSCount ) + currMSCount + 1; + } + + return result; +} + +