mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-21 19:29:18 +00:00
Account for 16 bit rtimer wraparound, else ENERGEST way underreports AVR times.
This commit is contained in:
parent
3ea102050b
commit
2feed121d2
@ -91,7 +91,22 @@ extern energest_t energest_leveldevice_current_leveltime[ENERGEST_CONF_LEVELDEVI
|
||||
energest_current_time[type] = RTIMER_NOW(); \
|
||||
energest_current_mode[type] = 1; \
|
||||
} while(0)
|
||||
#ifdef __AVR__
|
||||
/* Handle 16 bit rtimer wraparound */
|
||||
#define ENERGEST_OFF(type) if(energest_current_mode[type] != 0) do { \
|
||||
if (RTIMER_NOW() < energest_current_time[type]) energest_total_time[type].current += RTIMER_ARCH_SECOND; \
|
||||
energest_total_time[type].current += (rtimer_clock_t)(RTIMER_NOW() - \
|
||||
energest_current_time[type]); \
|
||||
energest_current_mode[type] = 0; \
|
||||
} while(0)
|
||||
|
||||
#define ENERGEST_OFF_LEVEL(type,level) do { \
|
||||
if (RTIMER_NOW() < energest_current_time[type]) energest_total_time[type].current += RTIMER_ARCH_SECOND; \
|
||||
energest_leveldevice_current_leveltime[level].current += (rtimer_clock_t)(RTIMER_NOW() - \
|
||||
energest_current_time[type]); \
|
||||
energest_current_mode[type] = 0; \
|
||||
} while(0)
|
||||
#else
|
||||
#define ENERGEST_OFF(type) if(energest_current_mode[type] != 0) do { \
|
||||
energest_total_time[type].current += (rtimer_clock_t)(RTIMER_NOW() - \
|
||||
energest_current_time[type]); \
|
||||
@ -103,6 +118,7 @@ extern energest_t energest_leveldevice_current_leveltime[ENERGEST_CONF_LEVELDEVI
|
||||
energest_current_time[type]); \
|
||||
energest_current_mode[type] = 0; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
|
||||
#else /* ENERGEST_CONF_ON */
|
||||
|
Loading…
Reference in New Issue
Block a user