NEORV32 Software Framework Documentation
The NEORV32 RISC-V Processor
Loading...
Searching...
No Matches
neorv32_mtime.c File Reference

Machine System Timer (MTIME) HW driver source file. More...

#include "neorv32.h"
#include "neorv32_mtime.h"

Functions

int neorv32_mtime_available (void)
 
void neorv32_mtime_set_time (uint64_t time)
 
uint64_t neorv32_mtime_get_time (void)
 
void neorv32_mtime_set_timecmp (uint64_t timecmp)
 
uint64_t neorv32_mtime_get_timecmp (void)
 
void neorv32_mtime_set_unixtime (uint64_t unixtime)
 
uint64_t neorv32_mtime_get_unixtime (void)
 

Detailed Description

Machine System Timer (MTIME) HW driver source file.

Note
These functions should only be used if the MTIME unit was synthesized (IO_MTIME_EN = true).
See also
https://stnolting.github.io/neorv32/sw/files.html

Function Documentation

◆ neorv32_mtime_available()

int neorv32_mtime_available ( void )

Check if MTIME unit was synthesized.

Returns
0 if MTIME was not synthesized, 1 if MTIME is available.

◆ neorv32_mtime_get_time()

uint64_t neorv32_mtime_get_time ( void )

Get current system time.

Note
The MTIME timer increments with the primary processor clock.
Returns
Current system time (uint64_t)

◆ neorv32_mtime_get_timecmp()

uint64_t neorv32_mtime_get_timecmp ( void )

Get compare time register (MTIMECMP).

Returns
Current MTIMECMP value.

◆ neorv32_mtime_get_unixtime()

uint64_t neorv32_mtime_get_unixtime ( void )

Get Unix time from TIME.

Returns
Unix time since 00:00:00 UTC, January 1, 1970 in seconds.

◆ neorv32_mtime_set_time()

void neorv32_mtime_set_time ( uint64_t time)

Set current system time.

Note
The MTIME timer increments with the primary processor clock.
Parameters
[in]timeNew system time (uint64_t)

◆ neorv32_mtime_set_timecmp()

void neorv32_mtime_set_timecmp ( uint64_t timecmp)

Set compare time register (MTIMECMP) for generating interrupts.

Note
The interrupt is triggered when MTIME >= MTIMECMP.
Global interrupts and the timer interrupt source have to be enabled.
Parameters
[in]timecmpSystem time for interrupt (uint64_t)

◆ neorv32_mtime_set_unixtime()

void neorv32_mtime_set_unixtime ( uint64_t unixtime)

Set TIME to Unix time.

Parameters
[in]unixtimeUnix time since 00:00:00 UTC, January 1, 1970 in seconds.