From ed28e4d69760f3716c1c6aa40dfd8e5f6233b526 Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Wed, 13 Feb 2013 23:39:35 +0100 Subject: [PATCH] [sys_time] if PERIODIC_FREQUENCY is defined, set default SYS_TIME_RESOLUTION to twice that --- sw/airborne/mcu_periph/sys_time.c | 2 ++ sw/airborne/mcu_periph/sys_time.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/sw/airborne/mcu_periph/sys_time.c b/sw/airborne/mcu_periph/sys_time.c index 6cf939a799..813461d541 100644 --- a/sw/airborne/mcu_periph/sys_time.c +++ b/sw/airborne/mcu_periph/sys_time.c @@ -32,6 +32,8 @@ struct sys_time sys_time; +PRINT_CONFIG_VAR(SYS_TIME_RESOLUTION) + int sys_time_register_timer(float duration, sys_time_cb cb) { uint32_t start_time = sys_time.nb_tick; diff --git a/sw/airborne/mcu_periph/sys_time.h b/sw/airborne/mcu_periph/sys_time.h index ae44b68344..96b1f7be12 100644 --- a/sw/airborne/mcu_periph/sys_time.h +++ b/sw/airborne/mcu_periph/sys_time.h @@ -103,8 +103,12 @@ static inline bool_t sys_time_check_and_ack_timer(tid_t id) { /** system time resolution in seconds */ #ifndef SYS_TIME_RESOLUTION +#if defined PERIODIC_FREQUENCY +#define SYS_TIME_RESOLUTION ( 1./(2*PERIODIC_FREQUENCY) ) +#else #define SYS_TIME_RESOLUTION ( 1./1024. ) #endif +#endif #define SYS_TIME_RESOLUTION_CPU_TICKS CPU_TICKS_OF_SEC(SYS_TIME_RESOLUTION) #define SYS_TIME_TICKS_OF_SEC(s) (uint32_t)((s) / SYS_TIME_RESOLUTION + 0.5)