RTCEMLIB

Detailed Description

Real Time Counter (RTC) Peripheral API.

This module contains functions to control the RTC peripheral of Silicon Labs 32-bit MCUs and SoCs. The RTC ensures timekeeping in low energy modes.

Data Structures

struct  RTC_Init_TypeDef
 

Macros

#define NUM_RTC_CHANNELS   6U
 
#define RTC_INIT_DEFAULT
 

Functions

uint32_t RTC_CompareGet (unsigned int comp)
 Get the RTC compare register value.
 
void RTC_CompareSet (unsigned int comp, uint32_t value)
 Set the RTC compare register value.
 
__STATIC_INLINE uint32_t RTC_CounterGet (void)
 Get RTC counter value.
 
void RTC_CounterReset (void)
 Restart the RTC counter from zero.
 
__STATIC_INLINE void RTC_CounterSet (uint32_t value)
 Set the RTC counter value.
 
void RTC_Enable (bool enable)
 Enable/disable RTC.
 
void RTC_Init (const RTC_Init_TypeDef *init)
 Initialize RTC.
 
__STATIC_INLINE void RTC_IntClear (uint32_t flags)
 Clear one or more pending RTC interrupts.
 
__STATIC_INLINE void RTC_IntDisable (uint32_t flags)
 Disable one or more RTC interrupts.
 
__STATIC_INLINE void RTC_IntEnable (uint32_t flags)
 Enable one or more RTC interrupts.
 
__STATIC_INLINE uint32_t RTC_IntGet (void)
 Get pending RTC interrupt flags.
 
__STATIC_INLINE uint32_t RTC_IntGetEnabled (void)
 Get enabled and pending RTC interrupt flags. Useful for handling more interrupt sources in the same interrupt handler.
 
__STATIC_INLINE void RTC_IntSet (uint32_t flags)
 Set one or more pending RTC interrupts from SW.
 
void RTC_Reset (void)
 Restore RTC to reset state.
 

Macro Definition Documentation

#define NUM_RTC_CHANNELS   6U

The RTC peripheral on series 0 devices support 2 compare channels while the RTC peripheral on series 1 devices support 6 compare channels.

Definition at line 63 of file em_rtc.h.

Referenced by RTC_Reset().

#define RTC_INIT_DEFAULT
Value:
{ \
true, /* Start counting when initialization is done. */ \
false, /* Disable updating during debug halt. */ \
true /* Restart counting from 0 when reaching COMP0. */ \
}

Suggested default configuration for RTC initialization structure.

Definition at line 78 of file em_rtc.h.

Referenced by UDELAY_Calibrate().

Function Documentation

uint32_t RTC_CompareGet ( unsigned int  comp)

Get the RTC compare register value.

Parameters
[in]compA compare register to get. This value must be less than NUM_RTC_CHANNELS.
Returns
A compare register value, 0 if invalid register selected.

Definition at line 117 of file em_rtc.c.

References RTC.

void RTC_CompareSet ( unsigned int  comp,
uint32_t  value 
)

Set the RTC compare register value.

Note
The setting of a compare register requires synchronization into the low-frequency domain. If the same register is modified before a previous update has completed, this function will stall until the previous synchronization has completed. This only applies to the Gecko Family. See comments in the regSync() internal function call.
Parameters
[in]compA compare register to set. This value must be less than NUM_RTC_CHANNELS.
[in]valueAn initialization value (<= 0x00ffffff).

Definition at line 163 of file em_rtc.c.

References _RTC_COMP_COMP_COMP_MASK, _RTC_COMP_COMP_COMP_SHIFT, and RTC.

Referenced by RTC_IRQHandler().

__STATIC_INLINE uint32_t RTC_CounterGet ( void  )

Get RTC counter value.

Returns
Current RTC counter value.

Definition at line 99 of file em_rtc.h.

References RTC.

__STATIC_INLINE void RTC_CounterSet ( uint32_t  value)

Set the RTC counter value.

Parameters
[in]valueThe new RTC counter value.

Definition at line 112 of file em_rtc.h.

References RTC.

void RTC_Enable ( bool  enable)

Enable/disable RTC.

Note
The enabling/disabling of RTC modifies the RTC CTRL register which requires synchronization into the low-frequency domain. If this register is modified before a previous update to the same register has completed, this function will stall until the previous synchronization has completed. This only applies to the Gecko Family. See comments in the regSync() internal function call.
Parameters
[in]enableTrue to enable counting, false to disable.

Definition at line 226 of file em_rtc.c.

References _RTC_CTRL_EN_SHIFT, BUS_RegBitWrite(), and RTC.

Referenced by RTC_CounterReset(), RTCDRV_DeInit(), and UDELAY_Calibrate().

void RTC_Init ( const RTC_Init_TypeDef init)

Initialize RTC.

Note that the compare values must be set separately with RTC_CompareSet() prior to the use of this function if configuring the RTC to start when initialization is completed.

Note
The initialization of the RTC modifies the RTC CTRL register which requires synchronization into the low-frequency domain. If this register is modified before a previous update to the same register has completed, this function will stall until the previous synchronization has completed. This only applies to the Gecko Family. See comments in the regSync() internal function call.
Parameters
[in]initA pointer to the RTC initialization structure.

Definition at line 311 of file em_rtc.c.

References RTC_Init_TypeDef::comp0Top, RTC_Init_TypeDef::debugRun, RTC_Init_TypeDef::enable, RTC, RTC_CTRL_COMP0TOP, RTC_CTRL_DEBUGRUN, and RTC_CTRL_EN.

Referenced by RTCDRV_Init(), and UDELAY_Calibrate().

__STATIC_INLINE void RTC_IntClear ( uint32_t  flags)

Clear one or more pending RTC interrupts.

Parameters
[in]flagsRTC interrupt sources to clear. Use a set of interrupt flags OR-ed together to clear multiple interrupt sources for the RTC module (RTC_IFS_nnn).

Definition at line 134 of file em_rtc.h.

References RTC.

Referenced by RTC_IRQHandler().

__STATIC_INLINE void RTC_IntDisable ( uint32_t  flags)

Disable one or more RTC interrupts.

Parameters
[in]flagsRTC interrupt sources to disable. Use a set of interrupt flags OR-ed together to disable multiple interrupt sources for the RTC module (RTC_IFS_nnn).

Definition at line 148 of file em_rtc.h.

References RTC.

__STATIC_INLINE void RTC_IntEnable ( uint32_t  flags)

Enable one or more RTC interrupts.

Note
Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. To ignore a pending interrupt, consider using RTC_IntClear() prior to enabling the interrupt.
Parameters
[in]flagsRTC interrupt sources to enable. Use a set of interrupt flags OR-ed together to set multiple interrupt sources for the RTC module (RTC_IFS_nnn).

Definition at line 167 of file em_rtc.h.

References RTC.

__STATIC_INLINE uint32_t RTC_IntGet ( void  )

Get pending RTC interrupt flags.

Note
Event bits are not cleared by using this function.
Returns
Pending RTC interrupt sources. Returns a set of interrupt flags OR-ed together for multiple interrupt sources in the RTC module (RTC_IFS_nnn).

Definition at line 183 of file em_rtc.h.

References RTC.

Referenced by RTC_IRQHandler().

__STATIC_INLINE uint32_t RTC_IntGetEnabled ( void  )

Get enabled and pending RTC interrupt flags. Useful for handling more interrupt sources in the same interrupt handler.

Note
Interrupt flags are not cleared by using this function.
Returns
Pending and enabled RTC interrupt sources. The return value is the bitwise AND of
  • the enabled interrupt sources in RTC_IEN and
  • the pending interrupt flags RTC_IF.

Definition at line 202 of file em_rtc.h.

References RTC.

__STATIC_INLINE void RTC_IntSet ( uint32_t  flags)

Set one or more pending RTC interrupts from SW.

Parameters
[in]flagsRTC interrupt sources to set to pending. Use a set of interrupt flags OR-ed together to set multiple interrupt sources for the RTC module (RTC_IFS_nnn).

Definition at line 219 of file em_rtc.h.

References RTC.