Zephyr API Documentation 4.0.0-rc3
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
uart.h File Reference

Public APIs for UART drivers. More...

#include <errno.h>
#include <stddef.h>
#include <zephyr/device.h>
#include <zephyr/syscalls/uart.h>

Go to the source code of this file.

Data Structures

struct  uart_config
 UART controller configuration structure. More...
 
struct  uart_event_tx
 UART TX event data. More...
 
struct  uart_event_rx
 UART RX event data. More...
 
struct  uart_event_rx_buf
 UART RX buffer released event data. More...
 
struct  uart_event_rx_stop
 UART RX stopped data. More...
 
struct  uart_event
 Structure containing information about current event. More...
 
union  uart_event::uart_event_data
 Event data. More...
 

Typedefs

typedef void(* uart_irq_callback_user_data_t) (const struct device *dev, void *user_data)
 Define the application callback function signature for uart_irq_callback_user_data_set() function.
 
typedef void(* uart_irq_config_func_t) (const struct device *dev)
 For configuring IRQ on each individual UART device.
 
typedef void(* uart_callback_t) (const struct device *dev, struct uart_event *evt, void *user_data)
 Define the application callback function signature for uart_callback_set() function.
 

Enumerations

enum  uart_line_ctrl {
  UART_LINE_CTRL_BAUD_RATE = BIT(0) , UART_LINE_CTRL_RTS = BIT(1) , UART_LINE_CTRL_DTR = BIT(2) , UART_LINE_CTRL_DCD = BIT(3) ,
  UART_LINE_CTRL_DSR = BIT(4)
}
 Line control signals. More...
 
enum  uart_rx_stop_reason {
  UART_ERROR_OVERRUN = (1 << 0) , UART_ERROR_PARITY = (1 << 1) , UART_ERROR_FRAMING = (1 << 2) , UART_BREAK = (1 << 3) ,
  UART_ERROR_COLLISION = (1 << 4) , UART_ERROR_NOISE = (1 << 5)
}
 Reception stop reasons. More...
 
enum  uart_config_parity {
  UART_CFG_PARITY_NONE , UART_CFG_PARITY_ODD , UART_CFG_PARITY_EVEN , UART_CFG_PARITY_MARK ,
  UART_CFG_PARITY_SPACE
}
 Parity modes. More...
 
enum  uart_config_stop_bits { UART_CFG_STOP_BITS_0_5 , UART_CFG_STOP_BITS_1 , UART_CFG_STOP_BITS_1_5 , UART_CFG_STOP_BITS_2 }
 Number of stop bits. More...
 
enum  uart_config_data_bits {
  UART_CFG_DATA_BITS_5 , UART_CFG_DATA_BITS_6 , UART_CFG_DATA_BITS_7 , UART_CFG_DATA_BITS_8 ,
  UART_CFG_DATA_BITS_9
}
 Number of data bits. More...
 
enum  uart_config_flow_control { UART_CFG_FLOW_CTRL_NONE , UART_CFG_FLOW_CTRL_RTS_CTS , UART_CFG_FLOW_CTRL_DTR_DSR , UART_CFG_FLOW_CTRL_RS485 }
 Hardware flow control options. More...
 
enum  uart_event_type {
  UART_TX_DONE , UART_TX_ABORTED , UART_RX_RDY , UART_RX_BUF_REQUEST ,
  UART_RX_BUF_RELEASED , UART_RX_DISABLED , UART_RX_STOPPED
}
 Types of events passed to callback in UART_ASYNC_API. More...
 

Functions

int uart_err_check (const struct device *dev)
 Check whether an error was detected.
 
int uart_poll_in (const struct device *dev, unsigned char *p_char)
 Read a character from the device for input.
 
int uart_poll_in_u16 (const struct device *dev, uint16_t *p_u16)
 Read a 16-bit datum from the device for input.
 
void uart_poll_out (const struct device *dev, unsigned char out_char)
 Write a character to the device for output.
 
void uart_poll_out_u16 (const struct device *dev, uint16_t out_u16)
 Write a 16-bit datum to the device for output.
 
int uart_configure (const struct device *dev, const struct uart_config *cfg)
 Set UART configuration.
 
int uart_config_get (const struct device *dev, struct uart_config *cfg)
 Get UART configuration.
 
static int uart_fifo_fill (const struct device *dev, const uint8_t *tx_data, int size)
 Fill FIFO with data.
 
static int uart_fifo_fill_u16 (const struct device *dev, const uint16_t *tx_data, int size)
 Fill FIFO with wide data.
 
static int uart_fifo_read (const struct device *dev, uint8_t *rx_data, const int size)
 Read data from FIFO.
 
static int uart_fifo_read_u16 (const struct device *dev, uint16_t *rx_data, const int size)
 Read wide data from FIFO.
 
void uart_irq_tx_enable (const struct device *dev)
 Enable TX interrupt in IER.
 
void uart_irq_tx_disable (const struct device *dev)
 Disable TX interrupt in IER.
 
static int uart_irq_tx_ready (const struct device *dev)
 Check if UART TX buffer can accept bytes.
 
void uart_irq_rx_enable (const struct device *dev)
 Enable RX interrupt.
 
void uart_irq_rx_disable (const struct device *dev)
 Disable RX interrupt.
 
static int uart_irq_tx_complete (const struct device *dev)
 Check if UART TX block finished transmission.
 
static int uart_irq_rx_ready (const struct device *dev)
 Check if UART RX buffer has a received char.
 
void uart_irq_err_enable (const struct device *dev)
 Enable error interrupt.
 
void uart_irq_err_disable (const struct device *dev)
 Disable error interrupt.
 
int uart_irq_is_pending (const struct device *dev)
 Check if any IRQs is pending.
 
int uart_irq_update (const struct device *dev)
 Start processing interrupts in ISR.
 
static int uart_irq_callback_user_data_set (const struct device *dev, uart_irq_callback_user_data_t cb, void *user_data)
 Set the IRQ callback function pointer.
 
static int uart_irq_callback_set (const struct device *dev, uart_irq_callback_user_data_t cb)
 Set the IRQ callback function pointer (legacy).
 
static int uart_callback_set (const struct device *dev, uart_callback_t callback, void *user_data)
 Set event handler function.
 
int uart_tx (const struct device *dev, const uint8_t *buf, size_t len, int32_t timeout)
 Send given number of bytes from buffer through UART.
 
int uart_tx_u16 (const struct device *dev, const uint16_t *buf, size_t len, int32_t timeout)
 Send given number of datum from buffer through UART.
 
int uart_tx_abort (const struct device *dev)
 Abort current TX transmission.
 
int uart_rx_enable (const struct device *dev, uint8_t *buf, size_t len, int32_t timeout)
 Start receiving data through UART.
 
int uart_rx_enable_u16 (const struct device *dev, uint16_t *buf, size_t len, int32_t timeout)
 Start receiving wide data through UART.
 
static int uart_rx_buf_rsp (const struct device *dev, uint8_t *buf, size_t len)
 Provide receive buffer in response to UART_RX_BUF_REQUEST event.
 
static int uart_rx_buf_rsp_u16 (const struct device *dev, uint16_t *buf, size_t len)
 Provide wide data receive buffer in response to UART_RX_BUF_REQUEST event.
 
int uart_rx_disable (const struct device *dev)
 Disable RX.
 
int uart_line_ctrl_set (const struct device *dev, uint32_t ctrl, uint32_t val)
 Manipulate line control for UART.
 
int uart_line_ctrl_get (const struct device *dev, uint32_t ctrl, uint32_t *val)
 Retrieve line control for UART.
 
int uart_drv_cmd (const struct device *dev, uint32_t cmd, uint32_t p)
 Send extra command to driver.
 

Detailed Description

Public APIs for UART drivers.