From 41164740a51062936ed656ba3be1b7e44389c70b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 3 Feb 2016 13:08:19 -0600 Subject: [PATCH] Network: Improve half-second conversion --- net/devif/devif_poll.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/devif/devif_poll.c b/net/devif/devif_poll.c index 32a2eb51ab..38d57e725e 100644 --- a/net/devif/devif_poll.c +++ b/net/devif/devif_poll.c @@ -430,7 +430,6 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback) int devif_timer(FAR struct net_driver_s *dev, devif_poll_callback_t callback) { systime_t now; - systime_t elpased; int bstop = false; int hsec; @@ -441,13 +440,15 @@ int devif_timer(FAR struct net_driver_s *dev, devif_poll_callback_t callback) now = clock_systimer(); hsec = (now - g_polltime) / TICK_PER_HSEC; - /* Update the time only when more than one half second elapses */ + /* Process time-related events only when more than one half second elapses. */ if (hsec > 0) { - /* Save the current time */ + /* Update the current poll time (truncating to the last half second + * boundary to avoid error build-up). + */ - g_polltime = now; + g_polltime += (TICK_PER_HSEC * (systime_t)hsec); /* Perform periodic activitives that depend on hsec > 0 */