diff options
Diffstat (limited to 'cpukit/score/src')
-rw-r--r-- | cpukit/score/src/coretodset.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/coretodtickle.c | 18 |
2 files changed, 13 insertions, 7 deletions
diff --git a/cpukit/score/src/coretodset.c b/cpukit/score/src/coretodset.c index 9708ef9477..8b0928af60 100644 --- a/cpukit/score/src/coretodset.c +++ b/cpukit/score/src/coretodset.c @@ -25,6 +25,7 @@ void _TOD_Set_with_timestamp( const Timestamp_Control *tod ) { + uint32_t nanoseconds = _Timestamp_Get_nanoseconds( tod ); Watchdog_Interval seconds_next = _Timestamp_Get_seconds( tod ); Watchdog_Interval seconds_now; @@ -39,6 +40,7 @@ void _TOD_Set_with_timestamp( _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, seconds_next - seconds_now ); _TOD.now = *tod; + _TOD.seconds_trigger = nanoseconds; _TOD.is_set = true; _TOD_Activate(); diff --git a/cpukit/score/src/coretodtickle.c b/cpukit/score/src/coretodtickle.c index fbf67fda79..d0412f85d4 100644 --- a/cpukit/score/src/coretodtickle.c +++ b/cpukit/score/src/coretodtickle.c @@ -35,23 +35,27 @@ void _TOD_Tickle_ticks( void ) { Timestamp_Control tick; - uint32_t seconds; + uint32_t nanoseconds_per_tick; + + nanoseconds_per_tick = rtems_configuration_get_nanoseconds_per_tick(); /* Convert the tick quantum to a timestamp */ - _Timestamp_Set( &tick, 0, rtems_configuration_get_nanoseconds_per_tick() ); + _Timestamp_Set( &tick, 0, nanoseconds_per_tick ); /* Update the counter of ticks since boot */ _Watchdog_Ticks_since_boot += 1; - /* Update the timespec format uptime */ + /* Update the uptime */ _Timestamp_Add_to( &_TOD.uptime, &tick ); /* we do not care how much the uptime changed */ - /* Update the timespec format TOD */ - seconds = _Timestamp_Add_to_at_tick( &_TOD.now, &tick ); - while ( seconds ) { + /* Update the current TOD */ + _Timestamp_Add_to( &_TOD.now, &tick ); + + _TOD.seconds_trigger += nanoseconds_per_tick; + if ( _TOD.seconds_trigger >= 1000000000UL ) { + _TOD.seconds_trigger -= 1000000000UL; _Watchdog_Tickle_seconds(); - seconds--; } } |