43 #ifndef SYS_TIME_NB_TIMER
44 #define SYS_TIME_NB_TIMER 16
52 #ifndef SYS_TIME_FREQUENCY
53 #if defined PERIODIC_FREQUENCY
54 #define SYS_TIME_FREQUENCY (2 * PERIODIC_FREQUENCY)
56 #define SYS_TIME_FREQUENCY 1000
219 #define USEC_OF_SEC(sec) ((sec) * 1e6)
221 #include "mcu_periph/sys_time_arch.h"
227 #define SysTimeTimerStart(_t) { _t = get_sys_time_usec(); }
228 #define SysTimeTimer(_t) ( get_sys_time_usec() - (_t))
229 #define SysTimeTimerStop(_t) { _t = ( get_sys_time_usec() - (_t)); }
static uint32_t cpu_ticks
static const float offset[]
volatile uint32_t nb_tick
SYS_TIME_TICKS since startup.
static uint32_t msec_of_cpu_ticks(uint32_t cpu_ticks)
uint32_t ticks_per_sec
sys_time ticks per second (SYS_TIME_FREQUENCY)
static uint32_t nsec_of_cpu_ticks(uint32_t cpu_ticks)
static uint32_t sys_time_ticks_of_sec(float seconds)
void sys_time_update_timer(tid_t id, float duration)
Update the duration until a timer elapses.
volatile uint32_t nb_sec
full seconds since startup
tid_t sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
void(* sys_time_cb)(uint8_t id)
uint32_t cpu_ticks_per_sec
cpu ticks per second
uint32_t duration
in SYS_TIME_TICKS
static uint32_t sys_time_ticks_of_usec(uint32_t usec)
tid_t sys_time_register_timer_offset(tid_t timer, float offset, sys_time_cb cb)
Register a new system timer with an fixed offset from another one.
static bool sys_time_check_and_ack_timer(tid_t id)
Check if timer has elapsed.
uint32_t resolution_cpu_ticks
sys_time_timer resolution in cpu ticks
volatile uint32_t nb_sec_rem
remainder of seconds since startup in CPU_TICKS
float resolution
sys_time_timer resolution in seconds
static uint32_t cpu_ticks_of_usec(uint32_t usec)
void sys_time_arch_init(void)
Initialize SysTick.
#define SYS_TIME_NB_TIMER
static uint32_t msec_of_sys_time_ticks(uint32_t ticks)
static uint32_t cpu_ticks_of_nsec(uint32_t nsec)
static uint32_t sys_time_ticks_of_msec(uint32_t msec)
uint32_t end_time
in SYS_TIME_TICKS
void sys_time_cancel_timer(tid_t id)
Cancel a system timer by id.
static uint32_t cpu_ticks_of_sec(float seconds)
struct sys_time_timer timer[SYS_TIME_NB_TIMER]
static uint32_t usec_of_cpu_ticks(uint32_t cpu_ticks)
static float sec_of_sys_time_ticks(uint32_t ticks)
static uint32_t usec_of_sys_time_ticks(uint32_t ticks)
static float get_sys_time_float(void)
Get the time in seconds since startup.
int8_t tid_t
sys_time timer id type
static int32_t signed_cpu_ticks_of_usec(int32_t usec)
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
signed char int8_t
Typedef defining 8 bit char type.