17#ifndef KERNEL_DEVICES_TIMER_H
18#define KERNEL_DEVICES_TIMER_H
21#include <kernel/types.h>
24#define HZ CLOCK_PER_SECOND
27#define SEC_TO_TICKS(_time) SEC((_time) * HZ)
28#define MS_TO_TICKS(_time) MS_TO_SEC(SEC_TO_TICKS(_time))
29#define US_TO_TICKS(_time) US_TO_SEC(SEC_TO_TICKS(_time))
30#define NS_TO_TICKS(_time) NS_TO_SEC(SEC_TO_TICKS(_time))
34#define TICKS_TO_SEC(_ticks) SEC((_ticks) / HZ)
35#define TICKS_TO_MS(_ticks) MS(TICKS_TO_SEC(_ticks))
36#define TICKS_TO_US(_ticks) US(TICKS_TO_SEC(_ticks))
37#define TICKS_TO_NS(_ticks) NS(TICKS_TO_SEC(_ticks))
104 time->tv_nsec = ns %
NS(1);
121void timer_delay_ms(time_t);
void timer_wait_ms(time_t)
Wait a certain amount of miliseconds.
Definition: timer.c:12
#define TICKS_TO_MS(_ticks)
Convert a number of ticks into a regular time unit.
Definition: timer.h:35
static time_t timer_get_ms(void)
Definition: timer.h:77
volatile clock_t timer_ticks_counter
This is where we keep track of the number of intervals reported by the timer.
Definition: timer.c:27
void timer_start(u32 frequency)
Start the global timekeeping timer.
Definition: timer.c:39
static clock_t timer_gettick(void)
Definition: timer.h:60
static time_t timer_get_ns(void)
Definition: timer.h:89
static time_t timer_get_us(void)
Definition: timer.h:83
#define TICKS_TO_NS(_ticks)
Convert a number of ticks into a regular time unit.
Definition: timer.h:37
volatile u32 timer_kernel_frequency
Frequency of the global timekeeping timer.
Definition: timer.c:28
#define TICKS_TO_US(_ticks)
Convert a number of ticks into a regular time unit.
Definition: timer.h:36
static void clock_get_time(struct timespec *time)
Fill a timespec structure with the current time of the day.
Definition: timer.h:99
static bool timer_tick(void)
Increment the timekeeping timer's tick count.
Definition: timer.h:69
#define NS(_s)
Used for conversions from seconds to another time unit.
Definition: time.h:18
#define NS_TO_SEC(_s)
Used for conversions to seconds from another time unit.
Definition: time.h:25