SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Functions | Variables
timer.c File Reference
#include <io.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <types.h>
#include <log.h>
#include <timer.h>
Include dependency graph for timer.c:

Functions

void set_timer_count ()
 Set timer count.
 
uint64_t get_arch_counter (void)
 Get the architecture-specific counter value.
 
uint32_t time_ms (void)
 Get the current time in milliseconds.
 
uint64_t time_us (void)
 Get the current time in microseconds.
 
void udelay (uint32_t us)
 Delay execution for a specified number of microseconds.
 
void mdelay (uint32_t ms)
 Delay execution for a specified number of milliseconds.
 
void sdelay (uint32_t loops)
 Delay execution for a specified number of loops (treated as microseconds).
 
uint32_t get_init_timestamp ()
 Get the initialization timestamp.
 

Variables

static uint32_t init_timestamp = 0
 

Function Documentation

◆ get_arch_counter()

uint64_t get_arch_counter ( void  )

Get the architecture-specific counter value.

This function retrieves the current value of the architecture-specific timer counter. The returned value is a 64-bit integer representing the timer's current count.

Returns
Current counter value as a 64-bit integer.

◆ get_init_timestamp()

uint32_t get_init_timestamp ( )

Get the initialization timestamp.

This function retrieves the initialization timestamp set during the system timer setup.

Returns
The initialization timestamp in microseconds.

◆ mdelay()

void mdelay ( uint32_t  ms)

Delay execution for a specified number of milliseconds.

This function converts milliseconds to microseconds and calls the udelay function to implement the delay.

Parameters
msNumber of milliseconds to delay.

◆ sdelay()

void sdelay ( uint32_t  loops)

Delay execution for a specified number of loops (treated as microseconds).

This function creates a delay based on the number of microsecond loops specified, by calling the udelay function directly.

Parameters
loopsNumber of microsecond loops to delay.

◆ set_timer_count()

void set_timer_count ( )

Set timer count.

This function is used to set the count value of the timer.

Note
Before calling this function, timer-related hardware configuration should be initialized.

◆ time_ms()

uint32_t time_ms ( void  )

Get the current time in milliseconds.

This function calculates the current time based on the architecture counter and returns it in milliseconds.

Returns
Current time in milliseconds.

◆ time_us()

uint64_t time_us ( void  )

Get the current time in microseconds.

This function calculates the current time based on the architecture counter and returns it in microseconds.

Returns
Current time in microseconds.

◆ udelay()

void udelay ( uint32_t  us)

Delay execution for a specified number of microseconds.

This function creates a delay for the specified number of microseconds using a busy-wait loop.

Parameters
usNumber of microseconds to delay.

Variable Documentation

◆ init_timestamp

uint32_t init_timestamp = 0
static