Real-Time Clock

API for Real-Time Clocks.

Enums

enum metal_rtc_run_option

List of RTC run behaviors.

Values:

enumerator METAL_RTC_STOP
enumerator METAL_RTC_RUN

Functions

uint64_t metal_rtc_get_rate(const struct metal_rtc *const rtc)

Get the rate of the RTC.

Return

The rate in Hz

uint64_t metal_rtc_set_rate(const struct metal_rtc *const rtc, const uint64_t rate)

Set (if possible) the rate of the RTC.

Return

The new rate of the RTC (not guaranteed to be the same as requested)

uint64_t metal_rtc_get_compare(const struct metal_rtc *const rtc)

Get the compare value of the RTC.

Return

The compare value

uint64_t metal_rtc_set_compare(const struct metal_rtc *const rtc, const uint64_t compare)

Set the compare value of the RTC.

The RTC device might impose limits on the maximum compare value or the granularity of the compare value.

Return

The set compare value (not guaranteed to be exactly the requested value)

uint64_t metal_rtc_get_count(const struct metal_rtc *const rtc)

Get the current count of the RTC.

Return

The count

uint64_t metal_rtc_set_count(const struct metal_rtc *const rtc, const uint64_t count)

Set the current count of the RTC.

The RTC device might impose limits on the maximum value of the count

Return

The set value of the count (not guaranteed to be exactly the requested value)

int metal_rtc_run(const struct metal_rtc *const rtc, const enum metal_rtc_run_option option)

Start or stop the RTC.

Return

0 if the RTC was successfully started/stopped

struct metal_interrupt *metal_rtc_get_interrupt(const struct metal_rtc *const rtc)

Get the interrupt handle for the RTC compare.

Return

The interrupt handle

int metal_rtc_get_interrupt_id(const struct metal_rtc *const rtc)

Get the interrupt ID for the RTC compare.

Return

The interrupt ID

struct metal_rtc *metal_rtc_get_device(int index)

Get the handle for an RTC by index.

Return

The RTC handle, or NULL if none is available at that index

struct metal_rtc
#include <rtc.h>

Handle for a Real-Time Clock.