LEUARTEMLIB

Detailed Description

This module contains functions to control the LEUART peripheral of Silicon Labs 32-bit MCUs and SoCs. The LEUART provides full UART communication using a low frequency 32.768 kHz clock, and has special features for communication without CPU intervention.

Function Documentation

uint32_t LEUART_BaudrateCalc

(

uint32_t

refFreq,

uint32_t

clkdiv

)

Calculate baudrate for LEUART given reference frequency and clock division.

This function returns the baudrate that a LEUART module will use if configured with the given frequency and clock divisor. Notice that this function will not use actual HW configuration. It can be used to determinate if a given configuration is sufficiently accurate for the application.

The setting of a baudrate 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.

Parameters

[in]

leuart

Pointer to LEUART peripheral register block.

[in]

refFreq

LEUART reference clock frequency in Hz that will be used. If set to 0, the currently configured reference clock is assumed.

Notice that this function does not do any configuration. Enabling should normally be done after initialization is done (if not enabled as part of init).

Note

Enabling/disabling 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.

Some LEUART registers require synchronization into the low frequency (LF) domain. The freeze feature allows for several such registers to be modified before passing them to the LF domain simultaneously (which takes place when the freeze mode is disabled).

Note

When enabling freeze mode, this function will wait for all current ongoing LEUART synchronization to LF domain to complete (Normally synchronization will not be in progress.) However for this reason, when using freeze mode, modifications of registers requiring LF synchronization should be done within one freeze enable/disable block to avoid unecessary stalling.

Parameters

[in]

leuart

Pointer to LEUART peripheral register block.

[in]

enable

true - enable freeze, modified registers are not propagated to the LF domain

This function will configure basic settings in order to operate in normal asynchronous mode. Consider using LEUART_Reset() prior to this function if state of configuration is not known, since only configuration settings specified by init are set.

Special control setup not covered by this function may be done either before or after using this function (but normally before enabling) by direct modification of the CTRL register.

Notice that pins used by the LEUART module must be properly configured by the user explicitly, in order for the LEUART to work as intended. (When configuring pins, one should remember to consider the sequence of configuration, in order to avoid unintended pulses/glitches on output pins.)

Note

Initializing 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.

Parameters

[in]

leuart

Pointer to LEUART peripheral register block.

[in]

init

Pointer to initialization structure used to configure basic async setup.

This function is used to quickly receive one 8 bit frame by reading the RXDATA register directly, without checking the STATUS register for the RXDATAV flag. This can be useful from the RXDATAV interrupt handler, i.e. waiting is superfluous, in order to quickly read the received data. Please refer to LEUART_RxDataXGet() for reception of 9 bit frames.

Note

Since this function does not check whether the RXDATA register actually holds valid data, it should only be used in situations when it is certain that there is valid data, ensured by some external program routine, e.g. like when handling an RXDATAV interrupt. The LEUART_Rx() is normally a better choice if the validity of the RXDATA register is not certain.

Notice that possible parity/stop bits are not considered part of specified frame bit length.

This function is used to quickly receive one 8-9 bit frame with extended information by reading the RXDATAX register directly, without checking the STATUS register for the RXDATAV flag. This can be useful from the RXDATAV interrupt handler, i.e. waiting is superfluous, in order to quickly read the received data.

Note

Since this function does not check whether the RXDATAX register actually holds valid data, it should only be used in situations when it is certain that there is valid data, ensured by some external program routine, e.g. like when handling an RXDATAV interrupt. The LEUART_RxExt() is normally a better choice if the validity of the RXDATAX register is not certain.

Notice that possible parity/stop bits are not considered part of specified frame bit length.

Depending on frame length configuration, 8 (least significant) bits from data are transmitted. If frame length is 9, 8 bits are transmitted from data and one bit as specified by CTRL register, BIT8DV field. Please refer to LEUART_TxExt() for transmitting 9 bit frame with full control of all 9 bits.

Notice that possible parity/stop bits in asynchronous mode are not considered part of specified frame bit length.

Note

This function will stall if buffer is full, until buffer becomes available.