LETIMER - Low Energy Timer#

Low Energy Timer (LETIMER) Peripheral API.

This module contains functions to control the LETIMER peripheral of Silicon Labs 32-bit MCUs and SoCs. The LETIMER is a down-counter that can keep track of time and output configurable waveforms.

Modules#

LETIMER_Init_TypeDef

Enumerations#

enum
letimerRepeatFree = _LETIMER_CTRL_REPMODE_FREE
letimerRepeatOneshot = _LETIMER_CTRL_REPMODE_ONESHOT
letimerRepeatBuffered = _LETIMER_CTRL_REPMODE_BUFFERED
letimerRepeatDouble = _LETIMER_CTRL_REPMODE_DOUBLE
}

Repeat mode.

enum
letimerUFOANone = _LETIMER_CTRL_UFOA0_NONE
letimerUFOAToggle = _LETIMER_CTRL_UFOA0_TOGGLE
letimerUFOAPulse = _LETIMER_CTRL_UFOA0_PULSE
letimerUFOAPwm = _LETIMER_CTRL_UFOA0_PWM
}

Underflow action on output.

Functions#

uint32_t
LETIMER_CompareGet(LETIMER_TypeDef *letimer, unsigned int comp)

Get the LETIMER compare register value.

void
LETIMER_CompareSet(LETIMER_TypeDef *letimer, unsigned int comp, uint32_t value)

Set the LETIMER compare register value.

uint32_t
LETIMER_CounterGet(LETIMER_TypeDef *letimer)

Get LETIMER counter value.

void
LETIMER_CounterSet(LETIMER_TypeDef *letimer, uint32_t value)

Set LETIMER counter value.

void
LETIMER_Enable(LETIMER_TypeDef *letimer, bool enable)

Start/stop LETIMER.

void
LETIMER_Init(LETIMER_TypeDef *letimer, const LETIMER_Init_TypeDef *init)

Initialize LETIMER.

void
LETIMER_IntClear(LETIMER_TypeDef *letimer, uint32_t flags)

Clear one or more pending LETIMER interrupts.

void
LETIMER_IntDisable(LETIMER_TypeDef *letimer, uint32_t flags)

Disable one or more LETIMER interrupts.

void
LETIMER_IntEnable(LETIMER_TypeDef *letimer, uint32_t flags)

Enable one or more LETIMER interrupts.

uint32_t
LETIMER_IntGet(LETIMER_TypeDef *letimer)

Get pending LETIMER interrupt flags.

uint32_t
LETIMER_IntGetEnabled(LETIMER_TypeDef *letimer)

Get enabled and pending LETIMER interrupt flags.

void
LETIMER_IntSet(LETIMER_TypeDef *letimer, uint32_t flags)

Set one or more pending LETIMER interrupts from SW.

void
LETIMER_Lock(LETIMER_TypeDef *letimer)

Lock LETIMER registers.

void
LETIMER_Unlock(LETIMER_TypeDef *letimer)

Unlock LETIMER registers.

uint32_t
LETIMER_RepeatGet(LETIMER_TypeDef *letimer, unsigned int rep)

Get the LETIMER repeat register value.

void
LETIMER_RepeatSet(LETIMER_TypeDef *letimer, unsigned int rep, uint32_t value)

Set the LETIMER repeat counter register value.

void
LETIMER_Reset(LETIMER_TypeDef *letimer)

Reset LETIMER to the same state that it was in after a hardware reset.

void
LETIMER_SyncWait(LETIMER_TypeDef *letimer)

Wait for the LETIMER to complete all synchronization of register changes and commands.

void
LETIMER_TopSet(LETIMER_TypeDef *letimer, uint32_t value)

Set the LETIMER top value.

uint32_t
LETIMER_TopGet(LETIMER_TypeDef *letimer)

Get the current LETIMER top value.

Macros#

#define

Default configuration for LETIMER initialization structure.

Enumeration Documentation#

LETIMER_RepeatMode_TypeDef#

LETIMER_RepeatMode_TypeDef

Repeat mode.

Enumerator
letimerRepeatFree

Count until stopped by SW.

letimerRepeatOneshot

Count REP0 times.

letimerRepeatBuffered

Count REP0 times, if REP1 has been written to, it is loaded into REP0 when REP0 is about to be decremented to 0.

letimerRepeatDouble

Run as long as both REP0 and REP1 are not 0.


Definition at line 52 of file platform/emlib/inc/em_letimer.h

LETIMER_UFOA_TypeDef#

LETIMER_UFOA_TypeDef

Underflow action on output.

Enumerator
letimerUFOANone

No output action.

letimerUFOAToggle

Toggle output when counter underflows.

letimerUFOAPulse

Hold output one LETIMER clock cycle when counter underflows.

letimerUFOAPwm

Set output idle when counter underflows, and active when matching COMP1.


Definition at line 70 of file platform/emlib/inc/em_letimer.h

Function Documentation#

LETIMER_CompareGet#

uint32_t LETIMER_CompareGet (LETIMER_TypeDef *letimer, unsigned int comp)

Get the LETIMER compare register value.

Parameters
[in]letimer

A pointer to the LETIMER peripheral register block.

[in]comp

A compare register to get, either 0 or 1.

Returns

  • A compare register value, 0 if invalid register selected.


Definition at line 124 of file platform/emlib/src/em_letimer.c

LETIMER_CompareSet#

void LETIMER_CompareSet (LETIMER_TypeDef *letimer, unsigned int comp, uint32_t value)

Set the LETIMER compare register value.

Parameters
[in]letimer

A pointer to the LETIMER peripheral register block.

[in]comp

A compare register to set, either 0 or 1.

[in]value

An initialization value (<= 0x0000ffff).

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 LETIMER_Sync() internal function call.


Definition at line 213 of file platform/emlib/src/em_letimer.c

LETIMER_CounterGet#

uint32_t LETIMER_CounterGet (LETIMER_TypeDef *letimer)

Get LETIMER counter value.

Parameters
[in]letimer

Pointer to the LETIMER peripheral register block.

Returns

  • Current LETIMER counter value.


Definition at line 165 of file platform/emlib/src/em_letimer.c

LETIMER_CounterSet#

void LETIMER_CounterSet (LETIMER_TypeDef *letimer, uint32_t value)

Set LETIMER counter value.

Parameters
[in]letimer

Pointer to the LETIMER peripheral register block.

[in]value

New counter value.


Definition at line 184 of file platform/emlib/src/em_letimer.c

LETIMER_Enable#

void LETIMER_Enable (LETIMER_TypeDef *letimer, bool enable)

Start/stop LETIMER.

Parameters
[in]letimer

A pointer to the LETIMER peripheral register block.

[in]enable

True to enable counting, false to disable.

Note

  • The enabling/disabling of the LETIMER modifies the LETIMER CMD 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 LETIMER_Sync() internal function call.


Definition at line 263 of file platform/emlib/src/em_letimer.c

LETIMER_Init#

void LETIMER_Init (LETIMER_TypeDef *letimer, const LETIMER_Init_TypeDef *init)

Initialize LETIMER.

Parameters
[in]letimer

A pointer to the LETIMER peripheral register block.

[in]init

A pointer to the LETIMER initialization structure.

Note that the compare/repeat values must be set separately with LETIMER_CompareSet() and LETIMER_RepeatSet(). That should probably be done prior using this function if configuring the LETIMER to start when initialization is complete.

Note

  • The initialization of the LETIMER modifies the LETIMER CTRL/CMD registers which require synchronization into the low-frequency domain. If any of those registers are 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 LETIMER_Sync() internal function call.


Definition at line 354 of file platform/emlib/src/em_letimer.c

LETIMER_IntClear#

void LETIMER_IntClear (LETIMER_TypeDef *letimer, uint32_t flags)

Clear one or more pending LETIMER interrupts.

Parameters
[in]letimer

Pointer to LETIMER peripheral register block.

[in]flags

Pending LETIMER interrupt source to clear. Use a bitwise logic OR combination of valid interrupt flags for the LETIMER module (LETIMER_IF_nnn).


Definition at line 167 of file platform/emlib/inc/em_letimer.h

LETIMER_IntDisable#

void LETIMER_IntDisable (LETIMER_TypeDef *letimer, uint32_t flags)

Disable one or more LETIMER interrupts.

Parameters
[in]letimer

Pointer to LETIMER peripheral register block.

[in]flags

LETIMER interrupt sources to disable. Use a bitwise logic OR combination of valid interrupt flags for the LETIMER module (LETIMER_IF_nnn).


Definition at line 187 of file platform/emlib/inc/em_letimer.h

LETIMER_IntEnable#

void LETIMER_IntEnable (LETIMER_TypeDef *letimer, uint32_t flags)

Enable one or more LETIMER interrupts.

Parameters
[in]letimer

Pointer to the LETIMER peripheral register block.

[in]flags

LETIMER interrupt sources to enable. Use a bitwise logic OR combination of valid interrupt flags for the LETIMER module (LETIMER_IF_nnn).

Note

  • Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. To ignore a pending interrupt, consider using LETIMER_IntClear() prior to enabling the interrupt.


Definition at line 208 of file platform/emlib/inc/em_letimer.h

LETIMER_IntGet#

uint32_t LETIMER_IntGet (LETIMER_TypeDef *letimer)

Get pending LETIMER interrupt flags.

Parameters
[in]letimer

Pointer to LETIMER peripheral register block.

Note

  • Event bits are not cleared by the use of this function.

Returns

  • LETIMER interrupt sources pending. A bitwise logic OR combination of valid interrupt flags for the LETIMER module (LETIMER_IF_nnn).


Definition at line 227 of file platform/emlib/inc/em_letimer.h

LETIMER_IntGetEnabled#

uint32_t LETIMER_IntGetEnabled (LETIMER_TypeDef *letimer)

Get enabled and pending LETIMER interrupt flags.

Parameters
[in]letimer

Pointer to LETIMER peripheral register block.

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

Note

  • Event bits are not cleared by the use of this function.

Returns

  • Pending and enabled LETIMER interrupt sources. Return value is the bitwise AND combination of

    • the OR combination of enabled interrupt sources in LETIMER_IEN_nnn register (LETIMER_IEN_nnn) and

    • the OR combination of valid interrupt flags of the LETIMER module (LETIMER_IF_nnn).


Definition at line 253 of file platform/emlib/inc/em_letimer.h

LETIMER_IntSet#

void LETIMER_IntSet (LETIMER_TypeDef *letimer, uint32_t flags)

Set one or more pending LETIMER interrupts from SW.

Parameters
[in]letimer

Pointer to LETIMER peripheral register block.

[in]flags

LETIMER interrupt sources to set to pending. Use a bitwise logic OR combination of valid interrupt flags for the LETIMER module (LETIMER_IF_nnn).


Definition at line 276 of file platform/emlib/inc/em_letimer.h

LETIMER_Lock#

void LETIMER_Lock (LETIMER_TypeDef *letimer)

Lock LETIMER registers.

Parameters
[in]letimer

Pointer to LETIMER peripheral register block.

Note

  • When LETIMER registers are locked LETIMER_EN, LETIMER_SWRST, LETIMER_CTRL, LETIMER_CMD, LETIMER_CNT, LETIMER_COMPx, LETIMER_TOP, LETIMER_TOPBUFF, LETIMER_REPx, and PRSMODE registers cannot be written to.


Definition at line 298 of file platform/emlib/inc/em_letimer.h

LETIMER_Unlock#

void LETIMER_Unlock (LETIMER_TypeDef *letimer)

Unlock LETIMER registers.

Parameters
[in]letimer

Pointer to LETIMER peripheral register block.


Definition at line 312 of file platform/emlib/inc/em_letimer.h

LETIMER_RepeatGet#

uint32_t LETIMER_RepeatGet (LETIMER_TypeDef *letimer, unsigned int rep)

Get the LETIMER repeat register value.

Parameters
[in]letimer

A pointer to the LETIMER peripheral register block.

[in]rep

Repeat register to get, either 0 or 1.

Returns

  • Repeat register value, 0 if invalid register selected.


Definition at line 450 of file platform/emlib/src/em_letimer.c

LETIMER_RepeatSet#

void LETIMER_RepeatSet (LETIMER_TypeDef *letimer, unsigned int rep, uint32_t value)

Set the LETIMER repeat counter register value.

Parameters
[in]letimer

A pointer to the LETIMER peripheral register block.

[in]rep

Repeat counter register to set, either 0 or 1.

[in]value

An initialization value (<= 0x0000ffff).

Note

  • The setting of a repeat counter 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 LETIMER_Sync() internal function call.


Definition at line 502 of file platform/emlib/src/em_letimer.c

LETIMER_Reset#

void LETIMER_Reset (LETIMER_TypeDef *letimer)

Reset LETIMER to the same state that it was in after a hardware reset.

Parameters
[in]letimer

A pointer to the LETIMER peripheral register block.

Note

  • The ROUTE register is NOT reset by this function to allow for a centralized setup of this feature.


Definition at line 545 of file platform/emlib/src/em_letimer.c

LETIMER_SyncWait#

void LETIMER_SyncWait (LETIMER_TypeDef *letimer)

Wait for the LETIMER to complete all synchronization of register changes and commands.

Parameters
[in]letimer

A pointer to the LETIMER peripheral register block.


Definition at line 605 of file platform/emlib/src/em_letimer.c

LETIMER_TopSet#

void LETIMER_TopSet (LETIMER_TypeDef *letimer, uint32_t value)

Set the LETIMER top value.

Parameters
[in]letimer

A pointer to the LETIMER peripheral register block.

[in]value

The top value. This can be a 16 bit value on series-0 and series-1 devices and a 24 bit value on series-2 devices.

Note

  • The LETIMER is a down-counter, so when the counter reaches 0 then the top value will be loaded into the counter. This function can be used to set the top value.

If the LETIMER is not already configured to use a top value then this function will enable that functionality for the user.


Definition at line 637 of file platform/emlib/src/em_letimer.c

LETIMER_TopGet#

uint32_t LETIMER_TopGet (LETIMER_TypeDef *letimer)

Get the current LETIMER top value.

Parameters
[in]letimer

A pointer to the LETIMER peripheral register block.

Returns

  • The top value. This will be a 16 bit value on series-0 and series-1 devices and a 24 bit value on series-2 devices.


Definition at line 671 of file platform/emlib/src/em_letimer.c

Macro Definition Documentation#

LETIMER_INIT_DEFAULT#

#define LETIMER_INIT_DEFAULT
Value:
{ \
true, /* Enable timer when initialization completes. */ \
false, /* Stop counter during debug halt. */ \
false, /* Do not load COMP0 into CNT on underflow. */ \
false, /* Do not load COMP1 into COMP0 when REP0 reaches 0. */ \
0, /* Idle value 0 for output 0. */ \
0, /* Idle value 0 for output 1. */ \
letimerUFOANone, /* No action on underflow on output 0. */ \
letimerUFOANone, /* No action on underflow on output 1. */ \
letimerRepeatFree, /* Count until stopped by SW. */ \
0 /* Use default top Value. */ \
}

Default configuration for LETIMER initialization structure.


Definition at line 121 of file platform/emlib/inc/em_letimer.h