Index: firmware/App/Services/Timers.c =================================================================== diff -u -r52863cba9685f31136ab3f4b4764a17ccf34fc05 -r57ee0134869672b53ab5b7146b8988ede8f828d6 --- firmware/App/Services/Timers.c (.../Timers.c) (revision 52863cba9685f31136ab3f4b4764a17ccf34fc05) +++ firmware/App/Services/Timers.c (.../Timers.c) (revision 57ee0134869672b53ab5b7146b8988ede8f828d6) @@ -23,7 +23,7 @@ static U32 msTimerCount = 0; /************************************************************************* - * @brief initTimers + * @brief * The initTimers function initializes the Timers module. * @details * Inputs : none @@ -37,7 +37,7 @@ } /************************************************************************* - * @brief incMSTimerCount + * @brief * The incMSTimerCount function increments the ms timer count. * @details * Inputs : none @@ -51,7 +51,7 @@ } /************************************************************************* - * @brief getMSTimerCount + * @brief * The getMSTimerCount function returns the current ms timer count. * @details * Inputs : msTimerCount @@ -65,7 +65,7 @@ } /************************************************************************* - * @brief didTimeout + * @brief * The didTimeout function determines whether a timeout has occurred between \n * a given start count and a given timeout period (in ms). * @details @@ -103,13 +103,13 @@ } /************************************************************************* - * @brief calcTimeSince + * @brief * 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 + * @param startMSCount : the ms count at the start of the period * @return ms since given start time *************************************************************************/ U32 calcTimeSince( U32 startMSCount ) @@ -130,4 +130,31 @@ return result; } +/************************************************************************* + * @brief + * The calcTimeBetween function calculates the time (in ms) from a given start \n + * time until a given end time. + * @details + * Inputs : none + * Outputs : none + * @param startMSCount : the ms count at the start of the period + * @param endMSCount : the ms count at the end of the period + * @return ms between two given times + *************************************************************************/ +U32 calcTimeBetween( U32 startMSCount, U32 endMSCount ) +{ + U32 result; + // no wrap + if ( endMSCount >= startMSCount ) + { + result = endMSCount - startMSCount; + } + else + { + result = ( 0xFFFFFFFF - startMSCount ) + endMSCount + 1; + } + + return result; +} +