#include "rtc.h" rtc_timer_t* get_rtc_dev() { return (rtc_timer_t*)(RTC_BASE); } void get_rtc_time(RRTC_TIME_REG *time) { rtc_timer_t* rtc = get_rtc_dev(); time->_val = rtc->TIME; } void get_rtc_date(RRTC_DATE_REG *date) { rtc_timer_t* rtc = get_rtc_dev(); date->_val = rtc->TIME; } void set_rtc_alarm_time(RRTC_TIME_REG *time) { rtc_timer_t* rtc = get_rtc_dev(); rtc->TALRM = time->_val; } void set_rtc_alarm_date(RRTC_DATE_REG *date) { rtc_timer_t* rtc = get_rtc_dev(); rtc->DALRM = date->_val; } void enable_int_alarm() { rtc_timer_t* rtc = get_rtc_dev(); RRTC_CTRL_REG ctrl; ctrl._val = 0; ctrl.int_alarm_en = 1; ctrl.alrm_whup_en = 1; rtc->CTRL |= ctrl._val; } void disable_int_alarm() { rtc_timer_t* rtc = get_rtc_dev(); RRTC_CTRL_REG ctrl; ctrl._val = 0; ctrl.int_alarm_en = 1; rtc->CTRL &= (~ctrl._val); } void clear_int_alarm() { rtc_timer_t* rtc = get_rtc_dev(); RRTC_STAT_REG stat; stat._val = 0; stat.int_alarm = 1; rtc->STAT |= stat._val; }