SmartSnippets DA1459x SDK
Files | Data Structures | Macros | Typedefs | Enumerations | Functions
Real_Time_Clock (RTC) Driver

Real Time Clock (RTC) More...

Files

file  hw_rtc.h
 Definition of API for the Real Time Clock Low Level Driver.
 

Data Structures

struct  hw_rtc_calendar_t
 Calendar configuration for RTC. More...
 
struct  hw_rtc_alarm_calendar_t
 Alarm Calendar configuration for RTC. More...
 
struct  hw_rtc_time_t
 Time configuration for RTC. More...
 
struct  hw_rtc_config_pdc_evt_t
 RTC to Power Domain Controller event configuration. More...
 

Macros

#define HW_RTC_REG_GETF(reg, field)   ((RTC->reg & (RTC_##reg##_##field##_Msk)) >> (RTC_##reg##_##field##_Pos))
 Get the value of a field of an RTC register. More...
 
#define HW_RTC_REG_SETF(reg, field, val)
 Set the value of a field of a RTC register. More...
 
#define RTC_PDC_EVENT_PERIOD_MAX_VAL   0x1fff
 Maximum value of RTC to PDC event period (13bits). More...
 
#define RTC_ALL_STATUS_VALID   0xf
 All entries are valid in the RTC status register. More...
 
#define RTC_TIME_CLDR_STATUS_VALID   0x3
 Time and Calendar entries are valid in the RTC status register. More...
 
#define RTC_ALARM_TIME_CLDR_STATUS_VALID   0xc
 Alarm Time and Calendar entries are valid in the RTC status register. More...
 

Typedefs

typedef void(* hw_rtc_interrupt_cb) (uint8_t event)
 Callback that is fired on RTC events. More...
 

Enumerations

enum  HW_RTC_LP_CLK
 RTC lp_clk sources. More...
 
enum  HW_RTC_HOUR_MODE { RTC_24H_CLK = 0, RTC_12H_CLK }
 Hour clock mode. More...
 
enum  HW_RTC_DIV_DENOM { RTC_DIV_DENOM_1000 = 0x0, RTC_DIV_DENOM_1024 = 0x1 }
 RTC denominator for the fractional division of the source clock. More...
 
enum  HW_RTC_INTR {
  HW_RTC_INT_ALRM = RTC_RTC_INTERRUPT_MASK_REG_RTC_ALRM_INT_MSK_Msk, HW_RTC_INT_MONTH = RTC_RTC_INTERRUPT_MASK_REG_RTC_MNTH_INT_MSK_Msk, HW_RTC_INT_MDAY = RTC_RTC_INTERRUPT_MASK_REG_RTC_DATE_INT_MSK_Msk, HW_RTC_INT_HOUR = RTC_RTC_INTERRUPT_MASK_REG_RTC_HOUR_INT_MSK_Msk,
  HW_RTC_INT_MIN = RTC_RTC_INTERRUPT_MASK_REG_RTC_MIN_INT_MSK_Msk, HW_RTC_INT_SEC = RTC_RTC_INTERRUPT_MASK_REG_RTC_SEC_INT_MSK_Msk, HW_RTC_INT_HSEC = RTC_RTC_INTERRUPT_MASK_REG_RTC_HOS_INT_MSK_Msk
}
 RTC interrupt source. More...
 
enum  HW_RTC_EVENT {
  HW_RTC_EVENT_ALRM = RTC_RTC_EVENT_FLAGS_REG_RTC_EVENT_ALRM_Msk, HW_RTC_EVENT_MONTH = RTC_RTC_EVENT_FLAGS_REG_RTC_EVENT_MNTH_Msk, HW_RTC_EVENT_MDAY = RTC_RTC_EVENT_FLAGS_REG_RTC_EVENT_DATE_Msk, HW_RTC_EVENT_HOUR = RTC_RTC_EVENT_FLAGS_REG_RTC_EVENT_HOUR_Msk,
  HW_RTC_EVENT_MIN = RTC_RTC_EVENT_FLAGS_REG_RTC_EVENT_MIN_Msk, HW_RTC_EVENT_SEC = RTC_RTC_EVENT_FLAGS_REG_RTC_EVENT_SEC_Msk, HW_RTC_EVENT_HSEC = RTC_RTC_EVENT_FLAGS_REG_RTC_EVENT_HOS_Msk
}
 RTC Events. More...
 
enum  HW_RTC_ALARM_EN {
  HW_RTC_ALARM_MONTH = RTC_RTC_ALARM_ENABLE_REG_RTC_ALARM_MNTH_EN_Msk, HW_RTC_ALARM_MDAY = RTC_RTC_ALARM_ENABLE_REG_RTC_ALARM_DATE_EN_Msk, HW_RTC_ALARM_HOUR = RTC_RTC_ALARM_ENABLE_REG_RTC_ALARM_HOUR_EN_Msk, HW_RTC_ALARM_MIN = RTC_RTC_ALARM_ENABLE_REG_RTC_ALARM_MIN_EN_Msk,
  HW_RTC_ALARM_SEC = RTC_RTC_ALARM_ENABLE_REG_RTC_ALARM_SEC_EN_Msk, HW_RTC_ALARM_HSEC = RTC_RTC_ALARM_ENABLE_REG_RTC_ALARM_HOS_EN_Msk
}
 RTC Alarm enable mask. More...
 
enum  HW_RTC_STATUS { HW_RTC_VALID_CLNDR_ALM = RTC_RTC_STATUS_REG_RTC_VALID_CAL_ALM_Msk, HW_RTC_VALID_TIME_ALM = RTC_RTC_STATUS_REG_RTC_VALID_TIME_ALM_Msk, HW_RTC_VALID_CLNDR = RTC_RTC_STATUS_REG_RTC_VALID_CAL_Msk, HW_RTC_VALID_TIME = RTC_RTC_STATUS_REG_RTC_VALID_TIME_Msk }
 RTC status. More...
 
enum  HW_RTC_SET_REG_STATUS {
  HW_RTC_VALID_ENTRY = 0x1, HW_RTC_INVALID_TIME_HOUR_MODE_ALM = 0x3, HW_RTC_INVALID_CLNDR_ALM = 0x7, HW_RTC_INVALID_TIME_ALM = 0xB,
  HW_RTC_INVALID_CLNDR = 0xD, HW_RTC_INVALID_TIME = 0xE, HW_RTC_INVALID_TIME_CLNDR = 0xC
}
 RTC status. More...
 

Functions

void hw_rtc_config_RTC_to_PDC_evt (const hw_rtc_config_pdc_evt_t *cfg)
 RTC to PDC event configuration. More...
 
void hw_rtc_register_intr (hw_rtc_interrupt_cb handler, uint8_t mask)
 Register an interrupt handler. More...
 
void hw_rtc_unregister_intr (void)
 Unregister the event handler and disable RTC interrupt (NVIC) More...
 
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. More...
 
__STATIC_INLINE void hw_rtc_set_time_bcd (uint32_t time_bcd)
 Set RTC time. More...
 
__STATIC_INLINE void hw_rtc_set_clndr_bcd (uint32_t clndr_bcd)
 Set RTC Calendar date. More...
 
void hw_rtc_get_time_clndr (hw_rtc_time_t *time, hw_rtc_calendar_t *clndr)
 Get RTC time and/or calendar date. More...
 
__STATIC_INLINE uint32_t hw_rtc_get_time_bcd (void)
 Get RTC time. More...
 
__STATIC_INLINE uint32_t hw_rtc_get_clndr_bcd (void)
 Get RTC Calendar date. More...
 
__STATIC_INLINE void hw_rtc_time_start (void)
 Start RTC time. More...
 
__STATIC_INLINE void hw_rtc_time_stop (void)
 Stop RTC time. More...
 
__STATIC_INLINE void hw_rtc_clndr_start (void)
 Start RTC Calendar. More...
 
__STATIC_INLINE void hw_rtc_clndr_stop (void)
 Stop RTC Calendar. More...
 
__STATIC_INLINE void hw_rtc_start (void)
 Start RTC. Starts both time and calendar. More...
 
__STATIC_INLINE void hw_rtc_stop (void)
 Stop RTC. Stops both time and calendar. More...
 
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. More...
 
__STATIC_INLINE void hw_rtc_set_alarm_time_bcd (uint32_t time_bcd)
 Set RTC alarm time. More...
 
__STATIC_INLINE void hw_rtc_set_alarm_clndr_bcd (uint32_t clndr_bcd)
 Set RTC alarm Calendar. More...
 
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. More...
 
__STATIC_INLINE uint32_t hw_rtc_get_alarm_time_bcd (void)
 Get RTC alarm time. More...
 
__STATIC_INLINE uint32_t hw_rtc_get_alarm_clndr_bcd (void)
 Get RTC alarm calendar. More...
 
__STATIC_INLINE void hw_rtc_alarm_enable (const uint8_t mask)
 RTC alarm enable. More...
 
__STATIC_INLINE uint8_t hw_rtc_get_alarm_enable_msk (void)
 Get RTC alarm enable bitmask. More...
 
__STATIC_INLINE void hw_rtc_interrupt_enable (const uint8_t mask)
 Enable RTC interrupt(s) More...
 
__STATIC_INLINE void hw_rtc_interrupt_disable (const uint8_t mask)
 Disable RTC interrupt(s) More...
 
__STATIC_INLINE uint8_t hw_rtc_get_event_flags (void)
 Get RTC event flags. More...
 
__STATIC_INLINE uint8_t hw_rtc_get_interrupt_mask (void)
 Get RTC interrupt mask. More...
 
__STATIC_INLINE void hw_rtc_set_hour_clk_mode (HW_RTC_HOUR_MODE mode)
 Set RTC hour clock mode. More...
 
__STATIC_INLINE HW_RTC_HOUR_MODE hw_rtc_get_hour_clk_mode (void)
 Get RTC hour clock mode. More...
 
__STATIC_INLINE uint8_t hw_rtc_get_status (void)
 Get RTC status. More...
 
__STATIC_INLINE void hw_rtc_set_keep_reg_on_reset (bool keep)
 Configure RTC to keep or reset its registers after reset. More...
 
__STATIC_INLINE bool hw_rtc_get_keep_reg_on_reset (void)
 Get RTC keep register status. More...
 
__STATIC_INLINE void hw_rtc_pdc_event_enable (void)
 Enable RTC to Power Domains Controller (PDC) event. More...
 
__STATIC_INLINE void hw_rtc_pdc_event_disable (void)
 Disable RTC to Power Domains Controller event. More...
 
__STATIC_INLINE bool hw_rtc_get_pdc_event_cntrl (void)
 Get status of control of RTC to Power Domains Controller event. More...
 
__STATIC_INLINE void hw_rtc_set_pdc_event_period (uint16_t period)
 Set RTC to PDC event period. More...
 
__STATIC_INLINE uint16_t hw_rtc_get_pdc_event_period (void)
 Get RTC to PDC event period. More...
 
__STATIC_INLINE bool hw_rtc_pdc_event_clear (void)
 Clear RTC to PDC event. More...
 
__STATIC_INLINE uint16_t hw_rtc_get_pdc_event_cnt (void)
 Get PDC event count. More...
 
__STATIC_INLINE void hw_rtc_reset (void)
 Reset RTC module. More...
 
__STATIC_INLINE void hw_rtc_reset_set (void)
 Set RTC reset high. More...
 
__STATIC_INLINE void hw_rtc_reset_clear (void)
 Clear RTC reset. More...
 
__STATIC_INLINE void hw_rtc_clk_config (HW_RTC_DIV_DENOM div_denom, uint16_t div_int, uint16_t div_frac)
 Configure RTC clock. More...
 
__STATIC_INLINE void hw_rtc_clock_enable (void)
 Enable for the 100 Hz generation for the RTC block. More...
 

Detailed Description

Real Time Clock (RTC)

Macro Definition Documentation

◆ HW_RTC_REG_GETF

#define HW_RTC_REG_GETF (   reg,
  field 
)    ((RTC->reg & (RTC_##reg##_##field##_Msk)) >> (RTC_##reg##_##field##_Pos))

Get the value of a field of an RTC register.

Parameters
[in]regis the register to access
[in]fieldis the register field to read
Returns
the value of the register field

◆ HW_RTC_REG_SETF

#define HW_RTC_REG_SETF (   reg,
  field,
  val 
)
Value:
RTC->reg = ((RTC->reg & ~(RTC_##reg##_##field##_Msk)) | \
((RTC_##reg##_##field##_Msk) & ((val) << (RTC_##reg##_##field##_Pos))))

Set the value of a field of a RTC register.

Parameters
[in]regis the register to access
[in]fieldis the register field to write
[in]valis the value to write

◆ RTC_ALARM_TIME_CLDR_STATUS_VALID

#define RTC_ALARM_TIME_CLDR_STATUS_VALID   0xc

Alarm Time and Calendar entries are valid in the RTC status register.

◆ RTC_ALL_STATUS_VALID

#define RTC_ALL_STATUS_VALID   0xf

All entries are valid in the RTC status register.

◆ RTC_PDC_EVENT_PERIOD_MAX_VAL

#define RTC_PDC_EVENT_PERIOD_MAX_VAL   0x1fff

Maximum value of RTC to PDC event period (13bits).

◆ RTC_TIME_CLDR_STATUS_VALID

#define RTC_TIME_CLDR_STATUS_VALID   0x3

Time and Calendar entries are valid in the RTC status register.

Typedef Documentation

◆ hw_rtc_interrupt_cb

typedef void(* hw_rtc_interrupt_cb) (uint8_t event)

Callback that is fired on RTC events.

Parameters
[in]eventbitmask of HW_RTC_EVENT

Enumeration Type Documentation

◆ HW_RTC_ALARM_EN

RTC Alarm enable mask.

Can be used as bitmask.

See also
hw_rtc_get_alarm_enable_msk
hw_rtc_set_alarm
hw_rtc_get_alarm
Enumerator
HW_RTC_ALARM_MONTH 

Enable to trigger alarm when the month in Calendar Alarm Register has been reached

HW_RTC_ALARM_MDAY 

Enable to trigger alarm when the month day in Calendar Alarm Register has been reached

HW_RTC_ALARM_HOUR 

Enable to trigger alarm when the hour in Time Alarm Register has been reached

HW_RTC_ALARM_MIN 

Enable to trigger alarm when the minute in Time Alarm Register has been reached

HW_RTC_ALARM_SEC 

Enable to trigger alarm when the sec in Time Alarm Register has been reached

HW_RTC_ALARM_HSEC 

Enable to trigger alarm when the hsec in Time Alarm Register has been reached

◆ HW_RTC_DIV_DENOM

RTC denominator for the fractional division of the source clock.

Enumerator
RTC_DIV_DENOM_1000 

denominator for the fractional division is 1000

RTC_DIV_DENOM_1024 

denominator for the fractional division is 1024

◆ HW_RTC_EVENT

RTC Events.

Can be used as bitmask.

See also
hw_rtc_get_event_flags
Enumerator
HW_RTC_EVENT_ALRM 

alarm event

HW_RTC_EVENT_MONTH 

month rolls over event

HW_RTC_EVENT_MDAY 

day of the month rolls over event

HW_RTC_EVENT_HOUR 

hour rolls over event

HW_RTC_EVENT_MIN 

minute rolls over event

HW_RTC_EVENT_SEC 

second rolls over event

HW_RTC_EVENT_HSEC 

hundredths of a second rolls over event

◆ HW_RTC_HOUR_MODE

Hour clock mode.

Enumerator
RTC_24H_CLK 

24 hour clock format

RTC_12H_CLK 

12 hour clock format

◆ HW_RTC_INTR

RTC interrupt source.

Can be used as bitmask.

See also
hw_rtc_interrupt_enable
hw_rtc_interrupt_disable
hw_rtc_get_interrupt_mask
Enumerator
HW_RTC_INT_ALRM 

interrupt when alarm event occurs

HW_RTC_INT_MONTH 

interrupt when month event occurs

HW_RTC_INT_MDAY 

interrupt when day of the month event occurs

HW_RTC_INT_HOUR 

interrupt when hour event occurs

HW_RTC_INT_MIN 

interrupt when minute event occurs

HW_RTC_INT_SEC 

interrupt when seconds event occurs

HW_RTC_INT_HSEC 

interrupt when hundredth of a second event occurs

◆ HW_RTC_LP_CLK

RTC lp_clk sources.

◆ HW_RTC_SET_REG_STATUS

RTC status.

Can be used as bitmask.

See also
hw_rtc_set_time_clndr
hw_rtc_set_alarm
Enumerator
HW_RTC_VALID_ENTRY 

indicates a valid entry

HW_RTC_INVALID_TIME_HOUR_MODE_ALM 

indicates that invalid entry occurred when writing to Time Alarm Register hour clock mode. For example, when time is in 24h mode, alarm can not be set in 12h mode. Note that this is not flagged in the status register

HW_RTC_INVALID_CLNDR_ALM 

indicates that invalid entry occurred when writing to Calendar Alarm Register

HW_RTC_INVALID_TIME_ALM 

indicates that invalid entry occurred when writing to Time Alarm Register

HW_RTC_INVALID_CLNDR 

indicates that invalid entry occurred when writing to Calendar Register

HW_RTC_INVALID_TIME 

indicates that invalid entry occurred when writing to Time Register

HW_RTC_INVALID_TIME_CLNDR 

indicates that invalid entry occurred to both time and calendar registers

◆ HW_RTC_STATUS

RTC status.

Can be used as bitmask.

See also
hw_rtc_get_status
Enumerator
HW_RTC_VALID_CLNDR_ALM 

Valid Calendar Alarm. If cleared then indicates that invalid entry occurred when writing to Calendar Alarm Register

HW_RTC_VALID_TIME_ALM 

Valid Time Alarm. If cleared then indicates that invalid entry occurred when writing to Time Alarm Register

HW_RTC_VALID_CLNDR 

Valid Calendar. If cleared then indicates that invalid entry occurred when writing to Calendar Register

HW_RTC_VALID_TIME 

Valid Time. If cleared then indicates that invalid entry occurred when writing to Time Register

Function Documentation

◆ hw_rtc_alarm_enable()

__STATIC_INLINE void hw_rtc_alarm_enable ( const uint8_t  mask)

RTC alarm enable.

Parameters
[in]maskbitmask of HW_RTC_ALARM_EN. Set "1" to enable: Bit: | 5 | 4 | 3 | 2 | 1 | 0 | +------—+------—+------—+-----—+-----—+-------—+ Alarm enable: | on month| on mday | on hour | on min | on sec | on hsec | +------—+------—+------—+-----—+-----—+-------—+

◆ hw_rtc_clk_config()

__STATIC_INLINE void hw_rtc_clk_config ( HW_RTC_DIV_DENOM  div_denom,
uint16_t  div_int,
uint16_t  div_frac 
)

Configure RTC clock.

if div_denom = 1, div_frac out of 1024 cycles will divide by (div_int+1), the rest is div_int. If div_denom = 0, div_frac out of 1000 cycles will divide by (div_int+1), the rest is div_int.

Parameters
[in]div_denomdenominator for the fractional division
[in]div_intinteger divisor part for RTC 100Hz generation
[in]div_fracFractional divisor part for RTC 100Hz generation
Note
RTC is using the low power clock (lp_clk) as clock source, therefore lp_clk must be configured and enabled before calling this function.

◆ hw_rtc_clndr_start()

__STATIC_INLINE void hw_rtc_clndr_start ( void  )

Start RTC Calendar.

◆ hw_rtc_clndr_stop()

__STATIC_INLINE void hw_rtc_clndr_stop ( void  )

Stop RTC Calendar.

◆ hw_rtc_clock_enable()

__STATIC_INLINE void hw_rtc_clock_enable ( void  )

Enable for the 100 Hz generation for the RTC block.

See also
hw_rtc_clk_config

◆ hw_rtc_config_RTC_to_PDC_evt()

void hw_rtc_config_RTC_to_PDC_evt ( const hw_rtc_config_pdc_evt_t cfg)

RTC to PDC event configuration.

Configures and enables the RTC-to-PDC event.

Note
After configuration RTC is not running. Start RTC by calling hw_rtc_start().
Parameters
[in]cfgconfiguration of the RTC event

◆ hw_rtc_get_alarm()

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.

Parameters
[out]timereturns time alarm. Set NULL if there is no need to read time alarm
[out]clndrreturns calendar alarm. Set NULL if there is no need to read calendar alarm
[out]maskreturns bitmask of HW_RTC_ALARM_EN. Set NULL if there is no need to read bitmask. "1" means the alarm is enabled: Bit: | 5 | 4 | 3 | 2 | 1 | 0 | +------—+------—+------—+-----—+-----—+-------—+ Alarm enable: | on month| on mday | on hour | on min | on sec | on hsec | +------—+------—+------—+-----—+-----—+-------—+

◆ hw_rtc_get_alarm_clndr_bcd()

__STATIC_INLINE uint32_t hw_rtc_get_alarm_clndr_bcd ( void  )

Get RTC alarm calendar.

Returns
Calendar date in binary-coded decimal (BCD) format

◆ hw_rtc_get_alarm_enable_msk()

__STATIC_INLINE uint8_t hw_rtc_get_alarm_enable_msk ( void  )

Get RTC alarm enable bitmask.

Returns
bitmask of HW_RTC_ALARM_EN. "1" indicate the alarm is enabled: Bit: | 5 | 4 | 3 | 2 | 1 | 0 | +------—+------—+------—+-----—+-----—+-------—+ Alarm enable: | on month| on mday | on hour | on min | on sec | on hsec | +------—+------—+------—+-----—+-----—+-------—+

◆ hw_rtc_get_alarm_time_bcd()

__STATIC_INLINE uint32_t hw_rtc_get_alarm_time_bcd ( void  )

Get RTC alarm time.

Returns
time in binary-coded decimal (BCD) format

◆ hw_rtc_get_clndr_bcd()

__STATIC_INLINE uint32_t hw_rtc_get_clndr_bcd ( void  )

Get RTC Calendar date.

Returns
Calendar date in binary-coded decimal (BCD) format

◆ hw_rtc_get_event_flags()

__STATIC_INLINE uint8_t hw_rtc_get_event_flags ( void  )

Get RTC event flags.

Returns
bitmask of event flags (HW_RTC_EVENT). "1" indicates that the event occurred since the last reset: Bit: | 6 | 5 | 4 | 3 | 2 | 1 | 0 | +-----—+-----—+----—+----—+---—+---—+----—+ Event: |on alarm|on month|on mday|on hour|on min|on sec|on hsec| +-----—+-----—+----—+----—+---—+---—+----—+
Note
Reading the event flag register will clear the register

◆ hw_rtc_get_hour_clk_mode()

__STATIC_INLINE HW_RTC_HOUR_MODE hw_rtc_get_hour_clk_mode ( void  )

Get RTC hour clock mode.

Returns
12-hour or 24-hour clock format

◆ hw_rtc_get_interrupt_mask()

__STATIC_INLINE uint8_t hw_rtc_get_interrupt_mask ( void  )

Get RTC interrupt mask.

Returns
interrupt bitmask (HW_RTC_INTR) Bit: | 6 | 5 | 4 | 3 | 2 | 1 | 0 | +-----—+-----—+----—+----—+---—+---—+----—+ Intr msk: | alarm | month | mday | hour | min | sec | hsec | +-----—+-----—+----—+----—+---—+---—+----—+
Note
bitmask can be cleared by enabling the corresponding interrupt and it can be set by disabling the corresponding interrupt.
See also
hw_rtc_interrupt_enable
hw_rtc_interrupt_disable

◆ hw_rtc_get_keep_reg_on_reset()

__STATIC_INLINE bool hw_rtc_get_keep_reg_on_reset ( void  )

Get RTC keep register status.

Returns
keep when true, the time and calendar registers and any other registers which directly affect or are affected by the time and calendar registers are NOT reset when software reset is applied. When false, the software reset will reset every register except the keep RTC and control registers.

◆ hw_rtc_get_pdc_event_cnt()

__STATIC_INLINE uint16_t hw_rtc_get_pdc_event_cnt ( void  )

Get PDC event count.

Returns
It gives the current value of the PDC event counter (0 to RTC_PDC_EVENT_PERIOD)
See also
hw_rtc_set_pdc_event_period

◆ hw_rtc_get_pdc_event_cntrl()

__STATIC_INLINE bool hw_rtc_get_pdc_event_cntrl ( void  )

Get status of control of RTC to Power Domains Controller event.

Returns
if true, RTC to PDC event is enabled

◆ hw_rtc_get_pdc_event_period()

__STATIC_INLINE uint16_t hw_rtc_get_pdc_event_period ( void  )

Get RTC to PDC event period.

Returns
period of RTC to PDC event. Event is sent every (period+1)*10ms
See also
hw_rtc_pdc_event_enable
hw_rtc_pdc_event_disable

◆ hw_rtc_get_status()

__STATIC_INLINE uint8_t hw_rtc_get_status ( void  )

Get RTC status.

When setting the time/calendar or the alarm the entry can be invalid. The status bitmask indicates if the entry was valid or not.

Returns
status bitmask. "1" means valid entry and "0" invalid entry Bit: | 3 | 2 | 1 | 0 | +-------------—+---------—+-------—+---—+ Status | calendar alarm | time alarm | calendar | time | +-------------—+---------—+-------—+---—+
See also
hw_rtc_set_time_clndr
hw_rtc_set_alarm

◆ hw_rtc_get_time_bcd()

__STATIC_INLINE uint32_t hw_rtc_get_time_bcd ( void  )

Get RTC time.

Returns
time in binary-coded decimal (BCD) format

◆ hw_rtc_get_time_clndr()

void hw_rtc_get_time_clndr ( hw_rtc_time_t time,
hw_rtc_calendar_t clndr 
)

Get RTC time and/or calendar date.

Parameters
[out]timereturns the RTC time. Set NULL if there is no need to read time
[out]clndrreturns the RTC calendar. Set NULL if there is no need to read calendar date
Warning
When reading simultaneously time and date, in order to obtain a coherent view of time and date, the counters shall be stopped while reading them. This avoids the situation where the date counter increments between reading the time register and reading the date register. To avoid stopping the counters temporarily, call this function with clndr to NULL, to read time first and then call this function with time to NULL, to read the date.

◆ hw_rtc_interrupt_disable()

__STATIC_INLINE void hw_rtc_interrupt_disable ( const uint8_t  mask)

Disable RTC interrupt(s)

Parameters
[in]maskbitmask of available interrupts (HW_RTC_INTR). Set "1" to disable: Bit: | 6 | 5 | 4 | 3 | 2 | 1 | 0 | +-----—+-----—+----—+----—+---—+---—+----—+ Disable irq: |on alarm|on month|on mday|on hour|on min|on sec|on hsec| +-----—+-----—+----—+----—+---—+---—+----—+

◆ hw_rtc_interrupt_enable()

__STATIC_INLINE void hw_rtc_interrupt_enable ( const uint8_t  mask)

Enable RTC interrupt(s)

Parameters
[in]maskbitmask of available interrupts (HW_RTC_INTR). Set "1" to enable: Bit: | 6 | 5 | 4 | 3 | 2 | 1 | 0 | +-----—+-----—+----—+----—+---—+---—+----—+ Enable irq: |on alarm|on month|on mday|on hour|on min|on sec|on hsec| +-----—+-----—+----—+----—+---—+---—+----—+

◆ hw_rtc_pdc_event_clear()

__STATIC_INLINE bool hw_rtc_pdc_event_clear ( void  )

Clear RTC to PDC event.

Returns
Value is irrelevant. On read, PDC event is cleared

◆ hw_rtc_pdc_event_disable()

__STATIC_INLINE void hw_rtc_pdc_event_disable ( void  )

Disable RTC to Power Domains Controller event.

◆ hw_rtc_pdc_event_enable()

__STATIC_INLINE void hw_rtc_pdc_event_enable ( void  )

Enable RTC to Power Domains Controller (PDC) event.

◆ hw_rtc_register_intr()

void hw_rtc_register_intr ( hw_rtc_interrupt_cb  handler,
uint8_t  mask 
)

Register an interrupt handler.

Parameters
[in]handlercallback function to be called when RTC event occurs
[in]maskinitial bitmask of requested interrupt events
See also
hw_rtc_interrupt_enable
hw_rtc_interrupt_disable

◆ hw_rtc_reset()

__STATIC_INLINE void hw_rtc_reset ( void  )

Reset RTC module.

Software/hardware reset will reset every register except the keep RTC and control registers. If Keep RTC is high, the time and calendar registers and any other registers which directly affect or are affected by the time and calendar registers are NOT reset when software/hardware reset is applied. Calling this function will reset the time and calendar registers, the keep RTC register as well as the event period registers. Application should not call this function

Note
Reset pulse width it is not important since the reset is asynchronous
See also
hw_rtc_set_keep_reg_on_reset

◆ hw_rtc_reset_clear()

__STATIC_INLINE void hw_rtc_reset_clear ( void  )

Clear RTC reset.

See also
hw_rtc_reset_set

◆ hw_rtc_reset_set()

__STATIC_INLINE void hw_rtc_reset_set ( void  )

Set RTC reset high.

The software reset will reset every register except the keep RTC and control registers. If Keep RTC is high, the time and calendar registers and any other registers which directly affect or are affected by the time and calendar registers are NOT reset when software reset is applied. Calling this function will reset the time and calendar registers, the keep RTC register as well as the event period registers. Application should not call this function

Note
RTC reset shall be cleared before starting RTC module
See also
hw_rtc_reset_clear
hw_rtc_set_keep_reg_on_reset

◆ hw_rtc_set_alarm()

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.

Set time and/or calendar alarms. Enable bitmask mask to select the alarms needed. The alarm interrupt is enabled automatically, an interrupt will be generated when an alarm event occurs.

Parameters
[in]timetime alarm. Can be NULL if only calendar alarm is set
[in]clndrcalendar alarm. Can be NULL if only time alarm is set
[in]maskbitmask of HW_RTC_ALARM_EN. Set "1" to enable: Bit: | 5 | 4 | 3 | 2 | 1 | 0 | +------—+------—+------—+-----—+-----—+-------—+ Alarm enable: | on month| on mday | on hour | on min | on sec | on hsec | +------—+------—+------—+-----—+-----—+-------—+
Returns
HW_RTC_VALID_ENTRY on success, otherwise the failure cause
See also
hw_rtc_interrupt_enable
hw_rtc_alarm_enable

◆ hw_rtc_set_alarm_clndr_bcd()

__STATIC_INLINE void hw_rtc_set_alarm_clndr_bcd ( uint32_t  clndr_bcd)

Set RTC alarm Calendar.

Parameters
[in]clndr_bcdCalendar date in binary-coded decimal (BCD) format
Note
Use wrapper function hw_rtc_set_alarm() to set the alarm in easy to use decimal number format. If this function is used, then hw_rtc_get_status() should be called to check the status

◆ hw_rtc_set_alarm_time_bcd()

__STATIC_INLINE void hw_rtc_set_alarm_time_bcd ( uint32_t  time_bcd)

Set RTC alarm time.

Parameters
[in]time_bcdtime in binary-coded decimal (BCD) format
Note
Use wrapper function hw_rtc_set_alarm() to set the alarm in easy to use decimal number format. If this function is used, then hw_rtc_get_status() should be called to check the status

◆ hw_rtc_set_clndr_bcd()

__STATIC_INLINE void hw_rtc_set_clndr_bcd ( uint32_t  clndr_bcd)

Set RTC Calendar date.

Parameters
[in]clndr_bcdCalendar date in binary-coded decimal (BCD) format
Note
Use wrapper function hw_rtc_set_time_clndr() to set calendar in easy to use decimal number format. If this function is used, then hw_rtc_get_status() should be called to check the status
See also
hw_rtc_get_status

◆ hw_rtc_set_hour_clk_mode()

__STATIC_INLINE void hw_rtc_set_hour_clk_mode ( HW_RTC_HOUR_MODE  mode)

Set RTC hour clock mode.

Parameters
[in]mode12-hour or 24-hour clock format

◆ hw_rtc_set_keep_reg_on_reset()

__STATIC_INLINE void hw_rtc_set_keep_reg_on_reset ( bool  keep)

Configure RTC to keep or reset its registers after reset.

Parameters
[in]keepwhen true, the time and calendar registers and any other registers which directly affect or are affected by the time and calendar registers are NOT reset when software reset is applied. When false, the software reset will reset every register except the keep RTC and control registers.

◆ hw_rtc_set_pdc_event_period()

__STATIC_INLINE void hw_rtc_set_pdc_event_period ( uint16_t  period)

Set RTC to PDC event period.

Parameters
[in]periodRTC will send an event to PDC, if RTC to PDC event is enabled, every (period+1)*10ms
See also
hw_rtc_pdc_event_enable
hw_rtc_pdc_event_disable

◆ hw_rtc_set_time_bcd()

__STATIC_INLINE void hw_rtc_set_time_bcd ( uint32_t  time_bcd)

Set RTC time.

Parameters
[in]time_bcdtime in binary-coded decimal (BCD) format
Note
Use wrapper function hw_rtc_set_time_clndr() to set time in easy to use decimal number format. If this function is used, then hw_rtc_get_status() should be called to check the status
See also
hw_rtc_get_status

◆ hw_rtc_set_time_clndr()

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 can be NULL if only calendar is set. Also, clndr can be NULL if only time is set.

Parameters
[in]timevalue to set the RTC time
[in]clndrvalue to set the RTC calendar date
Returns
HW_RTC_VALID_ENTRY on success, otherwise the failure cause
Note
This function will stop the respective counter before setting the register and then it will start the counter again only if the entry was valid

◆ hw_rtc_start()

__STATIC_INLINE void hw_rtc_start ( void  )

Start RTC. Starts both time and calendar.

Warning
RTC is using the low power clock (lp_clk) as clock source, therefore firstly lp_clk must be configured and enabled and secondly the RTC clock 100Hz must be configured and enabled before calling this function.
See also
hw_rtc_clk_config
hw_rtc_clock_enable

◆ hw_rtc_stop()

__STATIC_INLINE void hw_rtc_stop ( void  )

Stop RTC. Stops both time and calendar.

◆ hw_rtc_time_start()

__STATIC_INLINE void hw_rtc_time_start ( void  )

Start RTC time.

◆ hw_rtc_time_stop()

__STATIC_INLINE void hw_rtc_time_stop ( void  )

Stop RTC time.

◆ hw_rtc_unregister_intr()

void hw_rtc_unregister_intr ( void  )

Unregister the event handler and disable RTC interrupt (NVIC)

This function disables all RTC interrupts by masking them. In addition it clears any pending ones on the ARM core. The status of RAW_INTR_STAT_REG remains unchanged.

See also
hw_rtc_interrupt_disable
hw_rtc_interrupt_enable