FD32M0P Microcontroller SDK
|
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. |
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 |
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 |
#define UART_CFG_DEFAULT |
Default Initializer for UART Configuration Struct.
#define UART_FIFO_CFG_DEFAULT |
Default Initializer for UART Fifo Configuration Struct.
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.
uart_regs | : pointer to the UART register space |
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().
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.
uart_regs | : pointer to the UART register space |
uart_cfg_struct | : UART configuration struct |
void |
References uart_cfg_s::baud_rate, UART_REGS_s::CFG, UART_REGS_s::CLK_DIV, uart_cfg_s::clk_div, uart_cfg_s::clk_freq, UART_REGS_s::CLK_SEL, uart_cfg_s::clk_sel, UART_REGS_s::CTRL, uart_cfg_s::cts_en, uart_cfg_s::even_parity, UART_REGS_s::FIFOLS, UART_REGS_s::GFCTL, uart_cfg_s::glitch_filter_width, uart_cfg_s::loopback_en, uart_cfg_s::majority_voting_en, uart_cfg_s::msb_first, uart_cfg_s::num_stop_bits, uart_cfg_s::oversampling, UART_CLK_SEL_u::packed_w, uart_cfg_s::parity_en, uart_cfg_s::rts_en, uart_cfg_s::rts_val, uart_cfg_s::rx_en, uart_cfg_s::rx_timeout_val, uart_cfg_s::stick_parity, uart_cfg_s::tx_en, uart_cfg_s::tx_out_ctrl, uart_cfg_s::tx_out_en, uart_baud_cfg(), UART_CLK_DIV_CLK_DIV_MASK, UART_CLK_SEL_CLK_SEL_MASK, and uart_cfg_s::word_length.
Referenced by UartStdOutInit().
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.
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 |
void |
References UART_REGS_s::BRDDEN, and UART_REGS_s::BRDNUM.
Referenced by uart_cfg().
void uart_clk_en | ( | UART_REGS_s * | regs | ) |
This function enables the UART clk.
uart_regs | : pointer to the UART register space |
void |
References UART_REGS_s::CLK_CTRL.
Referenced by uart_en().
void uart_clk_dis | ( | UART_REGS_s * | regs | ) |
This function disables the UART clk.
uart_regs | : pointer to the UART register space |
void |
References UART_REGS_s::CLK_CTRL.
void uart_en | ( | UART_REGS_s * | regs | ) |
This function enables the UART clock and UART peripheral.
uart_regs | : pointer to the UART register space |
void |
References UART_REGS_s::CTRL, and uart_clk_en().
Referenced by UART_CTRL_WRITE(), and UartStdOutInit().
void uart_dis | ( | UART_REGS_s * | regs | ) |
This function disables the UART peripheral.
uart_regs | : pointer to the UART register space |
void |
References UART_REGS_s::CTRL.
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.
uart_regs | : pointer to the UART register space |
uart_fifo_cfg_struct | : Uart Fifo Configuration Struct |
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.
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.
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 |
num_bytes_written |
References UART_REGS_s::FIFOSTS, and uart_putc().
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.
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 |
txn_done_status |
References UART_REGS_s::FIFOSTS, and uart_putc().
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.
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 |
void |
References UART_REGS_s::FIFOSTS, and uart_putc().
void uart_puts | ( | UART_REGS_s * | regs, |
const char * | data_char_arr ) |
This blocking function puts a string in the UART transmit fifo.
uart_regs | : pointer to the UART register space |
data_char_arr | : string input |
void |
References UART_REGS_s::FIFOSTS, and uart_putc().
|
inlinestatic |
This static inline function puts a charcter in UART transmit fifo, returns the character written.
uart_regs | : pointer to the UART register space |
data_char | character input |
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().
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.
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 |
num_bytes_read |
References UART_REGS_s::FIFOSTS, and uart_getc().
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.
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 |
txn_done_status |
References UART_REGS_s::FIFOSTS, and uart_getc().
void uart_rxfifo_drain_blocking | ( | UART_REGS_s * | regs, |
uint8_t * | buffer, | ||
uint32_t | num_bytes ) |
This blocking function drains the UART receive fifo.
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 |
void |
References UART_REGS_s::FIFOSTS, and uart_getc().
|
inlinestatic |
This static inline function returns a charcter from the UART receive fifo.
uart_regs | : pointer to the UART register space |
uart_result |
References UART_REGS_s::RXDATA.
Referenced by uart_rxfifo_drain_blocking(), uart_rxfifo_drain_nonblocking(), and uart_rxfifo_drain_static_nonblocking().
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.
uart_regs | : pointer to the UART register space |
uart_cfg_struct | : pointer to a uart configuration struct |
void |
References UART_REGS_s::CFG, UART_REGS_s::CLK_DIV, uart_cfg_s::clk_div, UART_REGS_s::CLK_SEL, uart_cfg_s::clk_sel, UART_REGS_s::CTRL, uart_cfg_s::cts_en, uart_cfg_s::even_parity, UART_REGS_s::FIFOLS, UART_REGS_s::GFCTL, uart_cfg_s::glitch_filter_width, uart_cfg_s::loopback_en, uart_cfg_s::majority_voting_en, uart_cfg_s::msb_first, uart_cfg_s::num_stop_bits, uart_cfg_s::oversampling, uart_cfg_s::parity_en, uart_cfg_s::rts_en, uart_cfg_s::rts_val, uart_cfg_s::rx_en, uart_cfg_s::rx_timeout_val, uart_cfg_s::stick_parity, uart_cfg_s::tx_en, uart_cfg_s::tx_out_ctrl, uart_cfg_s::tx_out_en, and uart_cfg_s::word_length.