mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-05 23:49:00 +08:00
moved some arch independant macros up
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#ifndef SYS_TIME_HW_H
|
#ifndef SYS_TIME_HW_H
|
||||||
#define SYS_TIME_HW_H
|
#define SYS_TIME_HW_H
|
||||||
|
#include "sys_time.h"
|
||||||
#include "std.h"
|
#include "std.h"
|
||||||
#include "LPC21xx.h"
|
#include "LPC21xx.h"
|
||||||
#include BOARD_CONFIG
|
#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_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 SIGNED_SYS_TICS_OF_SEC(s) (int32_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 MSEC_OF_SYS_TICS(st) (st / (PCLK/1000) * T0_PCLK_DIV)
|
||||||
#define USEC_OF_SYS_TICS(st) (st / (PCLK/1000000) * 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 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
|
#ifndef PERIODIC_TASK_PERIOD
|
||||||
#define PERIODIC_TASK_PERIOD AVR_PERIOD_MS
|
#define PERIODIC_TASK_PERIOD AVR_PERIOD_MS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TIME_TICKS_PER_SEC SYS_TICS_OF_SEC(1)
|
|
||||||
|
|
||||||
#define InitSysTimePeriodic() last_periodic_event = T0TC;
|
#define InitSysTimePeriodic() last_periodic_event = T0TC;
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,8 @@
|
|||||||
#ifndef SYS_TIME_HW_H
|
#ifndef SYS_TIME_HW_H
|
||||||
#define SYS_TIME_HW_H
|
#define SYS_TIME_HW_H
|
||||||
|
|
||||||
|
#include "sys_time.h"
|
||||||
|
|
||||||
#include <stm32/gpio.h>
|
#include <stm32/gpio.h>
|
||||||
#include <stm32/rcc.h>
|
#include <stm32/rcc.h>
|
||||||
#include "std.h"
|
#include "std.h"
|
||||||
@@ -45,8 +47,8 @@ extern void sys_tick_irq_handler(void);
|
|||||||
extern volatile bool_t sys_time_period_elapsed;
|
extern volatile bool_t sys_time_period_elapsed;
|
||||||
extern uint32_t cpu_time_ticks;
|
extern uint32_t cpu_time_ticks;
|
||||||
|
|
||||||
#define SYS_TICS_OF_SEC(s) (uint32_t)((s) * AHB_CLK + 0.5)
|
#define SYS_TICS_OF_SEC(s) (uint32_t)((s) * AHB_CLK + 0.5)
|
||||||
#define TIME_TICKS_PER_SEC SYS_TICS_OF_SEC(1.)
|
#define SIGNED_SYS_TICS_OF_SEC(s) (int32_t)((s) * AHB_CLK + 0.5)
|
||||||
|
|
||||||
static inline bool_t sys_time_periodic( void ) {
|
static inline bool_t sys_time_periodic( void ) {
|
||||||
if (sys_time_period_elapsed) {
|
if (sys_time_period_elapsed) {
|
||||||
|
|||||||
@@ -35,8 +35,19 @@
|
|||||||
|
|
||||||
extern uint16_t cpu_time_sec;
|
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
|
#ifndef READYBOARD_SYS_TIME
|
||||||
#include "sys_time_hw.h"
|
#include "sys_time_hw.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* SYS_TIME_H */
|
#endif /* SYS_TIME_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user