CRYOTIMEREMLIB
Detailed Description
Ultra Low Energy Timer/Counter (CRYOTIMER) Peripheral API.
The CRYOTIMER is a 32 bit counter which operates on a low frequency oscillator, and is capable of running in all Energy Modes. It can provide periodic wakeup events and PRS signals which can be used to wake up peripherals from any energy mode. The CRYOTIMER provides a very wide range of periods for the interrupts facilitating flexible ultra-low energy operation. Because of its simplicity, the CRYOTIMER is a lower energy solution for periodically waking up the MCU compared to the RTCC.
To configure the CRYOTIMER you call the CRYOTIMER_Init function. This function will configure the CRYOTIMER peripheral according to the user configuration.
When using the CRYOTIMER the user has to choose which oscillator to use as the CRYOTIMER clock. The CRYOTIMER supports 3 low frequency clock these are LFXO, LFRCO and ULFRCO. The oscillator that is chosen 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 cmuOsc_LFRCO and LFXO cmuOsc_LFXO must be enabled 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.
Here is an example of how to use the CRYOTIMER to generate an interrupt at a configurable period.
To use the CRYOTIMER in EM4 the user has to enable EM4 wakeup in the CRYOTIMER. This can be done either in the CRYOTIMER_Init_TypeDef structure when initializing the CRYOTIMER or at a later time by using CRYOTIMER_EM4WakeupEnable .
Note that when using the CRYOTIMER to wakeup from EM4 the application has the responsibility to clear the wakeup event. This is done by calling CRYOTIMER_IntClear . If the user does not clear the wakeup event then the wakeup event will stay pending and will cause an immediate wakeup the next time the application attempts to enter EM4.
Here is an example of how to use the CRYOTIMER to wakeup from EM4 after a configurable amount of time.
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.
Data Structures |
|
struct | CRYOTIMER_Init_TypeDef |
Macros |
|
#define | CRYOTIMER_INIT_DEFAULT |
Functions |
|
__STATIC_INLINE uint32_t | CRYOTIMER_CounterGet (void) |
Get the CRYOTIMER counter value.
|
|
__STATIC_INLINE void | CRYOTIMER_EM4WakeupEnable (bool enable) |
Enable/disable EM4 wakeup capability.
|
|
__STATIC_INLINE void | CRYOTIMER_Enable (bool enable) |
Enable/disable the CRYOTIMER.
|
|
void | CRYOTIMER_Init (const CRYOTIMER_Init_TypeDef *init) |
Initialize the CRYOTIMER.
|
|
__STATIC_INLINE void | CRYOTIMER_IntClear (uint32_t flags) |
Clear the CRYOTIMER period interrupt.
|
|
__STATIC_INLINE void | CRYOTIMER_IntDisable (uint32_t flags) |
Disable one or more CRYOTIMER interrupts.
|
|
__STATIC_INLINE void | CRYOTIMER_IntEnable (uint32_t flags) |
Enable one or more CRYOTIMER interrupts.
|
|
__STATIC_INLINE uint32_t | CRYOTIMER_IntGet (void) |
Get the CRYOTIMER interrupt flag.
|
|
__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.
|
|
__STATIC_INLINE void | CRYOTIMER_IntSet (uint32_t flags) |
Set the CRYOTIMER period interrupt flag.
|
|
__STATIC_INLINE uint32_t | CRYOTIMER_PeriodGet (void) |
Get the CRYOTIMER period select value.
|
|
__STATIC_INLINE void | CRYOTIMER_PeriodSet (uint32_t period) |
Set the CRYOTIMER period select.
|
|
Macro Definition Documentation
#define CRYOTIMER_INIT_DEFAULT |
Default CRYOTIMER init structure.
Definition at line
204
of file
em_cryotimer.h
.
Enumeration Type Documentation
Period selection value
Definition at line
138
of file
em_cryotimer.h
.
Prescaler selection.
Definition at line
119
of file
em_cryotimer.h
.
Function Documentation
__STATIC_INLINE uint32_t CRYOTIMER_CounterGet | ( | void |
|
) |
Get the CRYOTIMER counter value.
- Returns
- Returns the current CRYOTIMER counter value.
Definition at line
351
of file
em_cryotimer.h
.
References CRYOTIMER .
__STATIC_INLINE void CRYOTIMER_EM4WakeupEnable | ( | bool |
enable
|
) |
Enable/disable EM4 wakeup capability.
- Parameters
-
[in] enable
True to enable EM4 wakeup, false to disable.
Definition at line
363
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
|
) |
Enable/disable the CRYOTIMER.
- Parameters
-
[in] enable
True to enable the CRYOTIMER, false to disable.
Definition at line
377
of file
em_cryotimer.h
.
References _CRYOTIMER_CTRL_EN_SHIFT , BUS_RegBitWrite() , and CRYOTIMER .
void CRYOTIMER_Init | ( | const CRYOTIMER_Init_TypeDef * |
init
|
) |
Initialize the CRYOTIMER.
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] init
Pointer 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 .
__STATIC_INLINE void CRYOTIMER_IntClear | ( | uint32_t |
flags
|
) |
Clear the CRYOTIMER period interrupt.
- Parameters
-
[in] flags
CRYOTIMER interrupt sources to clear. Use CRYOTIMER_IFC_PERIOD
Definition at line
225
of file
em_cryotimer.h
.
References _CRYOTIMER_IFC_MASK , and CRYOTIMER .
__STATIC_INLINE void CRYOTIMER_IntDisable | ( | uint32_t |
flags
|
) |
Disable one or more CRYOTIMER interrupts.
- Parameters
-
[in] flags
CRYOTIMER interrupt sources to disable. Use CRYOTIMER_IEN_PERIOD .
Definition at line
287
of file
em_cryotimer.h
.
References _CRYOTIMER_IEN_MASK , and CRYOTIMER .
__STATIC_INLINE void CRYOTIMER_IntEnable | ( | uint32_t |
flags
|
) |
Enable one or more CRYOTIMER interrupts.
- Parameters
-
[in] flags
CRYOTIMER interrupt sources to enable. Use CRYOTIMER_IEN_PERIOD .
Definition at line
275
of file
em_cryotimer.h
.
References _CRYOTIMER_IEN_MASK , and CRYOTIMER .
__STATIC_INLINE uint32_t CRYOTIMER_IntGet | ( | void |
|
) |
Get the CRYOTIMER interrupt flag.
- Note
- The event bits are not cleared by the use of this function.
- Returns
- Pending CRYOTIMER interrupt sources. The only interrupt source available for the CRYOTIMER is CRYOTIMER_IF_PERIOD .
Definition at line
241
of file
em_cryotimer.h
.
References CRYOTIMER .
__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.
- 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
260
of file
em_cryotimer.h
.
References _CRYOTIMER_IEN_MASK , and CRYOTIMER .
__STATIC_INLINE void CRYOTIMER_IntSet | ( | uint32_t |
flags
|
) |
Set the CRYOTIMER period interrupt flag.
- Note
- Writes 1 to the interrupt flag set register.
- Parameters
-
[in] flags
CRYOTIMER interrupt sources to set to pending. Use CRYOTIMER_IFS_PERIOD .
Definition at line
303
of file
em_cryotimer.h
.
References _CRYOTIMER_IFS_MASK , and CRYOTIMER .
__STATIC_INLINE uint32_t CRYOTIMER_PeriodGet | ( | void |
|
) |
Get the CRYOTIMER period select value.
- 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
339
of file
em_cryotimer.h
.
References CRYOTIMER .
__STATIC_INLINE void CRYOTIMER_PeriodSet | ( | uint32_t |
period
|
) |
Set the CRYOTIMER period select.
- Note
- Sets the duration between the Interrupts/Wakeup events based on the pre-scaled clock.
- Parameters
-
[in] period
2^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
321
of file
em_cryotimer.h
.
References _CRYOTIMER_PERIODSEL_MASK , and CRYOTIMER .