39 #ifndef SYS_TIME_NB_TIMER
40 #define SYS_TIME_NB_TIMER 16
48 #ifndef SYS_TIME_FREQUENCY
50 #define SYS_TIME_FREQUENCY CH_CFG_ST_FREQUENCY
52 #if defined PERIODIC_FREQUENCY
53 #define SYS_TIME_FREQUENCY (2 * PERIODIC_FREQUENCY)
55 #define SYS_TIME_FREQUENCY 1000
210 #define USEC_OF_SEC(sec) ((sec) * 1e6)
212 #include "mcu_periph/sys_time_arch.h"
218 #define SysTimeTimerStart(_t) { _t = get_sys_time_usec(); }
219 #define SysTimeTimer(_t) ( get_sys_time_usec() - (_t))
220 #define SysTimeTimerStop(_t) { _t = ( get_sys_time_usec() - (_t)); }
static uint32_t msec_of_cpu_ticks(uint32_t cpu_ticks)
static uint32_t cpu_ticks_of_nsec(uint32_t nsec)
float resolution
sys_time_timer resolution in seconds
uint32_t cpu_ticks_per_sec
cpu ticks per second
static float sec_of_sys_time_ticks(uint32_t ticks)
static uint32_t msec_of_sys_time_ticks(uint32_t ticks)
volatile uint32_t nb_tick
SYS_TIME_TICKS since startup.
void sys_time_arch_init(void)
Initialize SysTick.
static float get_sys_time_float(void)
Get the time in seconds since startup.
tid_t sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
uint32_t ticks_per_sec
sys_time ticks per second (SYS_TIME_FREQUENCY)
static uint32_t usec_of_cpu_ticks(uint32_t cpu_ticks)
void(* sys_time_cb)(uint8_t id)
static uint32_t sys_time_ticks_of_msec(uint32_t msec)
uint32_t end_time
in SYS_TIME_TICKS
int8_t tid_t
sys_time timer id type
static int32_t signed_cpu_ticks_of_usec(int32_t usec)
volatile uint32_t nb_sec_rem
remainder of seconds since startup in CPU_TICKS
static uint32_t usec_of_sys_time_ticks(uint32_t ticks)
struct sys_time_timer timer[SYS_TIME_NB_TIMER]
static uint32_t sys_time_ticks_of_sec(float seconds)
static bool sys_time_check_and_ack_timer(tid_t id)
Check if timer has elapsed.
volatile uint32_t nb_sec
full seconds since startup
static uint32_t nsec_of_cpu_ticks(uint32_t cpu_ticks)
#define SYS_TIME_NB_TIMER
uint32_t duration
in SYS_TIME_TICKS
static uint32_t sys_time_ticks_of_usec(uint32_t usec)
static uint32_t cpu_ticks_of_sec(float seconds)
void sys_time_update_timer(tid_t id, float duration)
Update the duration until a timer elapses.
static uint32_t cpu_ticks_of_usec(uint32_t usec)
void sys_time_cancel_timer(tid_t id)
Cancel a system timer by id.
uint32_t resolution_cpu_ticks
sys_time_timer resolution in cpu ticks