17#define SDRV_RTC_REG_PARITY_ERR_ENABLE() \
18 sdrv_rtc_reg_parity_err_int_enable(APB_RTC1_BASE); \
19 sdrv_rtc_reg_parity_err_int_enable(APB_RTC2_BASE);
21#define SDRV_RTC_REG_PARITY_ERR_DISABLE() \
22 sdrv_rtc_reg_parity_err_int_disable(APB_RTC1_BASE); \
23 sdrv_rtc_reg_parity_err_int_disable(APB_RTC2_BASE);
25typedef int (*
rtc_cb_t)(uint32_t irq,
void *arg);
100 RMWREG32(base + 0x68U, 0, 1, 1);
110 RMWREG32(base + 0x68U, 0, 1, 0);
121 return (!(year % 4) && (year % 100)) || !(year % 400);
SemiDrive driver common header file.
@ SDRV_STATUS_GROUP_RTC
Definition: sdrv_common.h:53
int32_t status_t
Type used for all status and error return values.
Definition: sdrv_common.h:82
#define SDRV_ERROR_STATUS(group, code)
Construct a status code value from a group and code number. All the error statuses are negetive numbe...
Definition: sdrv_common.h:17
sdrv_general_purpose
Definition: sdrv_rtc.h:78
@ SDRV_RTC_GP0
Definition: sdrv_rtc.h:79
@ SDRV_RTC_GP3
Definition: sdrv_rtc.h:82
@ SDRV_RTC_GP2
Definition: sdrv_rtc.h:81
@ SDRV_RTC_GP1
Definition: sdrv_rtc.h:80
status_t sdrv_rtc_write_general_purpose_reg(sdrv_rtc_t *dev, sdrv_general_purpose_e gp_num, uint32_t value)
Write rtc general purpose register.
sdrv_rtc_violation_enum
Definition: sdrv_rtc.h:45
@ SDRV_RTC_VIO_NONE
Definition: sdrv_rtc.h:46
@ SDRV_RTC_VIO_ALL
Definition: sdrv_rtc.h:49
@ SDRV_RTC_VIO_OVERFLOW
Definition: sdrv_rtc.h:47
@ SDRV_RTC_VIO_DISABLE
Definition: sdrv_rtc.h:48
uint32_t sdrv_rtc_read_general_purpose_reg(sdrv_rtc_t *dev, sdrv_general_purpose_e gp_num)
Read rtc general purpose register.
status_t epoch_ms_to_rtc(struct rtc_time *tm, uint64_t epoch_millisec)
Simple algorithm to convert epoch milliseconds to RTC time.
enum sdrv_rtc_violation_enum sdrv_rtc_violation_e
uint64_t rtc_to_epoch_ms(struct rtc_time *tm)
Simple algorithm to convert RTC time to Epoch milliseconds.
static void sdrv_rtc_reg_parity_err_int_enable(uint32_t base)
Enable RTC Register parity error interrupt status.
Definition: sdrv_rtc.h:98
status_t sdrv_rtc_wakeup_enable(sdrv_rtc_t *dev, sdrv_rtc_wakeup_enable_type_e type, bool enable)
sdrv enable rtc wake up.
status_t sdrv_rtc_enable_it(uint32_t source, void *arg, rtc_cb_t cb)
Enable rtc interrupt.
sdrv_rtc_error
RTC status error code.
Definition: sdrv_rtc.h:88
@ SDRV_RTC_STATUS_INVALID_RTC_TIME
Definition: sdrv_rtc.h:89
@ SDRV_RTC_STATUS_LOCK
Definition: sdrv_rtc.h:90
struct sdrv_rtc sdrv_rtc_t
RTC device structure.
uint64_t rtc_to_epoch(struct rtc_time *tm)
Simple algorithm to convert RTC time to Epoch seconds.
status_t sdrv_rtc_enable(sdrv_rtc_t *dev, bool enable)
sdrv rtc enable.
status_t epoch_to_rtc(struct rtc_time *tm, uint64_t epoch_sec)
Simple algorithm to convert epoch seconds to RTC time.
int(* rtc_cb_t)(uint32_t irq, void *arg)
Definition: sdrv_rtc.h:25
status_t sdrv_rtc_lock(sdrv_rtc_t *dev)
rtc lock.
status_t sdrv_rtc_clear_violation_status(sdrv_rtc_t *dev, sdrv_rtc_violation_e vio)
sdrv rtc clear violation status.
static bool is_leap_year(uint32_t year)
check is leap yaer
Definition: sdrv_rtc.h:119
status_t sdrv_rtc_get_time(sdrv_rtc_t *dev, struct rtc_time *tm)
rtc get time
status_t sdrv_rtc_clear_wakeup_status(sdrv_rtc_t *dev)
sdrv clear rtc wake up status.
status_t sdrv_rtc_enable_alarm(sdrv_rtc_t *dev, bool enable)
Enable rtc alarm.
status_t sdrv_rtc_disable_it(uint32_t source)
disable rtc interrput.
status_t sdrv_rtc_set_alarm(sdrv_rtc_t *dev, struct rtc_wkalrm *alrm)
rtc set alarm
bool sdrv_rtc_get_wakeup_status(sdrv_rtc_t *dev)
sdrv get rtc wake up status.
status_t sdrv_rtc_get_alarm(sdrv_rtc_t *dev, struct rtc_wkalrm *alrm)
rtc get alarm
sdrv_rtc_wakeup_enable_type
Definition: sdrv_rtc.h:71
@ SDRV_WKUP_ENABLE_ALL
Definition: sdrv_rtc.h:75
@ SDRV_WKUP_ENABLE_REQ
Definition: sdrv_rtc.h:74
@ SDRV_WKUP_ENABLE_IRQ
Definition: sdrv_rtc.h:73
@ SDRV_WKUP_ENABLE
Definition: sdrv_rtc.h:72
enum sdrv_rtc_wakeup_enable_type sdrv_rtc_wakeup_enable_type_e
static void sdrv_rtc_reg_parity_err_int_disable(uint32_t base)
Disable RTC Register parity error interrupt status.
Definition: sdrv_rtc.h:108
status_t sdrv_rtc_set_time(sdrv_rtc_t *dev, struct rtc_time *tm)
rtc set time
status_t sdrv_rtc_violation_intr_enable(sdrv_rtc_t *dev, sdrv_rtc_violation_e vio, bool en)
sdrv rtc violation enable.
enum sdrv_general_purpose sdrv_general_purpose_e
sdrv_rtc_violation_e sdrv_rtc_get_violation_status(sdrv_rtc_t *dev)
sdrv get rtc violation status.
RTC time structure.
Definition: sdrv_rtc.h:32
uint32_t tm_mon
Definition: sdrv_rtc.h:38
uint32_t tm_min
Definition: sdrv_rtc.h:35
uint32_t tm_year
Definition: sdrv_rtc.h:39
uint32_t tm_subsec
Definition: sdrv_rtc.h:33
uint32_t tm_wday
Definition: sdrv_rtc.h:40
uint32_t tm_mday
Definition: sdrv_rtc.h:37
uint32_t tm_yday
Definition: sdrv_rtc.h:41
uint32_t tm_isdst
Definition: sdrv_rtc.h:42
uint32_t tm_hour
Definition: sdrv_rtc.h:36
uint32_t tm_sec
Definition: sdrv_rtc.h:34
Definition: sdrv_rtc.h:64
struct rtc_time tm
Definition: sdrv_rtc.h:67
unsigned char enable
Definition: sdrv_rtc.h:65
unsigned char pending
Definition: sdrv_rtc.h:66
RTC device structure.
Definition: sdrv_rtc.h:55
rtc_cb_t cb
Definition: sdrv_rtc.h:60
uint32_t wakeup_intr
Definition: sdrv_rtc.h:57
uint32_t violation_intr
Definition: sdrv_rtc.h:59
uint32_t periodic_intr
Definition: sdrv_rtc.h:58
paddr_t base
Definition: sdrv_rtc.h:56
sdrv_rtc_violation_e vio_mask
Definition: sdrv_rtc.h:61