The Universal Asynchronous Receiver Transmitter features a two-pin UART that can be used for communication and trace purposes and offers an ideal medium for in-situ programming solutions.
Moreover, the association with two peripheral DMA controller (PDC) channels permits packet handling for these tasks with processor time reduced to a minimum.
Functions | |
void | uart_config_optical_interface (Uart *p_uart, struct uart_config_optical *cfg) |
Enable UART optical interface. More... | |
void | uart_disable (Uart *p_uart) |
Disable UART receiver and transmitter. More... | |
void | uart_disable_interrupt (Uart *p_uart, uint32_t ul_sources) |
Disable UART interrupts. More... | |
void | uart_disable_optical_interface (Uart *p_uart) |
Disable UART optical interface. More... | |
void | uart_disable_rx (Uart *p_uart) |
Disable UART receiver. More... | |
void | uart_disable_tx (Uart *p_uart) |
Disable UART transmitter. More... | |
void | uart_enable (Uart *p_uart) |
Enable UART receiver and transmitter. More... | |
void | uart_enable_interrupt (Uart *p_uart, uint32_t ul_sources) |
Enable UART interrupts. More... | |
void | uart_enable_optical_interface (Uart *p_uart) |
Enable UART optical interface. More... | |
void | uart_enable_rx (Uart *p_uart) |
Enable UART receiver. More... | |
void | uart_enable_tx (Uart *p_uart) |
Enable UART transmitter. More... | |
uint32_t | uart_get_interrupt_mask (Uart *p_uart) |
Read UART interrupt mask. More... | |
Pdc * | uart_get_pdc_base (Uart *p_uart) |
Get UART PDC base address. More... | |
uint32_t | uart_get_status (Uart *p_uart) |
Get current status. More... | |
uint32_t | uart_init (Uart *p_uart, const sam_uart_opt_t *p_uart_opt) |
Configure UART with the specified parameters. More... | |
uint32_t | uart_is_rx_buf_end (Uart *p_uart) |
Check if one receive buffer is filled. More... | |
uint32_t | uart_is_rx_buf_full (Uart *p_uart) |
Check if both receive buffers are full. More... | |
uint32_t | uart_is_rx_ready (Uart *p_uart) |
Check if Received data is ready. More... | |
uint32_t | uart_is_tx_buf_empty (Uart *p_uart) |
Check if both transmit buffers are sent out. More... | |
uint32_t | uart_is_tx_buf_end (Uart *p_uart) |
Check if one transmit buffer is sent out. More... | |
uint32_t | uart_is_tx_empty (Uart *p_uart) |
Check if Transmit Hold Register is empty. More... | |
uint32_t | uart_is_tx_ready (Uart *p_uart) |
Check if Transmit is Ready. More... | |
uint32_t | uart_read (Uart *p_uart, uint8_t *puc_data) |
Read from UART Receive Holding Register. More... | |
void | uart_reset (Uart *p_uart) |
Reset UART receiver and transmitter. More... | |
void | uart_reset_rx (Uart *p_uart) |
Reset UART receiver. More... | |
void | uart_reset_status (Uart *p_uart) |
Reset status bits. More... | |
void | uart_reset_tx (Uart *p_uart) |
Reset UART transmitter. More... | |
void | uart_set_clock_divisor (Uart *p_uart, uint16_t us_divisor) |
Set UART clock divisor value. More... | |
void | uart_set_sleepwalking (Uart *p_uart, uint8_t ul_low_value, bool cmpmode, bool cmppar, uint8_t ul_high_value) |
Set sleepwalking match mode. More... | |
void | uart_set_write_protection (Uart *p_uart, bool flag) |
Enables/Disables write protection mode. More... | |
uint32_t | uart_write (Uart *p_uart, const uint8_t uc_data) |
Write to UART Transmit Holding Register Before writing user should check if tx is ready (or empty). More... | |
void uart_config_optical_interface | ( | Uart * | p_uart, |
struct uart_config_optical * | cfg | ||
) |
Enable UART optical interface.
p_uart | Pointer to a UART instance. |
cfg | Pointer to a UART optical interface configuration. |
References Assert, uart_config_optical::clk_div, uart_config_optical::duty, uart_config_optical::rx_filter, uart_config_optical::rx_inverted, uart_config_optical::threshold, and uart_config_optical::tx_inverted.
void uart_disable | ( | Uart * | p_uart | ) |
Disable UART receiver and transmitter.
p_uart | Pointer to a UART instance. |
void uart_disable_interrupt | ( | Uart * | p_uart, |
uint32_t | ul_sources | ||
) |
Disable UART interrupts.
p_uart | Pointer to a UART instance. |
ul_sources | Interrupts to be disabled. |
void uart_disable_optical_interface | ( | Uart * | p_uart | ) |
void uart_disable_rx | ( | Uart * | p_uart | ) |
Disable UART receiver.
p_uart | Pointer to a UART instance. |
void uart_disable_tx | ( | Uart * | p_uart | ) |
Disable UART transmitter.
p_uart | Pointer to a UART instance. |
void uart_enable | ( | Uart * | p_uart | ) |
Enable UART receiver and transmitter.
p_uart | Pointer to a UART instance. |
void uart_enable_interrupt | ( | Uart * | p_uart, |
uint32_t | ul_sources | ||
) |
Enable UART interrupts.
p_uart | Pointer to a UART instance. |
ul_sources | Interrupts to be enabled. |
void uart_enable_optical_interface | ( | Uart * | p_uart | ) |
void uart_enable_rx | ( | Uart * | p_uart | ) |
Enable UART receiver.
p_uart | Pointer to a UART instance. |
void uart_enable_tx | ( | Uart * | p_uart | ) |
Enable UART transmitter.
p_uart | Pointer to a UART instance. |
uint32_t uart_get_interrupt_mask | ( | Uart * | p_uart | ) |
Read UART interrupt mask.
p_uart | Pointer to a UART instance. |
Pdc* uart_get_pdc_base | ( | Uart * | p_uart | ) |
Get UART PDC base address.
p_uart | Pointer to a UART instance. |
uint32_t uart_get_status | ( | Uart * | p_uart | ) |
Get current status.
p_uart | Pointer to a UART instance. |
uint32_t uart_init | ( | Uart * | p_uart, |
const sam_uart_opt_t * | p_uart_opt | ||
) |
Configure UART with the specified parameters.
p_uart | Pointer to a UART instance. |
p_uart_opt | Pointer to sam_uart_opt_t instance. |
0 | Success. |
1 | Bad baud rate generator value. |
References UART_MCK_DIV, UART_MCK_DIV_MAX_FACTOR, sam_uart_opt::ul_baudrate, sam_uart_opt::ul_mck, and sam_uart_opt::ul_mode.
Referenced by reconfigure_console(), and usart_serial_init().
uint32_t uart_is_rx_buf_end | ( | Uart * | p_uart | ) |
Check if one receive buffer is filled.
p_uart | Pointer to a UART instance. |
1 | Receive is completed. |
0 | Receive is still pending. |
uint32_t uart_is_rx_buf_full | ( | Uart * | p_uart | ) |
Check if both receive buffers are full.
p_uart | Pointer to a UART instance. |
1 | Receive buffers are full. |
0 | Receive buffers are not full. |
uint32_t uart_is_rx_ready | ( | Uart * | p_uart | ) |
Check if Received data is ready.
Check if data has been received and loaded in UART_RHR.
p_uart | Pointer to a UART instance. |
1 | One data has been received. |
0 | No data has been received. |
Referenced by usart_serial_is_rx_ready().
uint32_t uart_is_tx_buf_empty | ( | Uart * | p_uart | ) |
Check if both transmit buffers are sent out.
p_uart | Pointer to a UART instance. |
1 | Transmit buffer is empty. |
0 | Transmit buffer is not empty. |
uint32_t uart_is_tx_buf_end | ( | Uart * | p_uart | ) |
Check if one transmit buffer is sent out.
p_uart | Pointer to a UART instance. |
1 | Transmit is completed. |
0 | Transmit is still pending. |
uint32_t uart_is_tx_empty | ( | Uart * | p_uart | ) |
Check if Transmit Hold Register is empty.
Check if the last data written in UART_THR has been loaded in TSR and the last data loaded in TSR has been transmitted.
p_uart | Pointer to a UART instance. |
1 | Transmitter is empty. |
0 | Transmitter is not empty. |
Referenced by init_chip(), test_wait_mode(), and user_change_clock().
uint32_t uart_is_tx_ready | ( | Uart * | p_uart | ) |
Check if Transmit is Ready.
Check if data has been loaded in UART_THR and is waiting to be loaded in the Transmit Shift Register (TSR).
p_uart | Pointer to a UART instance. |
1 | Data has been transmitted. |
0 | Transmit is not ready, data pending. |
uint32_t uart_read | ( | Uart * | p_uart, |
uint8_t * | puc_data | ||
) |
Read from UART Receive Holding Register.
Before reading user should check if rx is ready.
p_uart | Pointer to a UART instance. |
0 | Success. |
1 | I/O Failure, UART is not ready. |
Referenced by usart_serial_getchar().
void uart_reset | ( | Uart * | p_uart | ) |
Reset UART receiver and transmitter.
p_uart | Pointer to a UART instance. |
void uart_reset_rx | ( | Uart * | p_uart | ) |
Reset UART receiver.
p_uart | Pointer to a UART instance. |
void uart_reset_status | ( | Uart * | p_uart | ) |
Reset status bits.
p_uart | Pointer to a UART instance. |
void uart_reset_tx | ( | Uart * | p_uart | ) |
Reset UART transmitter.
p_uart | Pointer to a UART instance. |
void uart_set_clock_divisor | ( | Uart * | p_uart, |
uint16_t | us_divisor | ||
) |
Set UART clock divisor value.
p_uart | Pointer to a UART instance. |
us_divisor | Value to be set. |
void uart_set_sleepwalking | ( | Uart * | p_uart, |
uint8_t | ul_low_value, | ||
bool | cmpmode, | ||
bool | cmppar, | ||
uint8_t | ul_high_value | ||
) |
Set sleepwalking match mode.
p_uart | Pointer to a UART instance. |
ul_low_value | First comparison value for received character. |
ul_high_value | Second comparison value for received character. |
cmpmode | ture for start condition, false for flag only. |
cmppar | ture for parity check, false for no. |
References Assert.
void uart_set_write_protection | ( | Uart * | p_uart, |
bool | flag | ||
) |
Enables/Disables write protection mode.
p_uart | Pointer to a UART instance. |
flag | ture for enable, false for disable. |
uint32_t uart_write | ( | Uart * | p_uart, |
const uint8_t | uc_data | ||
) |
Write to UART Transmit Holding Register Before writing user should check if tx is ready (or empty).
p_uart | Pointer to a UART instance. |
data | Data to be sent. |
0 | Success. |
1 | I/O Failure, UART is not ready. |
Referenced by usart_serial_putchar().