TimerTime_t RtcGetTimerValue( void ) { TimerTime_t retVal = 0; retVal = RtcConvertCalendarTickToTimerTime( NULL ); RtcConvertTickToMs( retVal ); return( RtcConvertTickToMs( retVal ) ); }
TimerTime_t RtcGetElapsedAlarmTime( void ) { TimerTime_t currentTime = 0; TimerTime_t contextTime = 0; currentTime = RtcConvertCalendarTickToTimerTime( NULL ); contextTime = RtcConvertCalendarTickToTimerTime( &RtcCalendarContext ); if( currentTime < contextTime ) { return( currentTime + ( 0xFFFFFFFF - contextTime ) ); } else { return( currentTime - contextTime ); } }
TimerTime_t RtcComputeElapsedTime( TimerTime_t eventInTime ) { TimerTime_t elapsedTime = 0; // Needed at boot, cannot compute with 0 or elapsed time will be equal to current time if( eventInTime == 0 ) { return 0; } elapsedTime = RtcConvertCalendarTickToTimerTime( NULL ); if( elapsedTime < eventInTime ) { // roll over of the counter return( elapsedTime + ( 0xFFFFFFFF - eventInTime ) ); } else { return( elapsedTime - eventInTime ); } }
TimerTime_t RtcComputeElapsedTime( TimerTime_t eventInTime ) { TimerTime_t elapsedTime = 0; // Needed at boot, cannot compute with 0 or elapsed time will be equal to current time if( eventInTime == 0 ) { return 0; } // first get the current value of the timer in tick elapsedTime = RtcConvertCalendarTickToTimerTime( NULL ); // convert into ms elapsedTime = RtcConvertTickToMs( elapsedTime ); // compare "eventInTime" with "elapsedTime" while watching for roll over due to 32-bit if( elapsedTime < eventInTime ) // // roll over of the counter { // due to convertion tick to ms, roll over value is 0x7D000000 (0x7D000000 * 2.048 = 0xFFFFFFFF) return( elapsedTime + ( 0x7D000000 - eventInTime ) ); } else { return( elapsedTime - eventInTime ); } }
TimerTime_t RtcGetTimerValue( void ) { return( RtcConvertCalendarTickToTimerTime( NULL ) ); }