RTCCEMLIB

Detailed Description

Real Time Counter (RTCC) Peripheral API.

This module contains functions to control the RTCC peripheral of Silicon Labs 32-bit MCUs and SoCs. The RTCC ensures timekeeping in low energy modes. The RTCC also includes a BCD calendar mode for easy time and date keeping.

Data Structures

struct RTCC_CCChConf_TypeDef
struct RTCC_Init_TypeDef

Macros

#define RTCC_CH_INIT_CAPTURE_DEFAULT
#define RTCC_CH_INIT_COMPARE_DEFAULT
#define RTCC_CH_VALID (ch)    ((unsigned)(ch) < RTCC_CC_NUM)
#define RTCC_INIT_DEFAULT
#define rtccPRSCh0 0U
#define rtccPRSCh1 1U
#define rtccPRSCh10 10U
#define rtccPRSCh11 11U
#define rtccPRSCh2 2U
#define rtccPRSCh3 3U
#define rtccPRSCh4 4U
#define rtccPRSCh5 5U
#define rtccPRSCh6 6U
#define rtccPRSCh7 7U
#define rtccPRSCh8 8U
#define rtccPRSCh9 9U

Typedefs

typedef uint8_t RTCC_PRSSel_TypeDef

Enumerations

enum RTCC_CapComChMode_TypeDef {
rtccCapComChModeOff = _RTCC_CC_CTRL_MODE_OFF,
rtccCapComChModeCapture = _RTCC_CC_CTRL_MODE_INPUTCAPTURE,
rtccCapComChModeCompare = _RTCC_CC_CTRL_MODE_OUTPUTCOMPARE
}
enum RTCC_CntPresc_TypeDef {
rtccCntPresc_1 = _RTCC_CFG_CNTPRESC_DIV1,
rtccCntPresc_2 = _RTCC_CFG_CNTPRESC_DIV2,
rtccCntPresc_4 = _RTCC_CFG_CNTPRESC_DIV4,
rtccCntPresc_8 = _RTCC_CFG_CNTPRESC_DIV8,
rtccCntPresc_16 = _RTCC_CFG_CNTPRESC_DIV16,
rtccCntPresc_32 = _RTCC_CFG_CNTPRESC_DIV32,
rtccCntPresc_64 = _RTCC_CFG_CNTPRESC_DIV64,
rtccCntPresc_128 = _RTCC_CFG_CNTPRESC_DIV128,
rtccCntPresc_256 = _RTCC_CFG_CNTPRESC_DIV256,
rtccCntPresc_512 = _RTCC_CFG_CNTPRESC_DIV512,
rtccCntPresc_1024 = _RTCC_CFG_CNTPRESC_DIV1024,
rtccCntPresc_2048 = _RTCC_CFG_CNTPRESC_DIV2048,
rtccCntPresc_4096 = _RTCC_CFG_CNTPRESC_DIV4096,
rtccCntPresc_8192 = _RTCC_CFG_CNTPRESC_DIV8192,
rtccCntPresc_16384 = _RTCC_CFG_CNTPRESC_DIV16384,
rtccCntPresc_32768 = _RTCC_CFG_CNTPRESC_DIV32768
}
enum RTCC_CompBase_TypeDef {
rtccCompBaseCnt = _RTCC_CC_CTRL_COMPBASE_CNT,
rtccCompBasePreCnt = _RTCC_CC_CTRL_COMPBASE_PRECNT
}
enum RTCC_CompMatchOutAction_TypeDef {
rtccCompMatchOutActionPulse = _RTCC_CC_CTRL_CMOA_PULSE,
rtccCompMatchOutActionToggle = _RTCC_CC_CTRL_CMOA_TOGGLE,
rtccCompMatchOutActionClear = _RTCC_CC_CTRL_CMOA_CLEAR,
rtccCompMatchOutActionSet = _RTCC_CC_CTRL_CMOA_SET
}
enum RTCC_InEdgeSel_TypeDef {
rtccInEdgeRising = _RTCC_CC_CTRL_ICEDGE_RISING,
rtccInEdgeFalling = _RTCC_CC_CTRL_ICEDGE_FALLING,
rtccInEdgeBoth = _RTCC_CC_CTRL_ICEDGE_BOTH,
rtccInEdgeNone = _RTCC_CC_CTRL_ICEDGE_NONE
}
enum RTCC_PrescMode_TypeDef {
rtccCntTickPresc = _RTCC_CFG_CNTTICK_PRESC,
rtccCntTickCCV0Match = _RTCC_CFG_CNTTICK_CCV0MATCH
}

Functions

__STATIC_INLINE uint32_t RTCC_ChannelCaptureValueGet (int ch)
Get RTCC input capture register value for selected channel.
__STATIC_INLINE uint32_t RTCC_ChannelCCVGet (int ch)
Get RTCC capture/compare register value for selected channel. For parts with separate capture compare value registers, this function returns the compare value.
__STATIC_INLINE void RTCC_ChannelCCVSet (int ch, uint32_t value)
Set RTCC capture/compare register value for selected channel. For parts with separate capture compare value registers, this function sets the compare value.
__STATIC_INLINE uint32_t RTCC_ChannelCompareValueGet (int ch)
Get RTCC compare register value for selected channel.
__STATIC_INLINE void RTCC_ChannelCompareValueSet (int ch, uint32_t value)
Set RTCC compare register value for selected channel.
void RTCC_ChannelInit (int ch, RTCC_CCChConf_TypeDef const *confPtr)
Configure the selected capture/compare channel of the RTCC.
__STATIC_INLINE uint32_t RTCC_CombinedCounterGet (void)
Get combined CNT/PRECNT register content.
__STATIC_INLINE uint32_t RTCC_CounterGet (void)
Get RTCC counter value.
__STATIC_INLINE void RTCC_CounterSet (uint32_t value)
Set RTCC CNT counter.
void RTCC_Enable (bool enable)
Enable/disable RTCC counting.
void RTCC_Init (const RTCC_Init_TypeDef *init)
Initialize RTCC.
__STATIC_INLINE void RTCC_IntClear (uint32_t flags)
Clear one or more pending RTCC interrupts.
__STATIC_INLINE void RTCC_IntDisable (uint32_t flags)
Disable one or more RTCC interrupts.
__STATIC_INLINE void RTCC_IntEnable (uint32_t flags)
Enable one or more RTCC interrupts.
__STATIC_INLINE uint32_t RTCC_IntGet (void)
Get pending RTCC interrupt flags.
__STATIC_INLINE uint32_t RTCC_IntGetEnabled (void)
Get enabled and pending RTCC interrupt flags.
__STATIC_INLINE void RTCC_IntSet (uint32_t flags)
Set one or more pending RTCC interrupts from SW.
__STATIC_INLINE void RTCC_Lock (void)
Lock RTCC registers.
__STATIC_INLINE uint32_t RTCC_PreCounterGet (void)
Get RTCC pre-counter value.
__STATIC_INLINE void RTCC_PreCounterSet (uint32_t preCntVal)
Set RTCC pre-counter value.
void RTCC_Reset (void)
Restore RTCC to its reset state.
__STATIC_INLINE void RTCC_Start (void)
Start RTCC counter.
void RTCC_StatusClear (void)
Clear the STATUS register.
__STATIC_INLINE uint32_t RTCC_StatusGet (void)
Get STATUS register value.
__STATIC_INLINE void RTCC_Stop (void)
Stop the RTCC counter.
__STATIC_INLINE void RTCC_SyncWait (void)
Wait for the RTCC to complete all synchronization of register changes and commands.
__STATIC_INLINE void RTCC_Unlock (void)
Unlock RTCC registers.

Macro Definition Documentation

#define RTCC_CH_INIT_CAPTURE_DEFAULT
Value:
{ \
rtccCapComChModeCapture, /* Select input capture mode. */ \
rtccCompMatchOutActionPulse, /* Don't care. */ \
0, /* Use PRS channel 0 as trigger. */ \
rtccInEdgeRising, /* Capture on rising edge. */ \
rtccCompBaseCnt, /* Don't care. */ \
}

Default RTCC channel input capture initialization structure.

Definition at line 345 of file em_rtcc.h .

#define RTCC_CH_INIT_COMPARE_DEFAULT
Value:
{ \
rtccCapComChModeCompare, /* Select output compare mode. */ \
rtccCompMatchOutActionPulse, /* Create pulse on compare match. */ \
0, /* Don't care. */ \
rtccInEdgeNone, /* Don't care. */ \
rtccCompBaseCnt, /* Use CNT for comparison. */ \
}

Default RTCC channel output compare initialization structure.

Definition at line 335 of file em_rtcc.h .

#define RTCC_CH_VALID ( ch ) ((unsigned)(ch) < RTCC_CC_NUM)

Number of RTCC capture/compare channels Validation of valid RTCC channel for assert statements.

Definition at line 388 of file em_rtcc.h .

Referenced by RTCC_ChannelCaptureValueGet() , RTCC_ChannelCompareValueGet() , RTCC_ChannelCompareValueSet() , and RTCC_ChannelInit() .

#define RTCC_INIT_DEFAULT
Value:
{ \
true, /* Start counting when init done. */ \
false, /* Disable RTCC during debug halt. */ \
false, /* Disable precounter wrap on ch. 0 CCV value. */ \
false, /* Disable counter wrap on ch. 1 CCV value. */ \
rtccCntPresc_32, /* 977 us per tick. */ \
rtccCntTickPresc, /* Counter increments according to prescaler value.*/ \
}

Default RTCC initialization structure.

Definition at line 292 of file em_rtcc.h .

Referenced by UDELAY_Calibrate() .

#define rtccPRSCh0   0U

Deprecated PRS channel values. New code should use an integer instead of using these deprecated enum values.

Definition at line 170 of file em_rtcc.h .

Typedef Documentation

typedef uint8_t RTCC_PRSSel_TypeDef

PRS channel number. This type is used when configuring input capture mode on a RTCC channel.

Definition at line 166 of file em_rtcc.h .

Enumeration Type Documentation

Capture/Compare channel mode.

Enumerator
rtccCapComChModeOff

Capture/Compare channel turned off.

rtccCapComChModeCapture

Capture mode.

rtccCapComChModeCompare

Compare mode.

Definition at line 150 of file em_rtcc.h .

Counter prescaler selection.

Enumerator
rtccCntPresc_1

Divide clock by 1.

rtccCntPresc_2

Divide clock by 2.

rtccCntPresc_4

Divide clock by 4.

rtccCntPresc_8

Divide clock by 8.

rtccCntPresc_16

Divide clock by 16.

rtccCntPresc_32

Divide clock by 32.

rtccCntPresc_64

Divide clock by 64.

rtccCntPresc_128

Divide clock by 128.

rtccCntPresc_256

Divide clock by 256.

rtccCntPresc_512

Divide clock by 512.

rtccCntPresc_1024

Divide clock by 1024.

rtccCntPresc_2048

Divide clock by 2048.

rtccCntPresc_4096

Divide clock by 4096.

rtccCntPresc_8192

Divide clock by 8192.

rtccCntPresc_16384

Divide clock by 16384.

rtccCntPresc_32768

Divide clock by 32768.

Definition at line 107 of file em_rtcc.h .

Capture/Compare channel compare mode.

Enumerator
rtccCompBaseCnt

CCVx is compared with the CNT register.

rtccCompBasePreCnt

CCVx is compared with a CNT[16:0] and PRECNT[14:0].

Definition at line 192 of file em_rtcc.h .

Compare match output action mode.

Enumerator
rtccCompMatchOutActionPulse

Generate a pulse.

rtccCompMatchOutActionToggle

Toggle output.

rtccCompMatchOutActionClear

Clear output.

rtccCompMatchOutActionSet

Set output.

Definition at line 157 of file em_rtcc.h .

Input edge select.

Enumerator
rtccInEdgeRising

Rising edges detected.

rtccInEdgeFalling

Falling edges detected.

rtccInEdgeBoth

Both edges detected.

rtccInEdgeNone

No edge detection, signal is left as is.

Definition at line 184 of file em_rtcc.h .

Prescaler mode of the RTCC counter.

Enumerator
rtccCntTickPresc

CNT register ticks according to the prescaler value.

rtccCntTickCCV0Match

CNT register ticks when PRECNT matches the 15 least significant bits of ch. 0 CCV register.

Definition at line 139 of file em_rtcc.h .

Function Documentation

__STATIC_INLINE uint32_t RTCC_ChannelCaptureValueGet ( int ch )

Get RTCC input capture register value for selected channel.

Parameters
[in] ch Channel selector.
Returns
Capture register value.

Definition at line 444 of file em_rtcc.h .

References RTCC_CH_VALID .

__STATIC_INLINE uint32_t RTCC_ChannelCCVGet ( int ch )

Get RTCC capture/compare register value for selected channel. For parts with separate capture compare value registers, this function returns the compare value.

Parameters
[in] ch Channel selector.
Returns
Capture/compare register value.

Definition at line 466 of file em_rtcc.h .

References RTCC_ChannelCompareValueGet() .

__STATIC_INLINE void RTCC_ChannelCCVSet ( int ch,
uint32_t value
)

Set RTCC capture/compare register value for selected channel. For parts with separate capture compare value registers, this function sets the compare value.

Parameters
[in] ch Channel selector.
[in] value Capture/compare register value

Definition at line 483 of file em_rtcc.h .

References RTCC_ChannelCompareValueSet() .

__STATIC_INLINE uint32_t RTCC_ChannelCompareValueGet ( int ch )

Get RTCC compare register value for selected channel.

Parameters
[in] ch Channel selector.
Returns
Compare register value.

Definition at line 404 of file em_rtcc.h .

References RTCC_CH_VALID .

Referenced by RTCC_ChannelCCVGet() .

__STATIC_INLINE void RTCC_ChannelCompareValueSet ( int ch,
uint32_t value
)

Set RTCC compare register value for selected channel.

Parameters
[in] ch Channel selector.
[in] value Compare register value

Definition at line 424 of file em_rtcc.h .

References RTCC_CH_VALID .

Referenced by RTCC_ChannelCCVSet() .

void RTCC_ChannelInit ( int ch,
RTCC_CCChConf_TypeDef const * confPtr
)

Configure the selected capture/compare channel of the RTCC.

Use this function to configure an RTCC channel. Select capture/compare mode, match output action, overflow output action, and PRS input configuration. See the configuration structure RTCC_CCChConf_TypeDef for more details.

Parameters
[in] ch A channel selector.
[in] confPtr A pointer to the configuration structure.

Configure the selected capture/compare channel.

Definition at line 79 of file em_rtcc.c .

References RTCC_CCChConf_TypeDef::chMode , RTCC_CCChConf_TypeDef::compBase , RTCC_CCChConf_TypeDef::compMatchOutAction , RTCC_CCChConf_TypeDef::inputEdgeSel , RTCC_CCChConf_TypeDef::prsSel , RTCC_CH_VALID , and rtccCapComChModeCapture .

Referenced by RTCDRV_Init() .

__STATIC_INLINE uint32_t RTCC_CombinedCounterGet ( void )

Get combined CNT/PRECNT register content.

Returns
CNT/PRECNT register value.

Definition at line 561 of file em_rtcc.h .

__STATIC_INLINE uint32_t RTCC_CounterGet ( void )

Get RTCC counter value.

Returns
Current RTCC counter value.

Definition at line 578 of file em_rtcc.h .

__STATIC_INLINE void RTCC_CounterSet ( uint32_t value )

Set RTCC CNT counter.

Parameters
[in] value CNT value.

Definition at line 595 of file em_rtcc.h .

void RTCC_Enable ( bool enable )

Enable/disable RTCC counting.

Parameters
[in] enable True to enable RTCC counting, false to disable counting.

Definition at line 117 of file em_rtcc.c .

References BUS_RegBitWrite() , RTCC_Start() , RTCC_Stop() , and RTCC_SyncWait() .

Referenced by RTCDRV_DeInit() , and UDELAY_Calibrate() .

void RTCC_Init ( const RTCC_Init_TypeDef * init )

Initialize RTCC.

Note that the compare values must be set separately with RTCC_CompareSet(), which should probably be done prior to the use of this function if configuring the RTCC to start when initialization is completed.

Parameters
[in] init A pointer to the RTCC initialization structure.

Definition at line 157 of file em_rtcc.c .

References RTCC_Init_TypeDef::cntWrapOnCCV1 , RTCC_Init_TypeDef::debugRun , RTCC_Init_TypeDef::enable , RTCC_Init_TypeDef::precntWrapOnCCV0 , RTCC_Init_TypeDef::presc , RTCC_Init_TypeDef::prescMode , and RTCC_SyncWait() .

Referenced by RTCDRV_Init() , and UDELAY_Calibrate() .

__STATIC_INLINE void RTCC_IntClear ( uint32_t flags )

Clear one or more pending RTCC interrupts.

Parameters
[in] flags RTCC interrupt sources to clear. Use a set of interrupt flags OR-ed together to clear multiple interrupt sources.

Definition at line 664 of file em_rtcc.h .

Referenced by RTCC_IRQHandler() , and RTCC_Reset() .

__STATIC_INLINE void RTCC_IntDisable ( uint32_t flags )

Disable one or more RTCC interrupts.

Parameters
[in] flags RTCC interrupt sources to disable. Use a set of interrupt flags OR-ed together to disable multiple interrupt.

Definition at line 681 of file em_rtcc.h .

__STATIC_INLINE void RTCC_IntEnable ( uint32_t flags )

Enable one or more RTCC 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 RTCC_IntClear() prior to enabling the interrupt.
Parameters
[in] flags RTCC interrupt sources to enable. Use a set of interrupt flags OR-ed together to set multiple interrupt.

Definition at line 699 of file em_rtcc.h .

__STATIC_INLINE uint32_t RTCC_IntGet ( void )

Get pending RTCC interrupt flags.

Note
Event bits are not cleared by using this function.
Returns
Pending RTCC interrupt sources. Returns a set of interrupt flags OR-ed together for the interrupt sources set.

Definition at line 715 of file em_rtcc.h .

Referenced by RTCC_IRQHandler() .

__STATIC_INLINE uint32_t RTCC_IntGetEnabled ( void )

Get enabled and pending RTCC interrupt flags.

Useful for handling more interrupt sources in the same interrupt handler.

Returns
Pending and enabled RTCC interrupt sources. Returns a set of interrupt flags OR-ed together for the interrupt sources set.

Definition at line 731 of file em_rtcc.h .

__STATIC_INLINE void RTCC_IntSet ( uint32_t flags )

Set one or more pending RTCC interrupts from SW.

Parameters
[in] flags RTCC interrupt sources to set to pending. Use a set of interrupt flags (RTCC_IFS_nnn).

Definition at line 749 of file em_rtcc.h .

__STATIC_INLINE void RTCC_Lock ( void )

Lock RTCC registers.

Note
When RTCC registers are locked, RTCC_CTRL, RTCC_PRECNT, RTCC_CNT, RTCC_TIME, RTCC_DATE, RTCC_IEN, RTCC_POWERDOWN and RTCC_CCx_XXX registers cannot be written to.

Definition at line 767 of file em_rtcc.h .

__STATIC_INLINE uint32_t RTCC_PreCounterGet ( void )

Get RTCC pre-counter value.

Returns
Current RTCC pre-counter value.

Definition at line 796 of file em_rtcc.h .

__STATIC_INLINE void RTCC_PreCounterSet ( uint32_t preCntVal )

Set RTCC pre-counter value.

Parameters
[in] preCntVal RTCC pre-counter value to be set.

Definition at line 813 of file em_rtcc.h .

__STATIC_INLINE void RTCC_Start ( void )

Start RTCC counter.

This function will send a start command to the RTCC peripheral. The RTCC peripheral will use some LF clock ticks before the command is executed. The RTCC_SyncWait() function can be used to wait for the start command to be executed.

Note
This function requires the RTCC to be enabled.

Definition at line 893 of file em_rtcc.h .

References RTCC_SyncWait() .

Referenced by RTCC_Enable() .

__STATIC_INLINE uint32_t RTCC_StatusGet ( void )

Get STATUS register value.

Returns
Current STATUS register value.

Definition at line 853 of file em_rtcc.h .

__STATIC_INLINE void RTCC_Stop ( void )

Stop the RTCC counter.

This function will send a stop command to the RTCC peripheral. The RTCC peripheral will use some LF clock ticks before the command is executed. The RTCC_SyncWait() function can be used to wait for the stop command to be executed.

Note
This function requires the RTCC to be enabled.

Definition at line 912 of file em_rtcc.h .

References RTCC_SyncWait() .

Referenced by RTCC_Enable() , and RTCC_Reset() .

__STATIC_INLINE void RTCC_Unlock ( void )

Unlock RTCC registers.

Note
When RTCC registers are locked, RTCC_CTRL, RTCC_PRECNT, RTCC_CNT, RTCC_TIME, RTCC_DATE, RTCC_IEN, RTCC_POWERDOWN and RTCC_CCx_XXX registers cannot be written to.

Definition at line 954 of file em_rtcc.h .

Referenced by RTCC_Reset() .