Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
sys_time_arch.c File Reference
#include "mcu_periph/sys_time.h"
#include "mcu_periph/sys_time_arch.h"
#include <stdio.h>
#include <pthread.h>
#include <sys/timerfd.h>
#include <time.h>
#include "rt_priority.h"
+ Include dependency graph for sys_time_arch.c:

Go to the source code of this file.

Macros

#define SYS_TIME_THREAD_PRIO   29
 
#define NSEC_OF_SEC(sec)   ((sec) * 1e9)
 

Functions

static void sys_tick_handler (void)
 
voidsys_time_thread_main (void *data)
 
void sys_time_arch_init (void)
 
uint32_t get_sys_time_usec (void)
 Get the time in microseconds since startup.
 
uint32_t get_sys_time_usec100 (void)
 Get the time in 100microseconds since startup.
 
uint32_t get_sys_time_msec (void)
 Get the time in milliseconds since startup.
 
void sys_time_usleep (uint32_t us)
 Sleep.
 
void sys_time_msleep (uint32_t ms)
 Sleep.
 

Variables

static struct timespec startup_time
 

Macro Definition Documentation

◆ NSEC_OF_SEC

#define NSEC_OF_SEC (   sec)    ((sec) * 1e9)

Definition at line 48 of file sys_time_arch.c.

◆ SYS_TIME_THREAD_PRIO

#define SYS_TIME_THREAD_PRIO   29

Definition at line 40 of file sys_time_arch.c.

Function Documentation

◆ get_sys_time_msec()

uint32_t get_sys_time_msec ( void  )

Get the time in milliseconds since startup.

Returns
milliseconds since startup as uint32_t

Definition at line 202 of file sys_time_arch.c.

References foo, and startup_time.

◆ get_sys_time_usec()

uint32_t get_sys_time_usec ( void  )

Get the time in microseconds since startup.

WARNING: overflows after 71min34seconds!

Returns
current system time as uint32_t

Definition at line 157 of file sys_time_arch.c.

References foo, and startup_time.

◆ get_sys_time_usec100()

uint32_t get_sys_time_usec100 ( void  )

Get the time in 100microseconds since startup.

Get the time in microseconds since startup.

Get the time in microseconds divided by 100 since startup.

WARNING: overflows after 7000 minutes!

Returns
current system time as uint32_t

Definition at line 180 of file sys_time_arch.c.

References foo, and startup_time.

◆ sys_tick_handler()

◆ sys_time_arch_init()

void sys_time_arch_init ( void  )

Definition at line 94 of file sys_time_arch.c.

References sys_time::cpu_ticks_per_sec, foo, sys_time::resolution, sys_time::resolution_cpu_ticks, startup_time, and sys_time_thread_main().

+ Here is the call graph for this function:

◆ sys_time_msleep()

void sys_time_msleep ( uint32_t  ms)

Sleep.

Parameters
msmilliseconds

Definition at line 225 of file sys_time_arch.c.

References foo, and sys_time_usleep().

+ Here is the call graph for this function:

◆ sys_time_thread_main()

void * sys_time_thread_main ( void data)

Definition at line 50 of file sys_time_arch.c.

References fd, foo, get_rt_prio(), NSEC_OF_SEC, sys_time::resolution, sys_tick_handler(), and SYS_TIME_THREAD_PRIO.

Referenced by sys_time_arch_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sys_time_usleep()

void sys_time_usleep ( uint32_t  us)

Sleep.

Parameters
usmicroseconds

Sleep.

using intermediate 64 bits variable to avoid wrapping

max sleep time is around 10 days (2^32 / CH_CFG_ST_FREQUENCY) at 10kHz

Definition at line 220 of file sys_time_arch.c.

References foo.

Variable Documentation

◆ startup_time

struct timespec startup_time
static