|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
30 #include <sys/timerfd.h>
38 #ifndef SYS_TIME_THREAD_PRIO
39 #define SYS_TIME_THREAD_PRIO 29
47 #define NSEC_OF_SEC(sec) ((sec) * 1e9)
54 fd = timerfd_create(CLOCK_MONOTONIC, 0);
56 perror(
"Could not set up timer.");
63 struct itimerspec timer;
65 timer.it_value.tv_sec = 0;
68 timer.it_interval.tv_sec = 0;
71 if (timerfd_settime(
fd, 0, &timer, NULL) == -1) {
72 perror(
"Could not set up timer.");
77 unsigned long long missed;
80 int r = read(
fd, &missed,
sizeof(missed));
82 perror(
"Couldn't read timer!");
85 fprintf(stderr,
"Missed %lld timer events!\n", missed);
103 perror(
"Could not setup sys_time_thread");
107 pthread_setname_np(tid,
"sys_time");
115 clock_gettime(CLOCK_MONOTONIC, &now);
124 d_nsec += 1000000000L;
160 clock_gettime(CLOCK_MONOTONIC, &now);
169 d_nsec += 1000000000L;
171 return d_sec * 1000000 + d_nsec / 1000;
182 clock_gettime(CLOCK_MONOTONIC, &now);
191 d_nsec += 1000000000L;
193 return d_sec * 1000 + d_nsec / 1000000;
uint32_t cpu_ticks_per_sec
cpu ticks per second
struct sys_time_timer timer[SYS_TIME_NB_TIMER]
uint32_t resolution_cpu_ticks
sys_time_timer resolution in cpu ticks
uint32_t duration
in SYS_TIME_TICKS
static uint32_t sys_time_ticks_of_usec(uint32_t usec)
static struct timespec startup_time
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
volatile uint32_t nb_tick
SYS_TIME_TICKS since startup.
Architecture independent timing functions.
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
arch independent LED (Light Emitting Diodes) API
static int get_rt_prio(int prio)
void sys_time_arch_init(void)
#define SYS_TIME_NB_TIMER
volatile uint32_t nb_sec_rem
remainder of seconds since startup in CPU_TICKS
uint32_t end_time
in SYS_TIME_TICKS
#define SYS_TIME_THREAD_PRIO
volatile uint32_t nb_sec
full seconds since startup
static void sys_tick_handler(void)
static uint32_t sys_time_ticks_of_sec(float seconds)
void * sys_time_thread_main(void *data)
static uint32_t cpu_ticks_of_nsec(uint32_t nsec)
float resolution
sys_time_timer resolution in seconds