FD32M0P Microcontroller SDK
Loading...
Searching...
No Matches

Data Structures

struct  uart_cfg_s
 UART Configuration Struct. More...
struct  uart_fifo_cfg_s
 UART Fifo Configuration Struct. More...

Macros

#define UART_CFG_DEFAULT
 Default Initializer for UART Configuration Struct.
#define UART_FIFO_CFG_DEFAULT
 Default Initializer for UART Fifo Configuration Struct.

Functions

void uart_init (UART_REGS_s *regs)
 This function initalizes the UART, enables power, resets the peripheral, and does reset status clear, blocks asynchronous fast clock requests.
void uart_cfg (UART_REGS_s *regs, const uart_cfg_s *cfg)
 This function configures the UART, data frame, clock, baud rate configurations, transmission and reception enables.
void uart_baud_cfg (UART_REGS_s *regs, uint32_t baud_rate, uint32_t clk_freq, uint32_t oversampling)
 This function calculates the UART baud rate, based on the inputs provided.
void uart_clk_en (UART_REGS_s *regs)
 This function enables the UART clk.
void uart_clk_dis (UART_REGS_s *regs)
 This function disables the UART clk.
void uart_en (UART_REGS_s *regs)
 This function enables the UART clock and UART peripheral.
void uart_dis (UART_REGS_s *regs)
 This function disables the UART peripheral.
void uart_fifo_cfg (UART_REGS_s *regs, const uart_fifo_cfg_s *fifo_cfg)
 This function configures the UART transmit and receive fifos, does fifo enable or disable.
uint32_t uart_txfifo_fill_nonblocking (UART_REGS_s *regs, const uint8_t *buffer, uint32_t num_bytes)
 This non blocking function fills the UART transmit fifo, user needs to update the buffer pointer and number of data bytes to be written, returns number of data bytes written.
bool uart_txfifo_fill_static_nonblocking (UART_REGS_s *regs, const uint8_t *buffer, uint32_t num_bytes, uint32_t rst_int_ctr)
 This non blocking static function fills the UART transmit fifo, auto updates the buffer pointer and number of bytes to be written, returns a boolean for transaction done.
void uart_txfifo_fill_blocking (UART_REGS_s *regs, const uint8_t *buffer, uint32_t num_bytes)
 This blocking function fills the UART transmit fifo.
void uart_puts (UART_REGS_s *regs, const char *data_char_arr)
 This blocking function puts a string in the UART transmit fifo.
static uint8_t uart_putc (UART_REGS_s *regs, const unsigned char data_char)
 This static inline function puts a charcter in UART transmit fifo, returns the character written.
uint32_t uart_rxfifo_drain_nonblocking (UART_REGS_s *regs, uint8_t *buffer, uint32_t num_bytes)
 This non blocking function drains the UART receive fifo, user needs to update the buffer pointer and number of data bytes to be read, returns number of data bytes read.
bool uart_rxfifo_drain_static_nonblocking (UART_REGS_s *regs, uint8_t *buffer, uint32_t num_bytes, uint32_t rst_int_ctr)
 This non blocking static function drains the UART receive fifo, auto updates the buffer pointer and number of data bytes to be read returns a boolean for transaction done.
void uart_rxfifo_drain_blocking (UART_REGS_s *regs, uint8_t *buffer, uint32_t num_bytes)
 This blocking function drains the UART receive fifo.
static uint8_t uart_getc (UART_REGS_s *regs)
 This static inline function returns a charcter from the UART receive fifo.
void uart_read_cfg (UART_REGS_s *regs, uart_cfg_s *rd_cfg)
 This function reads the UART configurations from the register space, puts them in the configuration struct provided in the input.

Detailed Description


Data Structure Documentation

◆ uart_cfg_s

struct uart_cfg_s

UART Configuration Struct.

Data Fields
UART_CLK_SEL_E clk_sel
uint8_t clk_div
uint32_t baud_rate
uint32_t clk_freq
UART_CTRL_OS_E oversampling
UART_CFG_WRD_LEN_E word_length
bool parity_en
bool even_parity
UART_CFG_STCK_PAR_E stick_parity
UART_CFG_STOP_BIT_E num_stop_bits
UART_CTRL_UART_MSB_E msb_first
bool majority_voting_en
bool loopback_en
UART_CTRL_TX_EN_E tx_en
bool rx_en
UART_CTRL_TX_OUT_EN_E tx_out_en
UART_CTRL_TX_OUT_CTRL_E tx_out_ctrl
bool cts_en
bool rts_en
bool rts_val
uint8_t glitch_filter_width
uint8_t rx_timeout_val

◆ uart_fifo_cfg_s

struct uart_fifo_cfg_s

UART Fifo Configuration Struct.

Data Fields
UART_FIFOLS_TX_FIFO_LS_E tx_fifo_lvl_sel
UART_FIFOLS_RX_FIFO_LS_E rx_fifo_lvl_sel
uint32_t fifo_en

Macro Definition Documentation

◆ UART_CFG_DEFAULT

#define UART_CFG_DEFAULT
Value:
{ \
.clk_sel = UART_CLK_SEL_CLK_APB, \
.clk_div = 0, \
.oversampling = UART_CTRL_OS_FACTOR_16, \
.word_length = UART_CFG_WRD_LEN_8_BITS, \
.num_stop_bits = UART_CFG_STOP_BIT_ONE, \
.msb_first = UART_CTRL_UART_MSB_LAST, \
.tx_en = UART_CTRL_TX_EN_HW, \
.rx_timeout_val = 10 \
}
@ UART_CFG_WRD_LEN_8_BITS
0x3
Definition UART_REGS.h:886
@ UART_CFG_STOP_BIT_ONE
0x0
Definition UART_REGS.h:901
@ UART_CLK_SEL_CLK_APB
0x0
Definition UART_REGS.h:854
@ UART_CTRL_TX_EN_HW
0x1
Definition UART_REGS.h:927
@ UART_CTRL_OS_FACTOR_16
0x10
Definition UART_REGS.h:919
@ UART_CTRL_UART_MSB_LAST
0x0
Definition UART_REGS.h:909

Default Initializer for UART Configuration Struct.

◆ UART_FIFO_CFG_DEFAULT

#define UART_FIFO_CFG_DEFAULT
Value:
{ \
.tx_fifo_lvl_sel = UART_FIFOLS_TX_FIFO_LS_EMPTY, \
.fifo_en = 1 \
}
@ UART_FIFOLS_RX_FIFO_LS_ALMOST_EMPTY
0x0
Definition UART_REGS.h:873
@ UART_FIFOLS_TX_FIFO_LS_EMPTY
0x0
Definition UART_REGS.h:863

Default Initializer for UART Fifo Configuration Struct.

Function Documentation

◆ uart_init()

void uart_init ( UART_REGS_s * regs)

This function initalizes the UART, enables power, resets the peripheral, and does reset status clear, blocks asynchronous fast clock requests.

Parameters
uart_regs: pointer to the UART register space
Return values
void

References UART_RST_STS_u::packed_w, UART_REGS_s::RST_STS, UART_CLKCFG_BLCK_ASYNC_KEY, UART_CLKCFG_WRITE(), UART_PWR_EN_PWR_EN_KEY, UART_PWR_EN_WRITE(), UART_RST_CTRL_RST_KEY, UART_RST_CTRL_RST_STS_CLR_KEY, UART_RST_CTRL_WRITE(), and UART_RST_STS_RST_STS_MASK.

Referenced by UartStdOutInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uart_cfg()

◆ uart_baud_cfg()

void uart_baud_cfg ( UART_REGS_s * regs,
uint32_t baud_rate,
uint32_t clk_freq,
uint32_t oversampling )

This function calculates the UART baud rate, based on the inputs provided.

Parameters
uart_regs: pointer to the UART register space
baud_rate: any of the standard UART baud rates
clk_freq: clock_frequency
oversampling: UART oversampling rate
Return values
void

References UART_REGS_s::BRDDEN, and UART_REGS_s::BRDNUM.

Referenced by uart_cfg().

Here is the caller graph for this function:

◆ uart_clk_en()

void uart_clk_en ( UART_REGS_s * regs)

This function enables the UART clk.

Parameters
uart_regs: pointer to the UART register space
Return values
void

References UART_REGS_s::CLK_CTRL.

Referenced by uart_en().

Here is the caller graph for this function:

◆ uart_clk_dis()

void uart_clk_dis ( UART_REGS_s * regs)

This function disables the UART clk.

Parameters
uart_regs: pointer to the UART register space
Return values
void

References UART_REGS_s::CLK_CTRL.

◆ uart_en()

void uart_en ( UART_REGS_s * regs)

This function enables the UART clock and UART peripheral.

Parameters
uart_regs: pointer to the UART register space
Return values
void

References UART_REGS_s::CTRL, and uart_clk_en().

Referenced by UART_CTRL_WRITE(), and UartStdOutInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uart_dis()

void uart_dis ( UART_REGS_s * regs)

This function disables the UART peripheral.

Parameters
uart_regs: pointer to the UART register space
Return values
void

References UART_REGS_s::CTRL.

◆ uart_fifo_cfg()

void uart_fifo_cfg ( UART_REGS_s * regs,
const uart_fifo_cfg_s * fifo_cfg )

This function configures the UART transmit and receive fifos, does fifo enable or disable.

Parameters
uart_regs: pointer to the UART register space
uart_fifo_cfg_struct: Uart Fifo Configuration Struct
Return values
void

References UART_REGS_s::CTRL, uart_fifo_cfg_s::fifo_en, UART_REGS_s::FIFOLS, uart_fifo_cfg_s::rx_fifo_lvl_sel, and uart_fifo_cfg_s::tx_fifo_lvl_sel.

◆ uart_txfifo_fill_nonblocking()

uint32_t uart_txfifo_fill_nonblocking ( UART_REGS_s * regs,
const uint8_t * buffer,
uint32_t num_bytes )

This non blocking function fills the UART transmit fifo, user needs to update the buffer pointer and number of data bytes to be written, returns number of data bytes written.

Parameters
uart_regs: pointer to the UART register space
buffer: pointer to the data buffer
num_bytes: number of bytes to be written to the transmit fifo
Return values
num_bytes_written

References UART_REGS_s::FIFOSTS, and uart_putc().

Here is the call graph for this function:

◆ uart_txfifo_fill_static_nonblocking()

bool uart_txfifo_fill_static_nonblocking ( UART_REGS_s * regs,
const uint8_t * buffer,
uint32_t num_bytes,
uint32_t rst_int_ctr )

This non blocking static function fills the UART transmit fifo, auto updates the buffer pointer and number of bytes to be written, returns a boolean for transaction done.

Parameters
uart_regs: pointer to the UART register space
buffer: pointer to the data buffer
num_bytes: number of bytes to be written to the transmit fifo
rst_int_ctr: reset the internal counter once transaction is done
Return values
txn_done_status

References UART_REGS_s::FIFOSTS, and uart_putc().

Here is the call graph for this function:

◆ uart_txfifo_fill_blocking()

void uart_txfifo_fill_blocking ( UART_REGS_s * regs,
const uint8_t * buffer,
uint32_t num_bytes )

This blocking function fills the UART transmit fifo.

Parameters
uart_regs: pointer to the UART register space
buffer: pointer to the data buffer
num_bytes: number of bytes to be written to the transmit fifo
Return values
void

References UART_REGS_s::FIFOSTS, and uart_putc().

Here is the call graph for this function:

◆ uart_puts()

void uart_puts ( UART_REGS_s * regs,
const char * data_char_arr )

This blocking function puts a string in the UART transmit fifo.

Parameters
uart_regs: pointer to the UART register space
data_char_arr: string input
Return values
void

References UART_REGS_s::FIFOSTS, and uart_putc().

Here is the call graph for this function:

◆ uart_putc()

uint8_t uart_putc ( UART_REGS_s * regs,
const unsigned char data_char )
inlinestatic

This static inline function puts a charcter in UART transmit fifo, returns the character written.

Parameters
uart_regs: pointer to the UART register space
data_charcharacter input
Return values
data_char

References UART_TXDATA_u::packed_w, and UART_REGS_s::TXDATA.

Referenced by uart_puts(), uart_txfifo_fill_blocking(), uart_txfifo_fill_nonblocking(), and uart_txfifo_fill_static_nonblocking().

Here is the caller graph for this function:

◆ uart_rxfifo_drain_nonblocking()

uint32_t uart_rxfifo_drain_nonblocking ( UART_REGS_s * regs,
uint8_t * buffer,
uint32_t num_bytes )

This non blocking function drains the UART receive fifo, user needs to update the buffer pointer and number of data bytes to be read, returns number of data bytes read.

Parameters
uart_regs: pointer to the UART register space
buffer: pointer to the data buffer
num_bytes: number of bytes to be read from receive fifo
Return values
num_bytes_read

References UART_REGS_s::FIFOSTS, and uart_getc().

Here is the call graph for this function:

◆ uart_rxfifo_drain_static_nonblocking()

bool uart_rxfifo_drain_static_nonblocking ( UART_REGS_s * regs,
uint8_t * buffer,
uint32_t num_bytes,
uint32_t rst_int_ctr )

This non blocking static function drains the UART receive fifo, auto updates the buffer pointer and number of data bytes to be read returns a boolean for transaction done.

Parameters
uart_regs: pointer to the UART register space
buffer: pointer to the data buffer
num_bytes: number of bytes to be read from receive fifo
rst_int_ctr: reset the internal counter once transaction is done
Return values
txn_done_status

References UART_REGS_s::FIFOSTS, and uart_getc().

Here is the call graph for this function:

◆ uart_rxfifo_drain_blocking()

void uart_rxfifo_drain_blocking ( UART_REGS_s * regs,
uint8_t * buffer,
uint32_t num_bytes )

This blocking function drains the UART receive fifo.

Parameters
uart_regs: pointer to the UART register space
buffer: pointer to the data buffer
num_bytes: number of bytes to be read from receive fifo
Return values
void

References UART_REGS_s::FIFOSTS, and uart_getc().

Here is the call graph for this function:

◆ uart_getc()

uint8_t uart_getc ( UART_REGS_s * regs)
inlinestatic

This static inline function returns a charcter from the UART receive fifo.

Parameters
uart_regs: pointer to the UART register space
Return values
uart_result

References UART_REGS_s::RXDATA.

Referenced by uart_rxfifo_drain_blocking(), uart_rxfifo_drain_nonblocking(), and uart_rxfifo_drain_static_nonblocking().

Here is the caller graph for this function:

◆ uart_read_cfg()