35 #if defined(BURTC_PRESENT)
68 __STATIC_INLINE uint32_t divToLog2(uint32_t div)
73 EFM_ASSERT((div > 0) && (div <= 32768));
76 log2 = (31 - __CLZ(div));
90 __STATIC_INLINE
void regSync(uint32_t mask)
95 if ((BURTC->FREEZE & BURTC_FREEZE_REGFREEZE)
96 || ((BURTC->CTRL & _BURTC_CTRL_CLKSEL_MASK) == BURTC_CTRL_CLKSEL_NONE))
102 while (BURTC->SYNCBUSY & mask)
130 void BURTC_Init(
const BURTC_Init_TypeDef *burtcInit)
136 EFM_ASSERT(burtcInit != (BURTC_Init_TypeDef *) 0);
138 EFM_ASSERT((burtcInit->clkDiv >= 1) && (burtcInit->clkDiv <= 128));
141 EFM_ASSERT(burtcInit->lowPowerComp <= 6);
143 EFM_ASSERT((burtcInit->enable ==
false) ||
144 ((burtcInit->enable ==
true)
145 && (burtcInit->mode != burtcModeDisable)));
147 EFM_ASSERT((burtcInit->clkSel != burtcClkSelULFRCO)
148 || ((burtcInit->clkSel == burtcClkSelULFRCO)
149 && (burtcInit->lowPowerMode == burtcLPDisable)));
155 presc = divToLog2(burtcInit->clkDiv);
158 if (burtcInit->enable)
160 BURTC_FreezeEnable(
true);
165 regSync(BURTC_SYNCBUSY_LPMODE);
168 BURTC->LPMODE = (uint32_t) (burtcInit->lowPowerMode);
171 ctrl = (BURTC_CTRL_RSTEN
173 | (burtcInit->debugRun << _BURTC_CTRL_DEBUGRUN_SHIFT)
174 | (burtcInit->compare0Top << _BURTC_CTRL_COMP0TOP_SHIFT)
175 | (burtcInit->lowPowerComp << _BURTC_CTRL_LPCOMP_SHIFT)
176 | (presc << _BURTC_CTRL_PRESC_SHIFT)
177 | (burtcInit->clkSel)
178 | (burtcInit->timeStamp << _BURTC_CTRL_BUMODETSEN_SHIFT));
181 BURTC_IntClear(0xFFFFFFFF);
187 if (burtcInit->enable)
193 BURTC_FreezeEnable(
false);
205 void BURTC_CompareSet(
unsigned int comp, uint32_t value)
209 EFM_ASSERT(comp == 0);
213 regSync(BURTC_SYNCBUSY_COMP0);
216 BURTC->COMP0 = value;
227 uint32_t BURTC_CompareGet(
unsigned int comp)
231 EFM_ASSERT(comp == 0);
240 void BURTC_CounterReset(
void)
256 void BURTC_Reset(
void)
274 uint32_t BURTC_ClockFreqGet(
void)
280 clkSel = BURTC->CTRL & _BURTC_CTRL_CLKSEL_MASK;
281 clkDiv = (BURTC->CTRL & _BURTC_CTRL_PRESC_MASK) >> _BURTC_CTRL_PRESC_SHIFT;
286 case BURTC_CTRL_CLKSEL_ULFRCO:
287 if (_BURTC_CTRL_PRESC_DIV1 == clkDiv)
299 case BURTC_CTRL_CLKSEL_LFRCO:
304 case BURTC_CTRL_CLKSEL_LFXO:
__STATIC_INLINE unsigned int BUS_RegBitRead(volatile const uint32_t *addr, unsigned int bit)
Perform a single-bit read operation on a peripheral register.
uint32_t SystemLFXOClockGet(void)
Get low frequency crystal oscillator clock frequency for target system.
uint32_t SystemLFRCOClockGet(void)
Get low frequency RC oscillator clock frequency for target system.
Backup Real Time Counter (BURTC) peripheral API.
__STATIC_INLINE void BUS_RegBitWrite(volatile uint32_t *addr, unsigned int bit, unsigned int val)
Perform a single-bit write operation on a peripheral register.
uint32_t SystemULFRCOClockGet(void)
Get ultra low frequency RC oscillator clock frequency for target system.