Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
uart.h File Reference

Public APIs for UART drivers. More...

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

Go to the source code of this file.

Data Structures

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...
 
struct  uart_config
 UART controller configuration structure. More...
 
struct  uart_device_config
 UART device configuration. More...
 
struct  uart_driver_api
 Driver API structure. More...
 

Typedefs

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. More...
 
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. More...
 
typedef void(* uart_irq_config_func_t) (const struct device *dev)
 For configuring IRQ on each individual UART device. More...
 

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_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...
 
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)
}
 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 }
 Hardware flow control options. More...
 

Functions

static int uart_callback_set (const struct device *dev, uart_callback_t callback, void *user_data)
 Set event handler function. More...
 
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. More...
 
int uart_tx_abort (const struct device *dev)
 Abort current TX transmission. More...
 
int uart_rx_enable (const struct device *dev, uint8_t *buf, size_t len, int32_t timeout)
 Start receiving data through UART. More...
 
static int uart_rx_buf_rsp (const struct device *dev, uint8_t *buf, size_t len)
 Provide receive buffer in response to uart_event_type::UART_RX_BUF_REQUEST event. More...
 
int uart_rx_disable (const struct device *dev)
 Disable RX. More...
 
int uart_err_check (const struct device *dev)
 Check whether an error was detected. More...
 
int uart_poll_in (const struct device *dev, unsigned char *p_char)
 Poll the device for input. More...
 
void uart_poll_out (const struct device *dev, unsigned char out_char)
 Output a character in polled mode. More...
 
int uart_configure (const struct device *dev, const struct uart_config *cfg)
 Set UART configuration. More...
 
int uart_config_get (const struct device *dev, struct uart_config *cfg)
 Get UART configuration. More...
 
static int uart_fifo_fill (const struct device *dev, const uint8_t *tx_data, int size)
 Fill FIFO with data. More...
 
static int uart_fifo_read (const struct device *dev, uint8_t *rx_data, const int size)
 Read data from FIFO. More...
 
void uart_irq_tx_enable (const struct device *dev)
 Enable TX interrupt in IER. More...
 
void uart_irq_tx_disable (const struct device *dev)
 Disable TX interrupt in IER. More...
 
static int uart_irq_tx_ready (const struct device *dev)
 Check if UART TX buffer can accept a new char. More...
 
void uart_irq_rx_enable (const struct device *dev)
 Enable RX interrupt. More...
 
void uart_irq_rx_disable (const struct device *dev)
 Disable RX interrupt. More...
 
static int uart_irq_tx_complete (const struct device *dev)
 Check if UART TX block finished transmission. More...
 
static int uart_irq_rx_ready (const struct device *dev)
 Check if UART RX buffer has a received char. More...
 
void uart_irq_err_enable (const struct device *dev)
 Enable error interrupt. More...
 
void uart_irq_err_disable (const struct device *dev)
 Disable error interrupt. More...
 
int uart_irq_is_pending (const struct device *dev)
 Check if any IRQs is pending. More...
 
int uart_irq_update (const struct device *dev)
 Start processing interrupts in ISR. More...
 
static void 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. More...
 
static void uart_irq_callback_set (const struct device *dev, uart_irq_callback_user_data_t cb)
 Set the IRQ callback function pointer (legacy). More...
 
int uart_line_ctrl_set (const struct device *dev, uint32_t ctrl, uint32_t val)
 Manipulate line control for UART. More...
 
int uart_line_ctrl_get (const struct device *dev, uint32_t ctrl, uint32_t *val)
 Retrieve line control for UART. More...
 
int uart_drv_cmd (const struct device *dev, uint32_t cmd, uint32_t p)
 Send extra command to driver. More...
 

Detailed Description

Public APIs for UART drivers.