diff --git a/sw/airborne/arm7/sys_time_hw.h b/sw/airborne/arm7/sys_time_hw.h index d55899d432..356d0e04b0 100644 --- a/sw/airborne/arm7/sys_time_hw.h +++ b/sw/airborne/arm7/sys_time_hw.h @@ -29,7 +29,7 @@ #ifndef SYS_TIME_HW_H #define SYS_TIME_HW_H - +#include "sys_time.h" #include "std.h" #include "LPC21xx.h" #include BOARD_CONFIG @@ -118,25 +118,20 @@ static inline void sys_time_init( void ) { } -#define SYS_TICS_OF_SEC(s) (uint32_t)(s * PCLK / T0_PCLK_DIV + 0.5) -#define SYS_TICS_OF_USEC(us) SYS_TICS_OF_SEC((us) * 1e-6) -#define SYS_TICS_OF_NSEC(ns) SYS_TICS_OF_SEC((ns) * 1e-9) +#define SYS_TICS_OF_SEC(s) (uint32_t)(s * PCLK / T0_PCLK_DIV + 0.5) #define SIGNED_SYS_TICS_OF_SEC(s) (int32_t)(s * PCLK / T0_PCLK_DIV + 0.5) -#define SIGNED_SYS_TICS_OF_USEC(us) SIGNED_SYS_TICS_OF_SEC((us) * 1e-6) -#define SEC_OF_SYS_TICS(st) (st / PCLK * T0_PCLK_DIV) + +#define SEC_OF_SYS_TICS(st) (st / PCLK * T0_PCLK_DIV) #define MSEC_OF_SYS_TICS(st) (st / (PCLK/1000) * T0_PCLK_DIV) #define USEC_OF_SYS_TICS(st) (st / (PCLK/1000000) * T0_PCLK_DIV) #define GET_CUR_TIME_FLOAT() ((float)cpu_time_sec + SEC_OF_SYS_TICS((float)cpu_time_ticks)) -#define FIFTY_MS SYS_TICS_OF_SEC( 50e-3 ) -#define AVR_PERIOD_MS SYS_TICS_OF_SEC( 16.666e-3 ) #ifndef PERIODIC_TASK_PERIOD #define PERIODIC_TASK_PERIOD AVR_PERIOD_MS #endif -#define TIME_TICKS_PER_SEC SYS_TICS_OF_SEC(1) #define InitSysTimePeriodic() last_periodic_event = T0TC; diff --git a/sw/airborne/stm32/sys_time_hw.h b/sw/airborne/stm32/sys_time_hw.h index cd375c1184..33b600d45f 100644 --- a/sw/airborne/stm32/sys_time_hw.h +++ b/sw/airborne/stm32/sys_time_hw.h @@ -30,6 +30,8 @@ #ifndef SYS_TIME_HW_H #define SYS_TIME_HW_H +#include "sys_time.h" + #include #include #include "std.h" @@ -45,8 +47,8 @@ extern void sys_tick_irq_handler(void); extern volatile bool_t sys_time_period_elapsed; extern uint32_t cpu_time_ticks; -#define SYS_TICS_OF_SEC(s) (uint32_t)((s) * AHB_CLK + 0.5) -#define TIME_TICKS_PER_SEC SYS_TICS_OF_SEC(1.) +#define SYS_TICS_OF_SEC(s) (uint32_t)((s) * AHB_CLK + 0.5) +#define SIGNED_SYS_TICS_OF_SEC(s) (int32_t)((s) * AHB_CLK + 0.5) static inline bool_t sys_time_periodic( void ) { if (sys_time_period_elapsed) { diff --git a/sw/airborne/sys_time.h b/sw/airborne/sys_time.h index 9e61935da0..8e0501acd9 100644 --- a/sw/airborne/sys_time.h +++ b/sw/airborne/sys_time.h @@ -35,8 +35,19 @@ extern uint16_t cpu_time_sec; +#define SYS_TICS_OF_USEC(us) SYS_TICS_OF_SEC((us) * 1e-6) +#define SYS_TICS_OF_NSEC(ns) SYS_TICS_OF_SEC((ns) * 1e-9) +#define SIGNED_SYS_TICS_OF_USEC(us) SIGNED_SYS_TICS_OF_SEC((us) * 1e-6) +#define SIGNED_SYS_TICS_OF_NSEC(us) SIGNED_SYS_TICS_OF_SEC((us) * 1e-9) + +#define TIME_TICKS_PER_SEC SYS_TICS_OF_SEC( 1.) +#define FIFTY_MS SYS_TICS_OF_SEC( 50e-3 ) +#define AVR_PERIOD_MS SYS_TICS_OF_SEC( 16.666e-3 ) + #ifndef READYBOARD_SYS_TIME #include "sys_time_hw.h" #endif + + #endif /* SYS_TIME_H */