EFM32 Pearl Gecko Software Documentation  efm32pg1-doc-4.2.1
CRYOTIMER

Ultra Low Energy Timer/Counter (CRYOTIMER) Peripheral API. More...

Data Structures

struct  CRYOTIMER_Init_TypeDef
 

Macros

#define CRYOTIMER_INIT_DEFAULT
 

Enumerations

enum  CRYOTIMER_Presc_TypeDef {
  cryotimerPresc_1 = _CRYOTIMER_CTRL_PRESC_DIV1,
  cryotimerPresc_2 = _CRYOTIMER_CTRL_PRESC_DIV2,
  cryotimerPresc_4 = _CRYOTIMER_CTRL_PRESC_DIV4,
  cryotimerPresc_8 = _CRYOTIMER_CTRL_PRESC_DIV8,
  cryotimerPresc_16 = _CRYOTIMER_CTRL_PRESC_DIV16,
  cryotimerPresc_32 = _CRYOTIMER_CTRL_PRESC_DIV32,
  cryotimerPresc_64 = _CRYOTIMER_CTRL_PRESC_DIV64,
  cryotimerPresc_128 = _CRYOTIMER_CTRL_PRESC_DIV128
}
 
enum  CRYOTIMER_Osc_TypeDef {
  cryotimerOscLFRCO = _CRYOTIMER_CTRL_OSCSEL_LFRCO,
  cryotimerOscLFXO = _CRYOTIMER_CTRL_OSCSEL_LFXO,
  cryotimerOscULFRCO = _CRYOTIMER_CTRL_OSCSEL_ULFRCO
}
 
enum  CRYOTIMER_Period_TypeDef {
  cryotimerPeriod_1 = 0,
  cryotimerPeriod_2 = 1,
  cryotimerPeriod_4 = 2,
  cryotimerPeriod_8 = 3,
  cryotimerPeriod_16 = 4,
  cryotimerPeriod_32 = 5,
  cryotimerPeriod_64 = 6,
  cryotimerPeriod_128 = 7,
  cryotimerPeriod_256 = 8,
  cryotimerPeriod_512 = 9,
  cryotimerPeriod_1k = 10,
  cryotimerPeriod_2k = 11,
  cryotimerPeriod_4k = 12,
  cryotimerPeriod_8k = 13,
  cryotimerPeriod_16k = 14,
  cryotimerPeriod_32k = 15,
  cryotimerPeriod_64k = 16,
  cryotimerPeriod_128k = 17,
  cryotimerPeriod_256k = 18,
  cryotimerPeriod_512k = 19,
  cryotimerPeriod_1m = 20,
  cryotimerPeriod_2m = 21,
  cryotimerPeriod_4m = 22,
  cryotimerPeriod_8m = 23,
  cryotimerPeriod_16m = 24,
  cryotimerPeriod_32m = 25,
  cryotimerPeriod_64m = 26,
  cryotimerPeriod_128m = 27,
  cryotimerPeriod_256m = 28,
  cryotimerPeriod_512m = 29,
  cryotimerPeriod_1024m = 30,
  cryotimerPeriod_2048m = 31,
  cryotimerPeriod_4096m = 32
}
 

Functions

__STATIC_INLINE void CRYOTIMER_IntClear (uint32_t flags)
 Clear the CRYOTIMER period interrupt. More...
 
__STATIC_INLINE uint32_t CRYOTIMER_IntGet (void)
 Get the CRYOTIMER interrupt flag. More...
 
__STATIC_INLINE uint32_t CRYOTIMER_IntGetEnabled (void)
 Get enabled and pending CRYOTIMER interrupt flags. Useful for handling more interrupt sources in the same interrupt handler. More...
 
__STATIC_INLINE void CRYOTIMER_IntEnable (uint32_t flags)
 Enable one or more CRYOTIMER interrupts. More...
 
__STATIC_INLINE void CRYOTIMER_IntDisable (uint32_t flags)
 Disable one or more CRYOTIMER interrupts. More...
 
__STATIC_INLINE void CRYOTIMER_IntSet (uint32_t flags)
 Set the CRYOTIMER period interrupt flag. More...
 
__STATIC_INLINE void CRYOTIMER_PeriodSet (uint32_t period)
 Set the CRYOTIMER period select. More...
 
__STATIC_INLINE uint32_t CRYOTIMER_PeriodGet (void)
 Get the CRYOTIMER period select value. More...
 
__STATIC_INLINE uint32_t CRYOTIMER_CounterGet (void)
 Get the CRYOTIMER counter value. More...
 
__STATIC_INLINE void CRYOTIMER_EM4WakeupEnable (bool enable)
 Enable/disable EM4 wakeup capability. More...
 
__STATIC_INLINE void CRYOTIMER_Enable (bool enable)
 Enable/disable the CRYOTIMER. More...
 
void CRYOTIMER_Init (const CRYOTIMER_Init_TypeDef *init)
 Initialize the CRYOTIMER. More...
 

Detailed Description

The user is responsible for choosing which oscillator to use for the CRYOTIMER. The oscillator that is choosen must be enabled and ready before calling this CRYOTIMER_Init function. See CMU_OscillatorEnable for details of how to enable and wait for an oscillator to become ready. Note that ULFRCO is always ready while LFRCO and LFXO must be enable by the user.

Note that the only oscillator which is running in EM3 is ULFRCO. Keep this in mind when choosing which oscillator to use for the CRYOTIMER.

Special care must be taken if the user wants the CRYOTIMER to run during EM4. All the low frequency oscillators can be used in EM4, however the oscillator that is used must be be configured to be retained when going into EM4. This can be configured by using functions in the EMU module. See EMU_EM4Init and EMU_EM4Init_TypeDef. If an oscillator is retained in EM4 the user is also responsible for unlatching the retained configuration on a wakeup from EM4.

Macro Definition Documentation

#define CRYOTIMER_INIT_DEFAULT
Value:
{ \
true, /* Start counting when init done. */ \
false, /* Disable CRYOTIMER during debug halt. */ \
false, /* Disable EM4 wakeup. */ \
cryotimerOscLFRCO, /* Select Low Frequency RC Oscillator. */ \
cryotimerPresc_1, /* LF Oscillator frequency undivided. */ \
cryotimerPeriod_4096m, /* Wakeup event after 4096M pre-scaled clock cycles. */ \
}

Default CRYOTIMER init structure.

Definition at line 173 of file em_cryotimer.h.

Enumeration Type Documentation

Prescaler selection.

Enumerator
cryotimerPresc_1 

Divide clock by 1.

cryotimerPresc_2 

Divide clock by 2.

cryotimerPresc_4 

Divide clock by 4.

cryotimerPresc_8 

Divide clock by 8.

cryotimerPresc_16 

Divide clock by 16.

cryotimerPresc_32 

Divide clock by 32.

cryotimerPresc_64 

Divide clock by 64.

cryotimerPresc_128 

Divide clock by 128.

Definition at line 84 of file em_cryotimer.h.

Low frequency oscillator selection.

Enumerator
cryotimerOscLFRCO 

Select Low Frequency RC Oscillator.

cryotimerOscLFXO 

Select Low Frequency Crystal Oscillator.

cryotimerOscULFRCO 

Select Ultra Low Frequency RC Oscillator.

Definition at line 97 of file em_cryotimer.h.

Period selection value

Enumerator
cryotimerPeriod_1 

Wakeup event after every Pre-scaled clock cycle.

cryotimerPeriod_2 

Wakeup event after 2 Pre-scaled clock cycles.

cryotimerPeriod_4 

Wakeup event after 4 Pre-scaled clock cycles.

cryotimerPeriod_8 

Wakeup event after 8 Pre-scaled clock cycles.

cryotimerPeriod_16 

Wakeup event after 16 Pre-scaled clock cycles.

cryotimerPeriod_32 

Wakeup event after 32 Pre-scaled clock cycles.

cryotimerPeriod_64 

Wakeup event after 64 Pre-scaled clock cycles.

cryotimerPeriod_128 

Wakeup event after 128 Pre-scaled clock cycles.

cryotimerPeriod_256 

Wakeup event after 256 Pre-scaled clock cycles.

cryotimerPeriod_512 

Wakeup event after 512 Pre-scaled clock cycles.

cryotimerPeriod_1k 

Wakeup event after 1k Pre-scaled clock cycles.

cryotimerPeriod_2k 

Wakeup event after 2k Pre-scaled clock cycles.

cryotimerPeriod_4k 

Wakeup event after 4k Pre-scaled clock cycles.

cryotimerPeriod_8k 

Wakeup event after 8k Pre-scaled clock cycles.

cryotimerPeriod_16k 

Wakeup event after 16k Pre-scaled clock cycles.

cryotimerPeriod_32k 

Wakeup event after 32k Pre-scaled clock cycles.

cryotimerPeriod_64k 

Wakeup event after 64k Pre-scaled clock cycles.

cryotimerPeriod_128k 

Wakeup event after 128k Pre-scaled clock cycles.

cryotimerPeriod_256k 

Wakeup event after 256k Pre-scaled clock cycles.

cryotimerPeriod_512k 

Wakeup event after 512k Pre-scaled clock cycles.

cryotimerPeriod_1m 

Wakeup event after 1m Pre-scaled clock cycles.

cryotimerPeriod_2m 

Wakeup event after 2m Pre-scaled clock cycles.

cryotimerPeriod_4m 

Wakeup event after 4m Pre-scaled clock cycles.

cryotimerPeriod_8m 

Wakeup event after 8m Pre-scaled clock cycles.

cryotimerPeriod_16m 

Wakeup event after 16m Pre-scaled clock cycles.

cryotimerPeriod_32m 

Wakeup event after 32m Pre-scaled clock cycles.

cryotimerPeriod_64m 

Wakeup event after 64m Pre-scaled clock cycles.

cryotimerPeriod_128m 

Wakeup event after 128m Pre-scaled clock cycles.

cryotimerPeriod_256m 

Wakeup event after 256m Pre-scaled clock cycles.

cryotimerPeriod_512m 

Wakeup event after 512m Pre-scaled clock cycles.

cryotimerPeriod_1024m 

Wakeup event after 1024m Pre-scaled clock cycles.

cryotimerPeriod_2048m 

Wakeup event after 2048m Pre-scaled clock cycles.

cryotimerPeriod_4096m 

Wakeup event after 4096m Pre-scaled clock cycles.

Definition at line 105 of file em_cryotimer.h.

Function Documentation

__STATIC_INLINE void CRYOTIMER_IntClear ( uint32_t  flags)
Parameters
[in]flagsCRYOTIMER interrupt sources to clear. Use CRYOTIMER_IFC_PERIOD

Definition at line 194 of file em_cryotimer.h.

References _CRYOTIMER_IFC_MASK, and CRYOTIMER.

__STATIC_INLINE uint32_t CRYOTIMER_IntGet ( void  )
Note
The event bits are not cleared by the use of this function.
Returns
Pending CRYOTIMER interrupt sources.

Definition at line 209 of file em_cryotimer.h.

References CRYOTIMER.

__STATIC_INLINE uint32_t CRYOTIMER_IntGetEnabled ( void  )
Note
Interrupt flags are not cleared by the use of this function.
Returns
Pending and enabled CRYOTIMER interrupt sources The return value is the bitwise AND of
  • the enabled interrupt sources in CRYOTIMER_IEN and
  • the pending interrupt flags CRYOTIMER_IF

Definition at line 228 of file em_cryotimer.h.

References _CRYOTIMER_IEN_MASK, and CRYOTIMER.

__STATIC_INLINE void CRYOTIMER_IntEnable ( uint32_t  flags)
Parameters
[in]flagsCRYOTIMER interrupt sources to enable. Use CRYOTIMER_IEN_PERIOD.

Definition at line 243 of file em_cryotimer.h.

References _CRYOTIMER_IEN_MASK, and CRYOTIMER.

__STATIC_INLINE void CRYOTIMER_IntDisable ( uint32_t  flags)
Parameters
[in]flagsCRYOTIMER interrupt sources to disable. Use CRYOTIMER_IEN_PERIOD.

Definition at line 255 of file em_cryotimer.h.

References _CRYOTIMER_IEN_MASK, and CRYOTIMER.

__STATIC_INLINE void CRYOTIMER_IntSet ( uint32_t  flags)
Note
Writes 1 to the interrupt flag set register.
Parameters
[in]flagsCRYOTIMER interrupt sources to set to pending. Use CRYOTIMER_IFS_PERIOD.

Definition at line 270 of file em_cryotimer.h.

References _CRYOTIMER_IFS_MASK, and CRYOTIMER.

__STATIC_INLINE void CRYOTIMER_PeriodSet ( uint32_t  period)
Note
Sets the duration between the Interrupts/Wakeup events based on the pre-scaled clock.
Parameters
[in]period2^period is the number of clock cycles before a wakeup event or interrupt is triggered. The CRYOTIMER_Periodsel_TypeDef enum can be used a convenience type when calling this function.

Definition at line 288 of file em_cryotimer.h.

References _CRYOTIMER_PERIODSEL_MASK, and CRYOTIMER.

__STATIC_INLINE uint32_t CRYOTIMER_PeriodGet ( void  )
Note
Gets the duration between the Interrupts/Wakeup events in the CRYOTIMER.
Returns
Duration between the interrupts/wakeup events. Returns the value of the PERIODSEL register. The number of clock cycles can be calculated as the 2^n where n is the return value of this function.

Definition at line 306 of file em_cryotimer.h.

References CRYOTIMER.

__STATIC_INLINE uint32_t CRYOTIMER_CounterGet ( void  )
Returns
Returns the current CRYOTIMER counter value.

Definition at line 318 of file em_cryotimer.h.

References CRYOTIMER.

__STATIC_INLINE void CRYOTIMER_EM4WakeupEnable ( bool  enable)
Parameters
[in]enableTrue to enable EM4 wakeup, false to disable.

Definition at line 330 of file em_cryotimer.h.

References _CRYOTIMER_EM4WUEN_EM4WU_SHIFT, BUS_RegBitWrite(), and CRYOTIMER.

Referenced by CRYOTIMER_Init().

__STATIC_INLINE void CRYOTIMER_Enable ( bool  enable)
Parameters
[in]enableTrue to enable the CRYOTIMER, false to disable.

Definition at line 342 of file em_cryotimer.h.

References _CRYOTIMER_CTRL_EN_SHIFT, BUS_RegBitWrite(), and CRYOTIMER.

void CRYOTIMER_Init ( const CRYOTIMER_Init_TypeDef init)

Use this function to initialize the CRYOTIMER. Select prescaler setting and select low frequency oscillator. Refer to the configuration structure CRYOTIMER_Init_TypeDef for more details.

Parameters
[in]initPointer to initialization structure.

Definition at line 51 of file em_cryotimer.c.

References _CRYOTIMER_CTRL_DEBUGRUN_SHIFT, _CRYOTIMER_CTRL_EN_SHIFT, _CRYOTIMER_CTRL_OSCSEL_SHIFT, _CRYOTIMER_CTRL_PRESC_SHIFT, _CRYOTIMER_PERIODSEL_MASK, CRYOTIMER, CRYOTIMER_EM4WakeupEnable(), CRYOTIMER_Init_TypeDef::debugRun, CRYOTIMER_Init_TypeDef::em4Wakeup, CRYOTIMER_Init_TypeDef::enable, CRYOTIMER_Init_TypeDef::osc, CRYOTIMER_Init_TypeDef::period, and CRYOTIMER_Init_TypeDef::presc.