|
SmartSnippets DA1459x SDK
|
Go to the documentation of this file.
46 #if dg_configUSE_HW_RTC
61 #define HW_RTC_REG_GETF(reg, field) \
62 ((RTC->reg & (RTC_##reg##_##field##_Msk)) >> (RTC_##reg##_##field##_Pos))
72 #define HW_RTC_REG_SETF(reg, field, val) \
73 RTC->reg = ((RTC->reg & ~(RTC_##reg##_##field##_Msk)) | \
74 ((RTC_##reg##_##field##_Msk) & ((val) << (RTC_##reg##_##field##_Pos))))
81 #define RTC_PDC_EVENT_PERIOD_MAX_VAL 0x1fff
87 #define RTC_ALL_STATUS_VALID 0xf
93 #define RTC_TIME_CLDR_STATUS_VALID 0x3
99 #define RTC_ALARM_TIME_CLDR_STATUS_VALID 0xc
341 RTC->RTC_TIME_REG = time_bcd;
356 RTC->RTC_CALENDAR_REG = clndr_bcd;
381 return RTC->RTC_TIME_REG;
392 return RTC->RTC_CALENDAR_REG;
444 RTC->RTC_CONTROL_REG = 0x0;
453 RTC->RTC_CONTROL_REG = 0x3;
491 RTC->RTC_TIME_ALARM_REG = time_bcd;
505 RTC->RTC_CALENDAR_ALARM_REG = clndr_bcd;
533 return RTC->RTC_TIME_ALARM_REG;
544 return RTC->RTC_CALENDAR_ALARM_REG;
562 RTC->RTC_ALARM_ENABLE_REG = mask;
579 return RTC->RTC_ALARM_ENABLE_REG;
595 RTC->RTC_INTERRUPT_ENABLE_REG = mask;
611 RTC->RTC_INTERRUPT_DISABLE_REG = mask;
630 return RTC->RTC_EVENT_FLAGS_REG;
653 return RTC->RTC_INTERRUPT_MASK_REG;
699 return RTC->RTC_STATUS_REG;
712 RTC->RTC_KEEP_RTC_REG = keep;
725 return RTC->RTC_KEEP_RTC_REG;
770 RTC->RTC_PDC_EVENT_PERIOD_REG = period;
784 return RTC->RTC_PDC_EVENT_PERIOD_REG;
795 return RTC->RTC_PDC_EVENT_CLEAR_REG;
809 return RTC->RTC_PDC_EVENT_CNT_REG;
828 temp_reg = RTC->RTC_INTERRUPT_MASK_REG;
829 RTC->RTC_INTERRUPT_DISABLE_REG = 0xff;
830 REG_SETF(CRG_TOP, CLK_RTCDIV_REG, RTC_RESET_REQ, 1);
831 REG_SETF(CRG_TOP, CLK_RTCDIV_REG, RTC_RESET_REQ, 0);
832 RTC->RTC_INTERRUPT_ENABLE_REG = ~temp_reg & 0x7f;
852 REG_SETF(CRG_TOP, CLK_RTCDIV_REG, RTC_RESET_REQ, 1);
863 REG_SETF(CRG_TOP, CLK_RTCDIV_REG, RTC_RESET_REQ, 0);
881 uint32_t tmp = CRG_TOP->CLK_RTCDIV_REG;
883 REG_SET_FIELD(CRG_TOP, CLK_RTCDIV_REG, RTC_DIV_DENOM, tmp, div_denom);
884 REG_SET_FIELD(CRG_TOP, CLK_RTCDIV_REG, RTC_DIV_INT, tmp, div_int);
885 REG_SET_FIELD(CRG_TOP, CLK_RTCDIV_REG, RTC_DIV_FRAC, tmp, div_frac);
887 CRG_TOP->CLK_RTCDIV_REG = tmp;
897 REG_SETF(CRG_TOP, CLK_RTCDIV_REG, RTC_DIV_ENABLE, 1);
bool pm_flag
Definition: hw_rtc.h:257
__STATIC_INLINE bool hw_rtc_get_keep_reg_on_reset(void)
Get RTC keep register status.
Definition: hw_rtc.h:723
HW_RTC_SET_REG_STATUS
RTC status.
Definition: hw_rtc.h:211
__STATIC_INLINE void hw_rtc_set_keep_reg_on_reset(bool keep)
Configure RTC to keep or reset its registers after reset.
Definition: hw_rtc.h:710
HW_RTC_INTR
RTC interrupt source.
Definition: hw_rtc.h:138
RTC to Power Domain Controller event configuration.
Definition: hw_rtc.h:268
uint8_t wday
Definition: hw_rtc.h:239
__STATIC_INLINE void hw_rtc_pdc_event_disable(void)
Disable RTC to Power Domains Controller event.
Definition: hw_rtc.h:741
HW_RTC_SET_REG_STATUS hw_rtc_set_alarm(const hw_rtc_time_t *time, const hw_rtc_alarm_calendar_t *clndr, const uint8_t mask)
Set RTC alarm.
#define REG_SETF(base, reg, field, new_val)
Set the value of a register field.
Definition: sdk_defs.h:738
uint8_t mday
Definition: hw_rtc.h:248
__STATIC_INLINE void hw_rtc_clndr_start(void)
Start RTC Calendar.
Definition: hw_rtc.h:417
#define RTC_RTC_ALARM_ENABLE_REG_RTC_ALARM_MIN_EN_Msk
Definition: DA1459x-00.h:4415
#define RTC_RTC_EVENT_FLAGS_REG_RTC_EVENT_HOUR_Msk
Definition: DA1459x-00.h:4466
#define RTC_RTC_ALARM_ENABLE_REG_RTC_ALARM_SEC_EN_Msk
Definition: DA1459x-00.h:4417
__STATIC_INLINE void hw_rtc_set_clndr_bcd(uint32_t clndr_bcd)
Set RTC Calendar date.
Definition: hw_rtc.h:354
__STATIC_INLINE void hw_rtc_interrupt_disable(const uint8_t mask)
Disable RTC interrupt(s)
Definition: hw_rtc.h:609
__STATIC_INLINE uint32_t hw_rtc_get_alarm_time_bcd(void)
Get RTC alarm time.
Definition: hw_rtc.h:531
#define HW_RTC_REG_GETF(reg, field)
Get the value of a field of an RTC register.
Definition: hw_rtc.h:61
uint8_t hsec
Definition: hw_rtc.h:261
__STATIC_INLINE void hw_rtc_reset(void)
Reset RTC module.
Definition: hw_rtc.h:825
uint8_t sec
Definition: hw_rtc.h:260
HW_RTC_SET_REG_STATUS hw_rtc_set_time_clndr(const hw_rtc_time_t *time, const hw_rtc_calendar_t *clndr)
Set RTC time and/or calendar date.
Time configuration for RTC.
Definition: hw_rtc.h:255
#define RTC_RTC_EVENT_FLAGS_REG_RTC_EVENT_ALRM_Msk
Definition: DA1459x-00.h:4460
HW_RTC_DIV_DENOM
RTC denominator for the fractional division of the source clock.
Definition: hw_rtc.h:124
#define RTC_RTC_STATUS_REG_RTC_VALID_CAL_Msk
Definition: DA1459x-00.h:4539
__STATIC_INLINE void hw_rtc_reset_set(void)
Set RTC reset high.
Definition: hw_rtc.h:850
Alarm Calendar configuration for RTC.
Definition: hw_rtc.h:246
#define RTC_PDC_EVENT_PERIOD_MAX_VAL
Maximum value of RTC to PDC event period (13bits).
Definition: hw_rtc.h:81
Central include header file with platform definitions.
__STATIC_INLINE uint8_t hw_rtc_get_interrupt_mask(void)
Get RTC interrupt mask.
Definition: hw_rtc.h:651
#define RTC_RTC_INTERRUPT_MASK_REG_RTC_MIN_INT_MSK_Msk
Definition: DA1459x-00.h:4516
__STATIC_INLINE void hw_rtc_pdc_event_enable(void)
Enable RTC to Power Domains Controller (PDC) event.
Definition: hw_rtc.h:732
__STATIC_INLINE bool hw_rtc_get_pdc_event_cntrl(void)
Get status of control of RTC to Power Domains Controller event.
Definition: hw_rtc.h:751
bool pdc_evt_en
Definition: hw_rtc.h:269
uint8_t minute
Definition: hw_rtc.h:259
__STATIC_INLINE uint16_t hw_rtc_get_pdc_event_cnt(void)
Get PDC event count.
Definition: hw_rtc.h:807
__STATIC_INLINE uint8_t hw_rtc_get_event_flags(void)
Get RTC event flags.
Definition: hw_rtc.h:628
#define RTC_RTC_EVENT_FLAGS_REG_RTC_EVENT_HOS_Msk
Definition: DA1459x-00.h:4472
__STATIC_INLINE void hw_rtc_clock_enable(void)
Enable for the 100 Hz generation for the RTC block.
Definition: hw_rtc.h:895
uint16_t year
Definition: hw_rtc.h:236
#define HW_RTC_REG_SETF(reg, field, val)
Set the value of a field of a RTC register.
Definition: hw_rtc.h:72
__STATIC_INLINE uint16_t hw_rtc_get_pdc_event_period(void)
Get RTC to PDC event period.
Definition: hw_rtc.h:782
__STATIC_INLINE void hw_rtc_set_time_bcd(uint32_t time_bcd)
Set RTC time.
Definition: hw_rtc.h:339
__STATIC_INLINE HW_RTC_HOUR_MODE hw_rtc_get_hour_clk_mode(void)
Get RTC hour clock mode.
Definition: hw_rtc.h:674
void hw_rtc_config_RTC_to_PDC_evt(const hw_rtc_config_pdc_evt_t *cfg)
RTC to PDC event configuration.
__STATIC_INLINE uint32_t hw_rtc_get_time_bcd(void)
Get RTC time.
Definition: hw_rtc.h:379
#define RTC_RTC_ALARM_ENABLE_REG_RTC_ALARM_HOS_EN_Msk
Definition: DA1459x-00.h:4419
#define RTC_RTC_EVENT_FLAGS_REG_RTC_EVENT_MIN_Msk
Definition: DA1459x-00.h:4468
__STATIC_INLINE void hw_rtc_set_alarm_time_bcd(uint32_t time_bcd)
Set RTC alarm time.
Definition: hw_rtc.h:489
__STATIC_INLINE void hw_rtc_set_pdc_event_period(uint16_t period)
Set RTC to PDC event period.
Definition: hw_rtc.h:767
uint8_t mday
Definition: hw_rtc.h:238
__STATIC_INLINE uint32_t hw_rtc_get_clndr_bcd(void)
Get RTC Calendar date.
Definition: hw_rtc.h:390
__STATIC_INLINE bool hw_rtc_pdc_event_clear(void)
Clear RTC to PDC event.
Definition: hw_rtc.h:793
void hw_rtc_get_alarm(hw_rtc_time_t *time, hw_rtc_alarm_calendar_t *clndr, uint8_t *mask)
Get RTC time and/or calendar alarms.
uint16_t pdc_evt_period
Definition: hw_rtc.h:270
__STATIC_INLINE void hw_rtc_alarm_enable(const uint8_t mask)
RTC alarm enable.
Definition: hw_rtc.h:560
void hw_rtc_unregister_intr(void)
Unregister the event handler and disable RTC interrupt (NVIC)
#define RTC_RTC_ALARM_ENABLE_REG_RTC_ALARM_HOUR_EN_Msk
Definition: DA1459x-00.h:4413
#define RTC_RTC_INTERRUPT_MASK_REG_RTC_DATE_INT_MSK_Msk
Definition: DA1459x-00.h:4512
HW_GPIO_MODE mode
Definition: hw_gpio.h:211
#define RTC_RTC_ALARM_ENABLE_REG_RTC_ALARM_DATE_EN_Msk
Definition: DA1459x-00.h:4411
#define RTC_RTC_INTERRUPT_MASK_REG_RTC_HOS_INT_MSK_Msk
Definition: DA1459x-00.h:4520
HW_RTC_EVENT
RTC Events.
Definition: hw_rtc.h:157
__STATIC_INLINE void hw_rtc_time_start(void)
Start RTC time.
Definition: hw_rtc.h:399
#define RTC_RTC_ALARM_ENABLE_REG_RTC_ALARM_MNTH_EN_Msk
Definition: DA1459x-00.h:4409
#define RTC_RTC_EVENT_FLAGS_REG_RTC_EVENT_MNTH_Msk
Definition: DA1459x-00.h:4462
#define RTC_RTC_EVENT_FLAGS_REG_RTC_EVENT_SEC_Msk
Definition: DA1459x-00.h:4470
uint8_t hour
Definition: hw_rtc.h:258
#define RTC_RTC_STATUS_REG_RTC_VALID_TIME_ALM_Msk
Definition: DA1459x-00.h:4537
Calendar configuration for RTC.
Definition: hw_rtc.h:235
void hw_rtc_register_intr(hw_rtc_interrupt_cb handler, uint8_t mask)
Register an interrupt handler.
__STATIC_INLINE void hw_rtc_interrupt_enable(const uint8_t mask)
Enable RTC interrupt(s)
Definition: hw_rtc.h:593
__STATIC_INLINE uint8_t hw_rtc_get_status(void)
Get RTC status.
Definition: hw_rtc.h:697
__STATIC_INLINE void hw_rtc_set_alarm_clndr_bcd(uint32_t clndr_bcd)
Set RTC alarm Calendar.
Definition: hw_rtc.h:503
__STATIC_INLINE void hw_rtc_clndr_stop(void)
Stop RTC Calendar.
Definition: hw_rtc.h:426
__STATIC_INLINE void hw_rtc_stop(void)
Stop RTC. Stops both time and calendar.
Definition: hw_rtc.h:451
__STATIC_INLINE void hw_rtc_set_hour_clk_mode(HW_RTC_HOUR_MODE mode)
Set RTC hour clock mode.
Definition: hw_rtc.h:662
__STATIC_INLINE void hw_rtc_reset_clear(void)
Clear RTC reset.
Definition: hw_rtc.h:861
__STATIC_INLINE void hw_rtc_start(void)
Start RTC. Starts both time and calendar.
Definition: hw_rtc.h:442
__STATIC_INLINE uint32_t hw_rtc_get_alarm_clndr_bcd(void)
Get RTC alarm calendar.
Definition: hw_rtc.h:542
void hw_rtc_get_time_clndr(hw_rtc_time_t *time, hw_rtc_calendar_t *clndr)
Get RTC time and/or calendar date.
void(* hw_rtc_interrupt_cb)(uint8_t event)
Callback that is fired on RTC events.
Definition: hw_rtc.h:229
uint8_t month
Definition: hw_rtc.h:237
#define RTC_RTC_INTERRUPT_MASK_REG_RTC_SEC_INT_MSK_Msk
Definition: DA1459x-00.h:4518
HW_RTC_LP_CLK
RTC lp_clk sources.
Definition: hw_rtc.h:105
#define RTC_RTC_INTERRUPT_MASK_REG_RTC_ALRM_INT_MSK_Msk
Definition: DA1459x-00.h:4508
#define REG_SET_FIELD(base, reg, field, var, val)
Set register field value.
Definition: sdk_defs.h:626
__STATIC_INLINE void hw_rtc_time_stop(void)
Stop RTC time.
Definition: hw_rtc.h:408
#define RTC_RTC_STATUS_REG_RTC_VALID_CAL_ALM_Msk
Definition: DA1459x-00.h:4535
uint8_t month
Definition: hw_rtc.h:247
HW_RTC_HOUR_MODE
Hour clock mode.
Definition: hw_rtc.h:115
__STATIC_INLINE uint8_t hw_rtc_get_alarm_enable_msk(void)
Get RTC alarm enable bitmask.
Definition: hw_rtc.h:577
HW_RTC_ALARM_EN
RTC Alarm enable mask.
Definition: hw_rtc.h:178
#define RTC_RTC_EVENT_FLAGS_REG_RTC_EVENT_DATE_Msk
Definition: DA1459x-00.h:4464
HW_RTC_STATUS
RTC status.
Definition: hw_rtc.h:195
__STATIC_INLINE void hw_rtc_clk_config(HW_RTC_DIV_DENOM div_denom, uint16_t div_int, uint16_t div_frac)
Configure RTC clock.
Definition: hw_rtc.h:879
uint8_t hour_mode
Definition: hw_rtc.h:256
#define RTC_RTC_STATUS_REG_RTC_VALID_TIME_Msk
Definition: DA1459x-00.h:4541
#define RTC_RTC_INTERRUPT_MASK_REG_RTC_HOUR_INT_MSK_Msk
Definition: DA1459x-00.h:4514
#define RTC_RTC_INTERRUPT_MASK_REG_RTC_MNTH_INT_MSK_Msk
Definition: DA1459x-00.h:4510