28 lines
660 B
C
28 lines
660 B
C
#ifndef RTC_H
|
|
#define RTC_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#define MS_TO_NS(ms) ((uint64_t)(ms) * 1000ULL * 1000ULL)
|
|
#define NS_TO_MS(ms) ((uint64_t)(ms) / (1000ULL * 1000ULL))
|
|
|
|
struct rtc_class_ops {
|
|
uint64_t (*read_time)(void);
|
|
void (*set_time)(uint64_t);
|
|
uint64_t (*read_alarm)(uint64_t);
|
|
void (*set_alarm)(uint64_t);
|
|
void (*alarm_irq_enable)(void);
|
|
};
|
|
|
|
uint64_t rtc_time_read(void);
|
|
void rtc_time_set(uint64_t ns);
|
|
|
|
void rtc_alarm_set(uint64_t ns);
|
|
uint64_t rtc_alarm_read(void);
|
|
uint32_t rtc_alarm_status(void);
|
|
void rtc_alarm_clear(void);
|
|
|
|
void rtc_irq_clear(void);
|
|
uint32_t rtc_irq_enabled(void);
|
|
|
|
#endif // RTC_H
|