#include "Timers.h" /** * @addtogroup Timers * @{ */ // ********** private definitions ********** // ********** private data ********** static volatile U32 msTimerCount; ///< 1ms timer counter incremented by TaskTimer.c. /*********************************************************************//** * @brief * The initTimers function initializes the Timers unit. * @details \b Inputs: none * @details \b Outputs: msTimerCount * @return none *************************************************************************/ void initTimers( void ) { msTimerCount = 0; } /*********************************************************************//** * @brief * The incMSTimerCount function increments the ms timer count. * @details \b Inputs: msTimerCount * @details \b Outputs: msTimerCount * @return none *************************************************************************/ void incMSTimerCount( void ) { msTimerCount++; } /*********************************************************************//** * @brief * The getMSTimerCount function returns the current ms timer count. * @details \b Inputs: msTimerCount * @details \b Outputs: none * @return The current 32-bit millisecond timer count. *************************************************************************/ U32 getMSTimerCount( void ) { return msTimerCount; } /*********************************************************************//** * @brief * The didTimeout function determines whether a timeout has occurred between * a given start count and a given timeout period (in ms). * @details \b Inputs: msTimerCount * @details \b Outputs: none * @param startMSCount the ms count at the start of the timeout period * @param timeoutPeriod the period for the timeout (in ms) * @return TRUE if a timeout has occurred, FALSE if not *************************************************************************/ BOOL didTimeout( U32 startMSCount, U32 timeoutPeriod ) { BOOL result = FALSE; U32 currMSCount = msTimerCount; // no wrap if ( currMSCount >= startMSCount ) { if ( ( currMSCount - startMSCount ) >= timeoutPeriod ) { result = TRUE; } } // counter wrapped else { U32 deltaMSCount = ( 0xFFFFFFFF - startMSCount ) + currMSCount + 1; if ( deltaMSCount >= timeoutPeriod ) { result = TRUE; } } return result; } /**@}*/