13#ifndef ZEPHYR_INCLUDE_DRIVERS_UART_H_
14#define ZEPHYR_INCLUDE_DRIVERS_UART_H_
346#if defined(CONFIG_UART_INTERRUPT_DRIVEN) || defined(CONFIG_UART_ASYNC_API)
354#ifdef CONFIG_UART_ASYNC_API
383#ifdef CONFIG_UART_INTERRUPT_DRIVEN
433#ifdef CONFIG_UART_LINE_CTRL
440#ifdef CONFIG_UART_DRV_CMD
461#ifdef CONFIG_UART_ASYNC_API
491static inline int z_impl_uart_tx(
const struct device *dev,
const uint8_t *buf,
495#ifdef CONFIG_UART_ASYNC_API
519static inline int z_impl_uart_tx_abort(
const struct device *dev)
521#ifdef CONFIG_UART_ASYNC_API
556static inline int z_impl_uart_rx_enable(
const struct device *dev,
560#ifdef CONFIG_UART_ASYNC_API
594#ifdef CONFIG_UART_ASYNC_API
621static inline int z_impl_uart_rx_disable(
const struct device *dev)
623#ifdef CONFIG_UART_ASYNC_API
643static inline int z_impl_uart_err_check(
const struct device *dev)
669static inline int z_impl_uart_poll_in(
const struct device *dev,
670 unsigned char *p_char)
675 return api->
poll_in(dev, p_char);
692 unsigned char out_char);
694static inline void z_impl_uart_poll_out(
const struct device *dev,
695 unsigned char out_char)
719static inline int z_impl_uart_configure(
const struct device *dev,
746static inline int z_impl_uart_config_get(
const struct device *dev,
782#ifdef CONFIG_UART_INTERRUPT_DRIVEN
787 return api->
fifo_fill(dev, tx_data, size);
819#ifdef CONFIG_UART_INTERRUPT_DRIVEN
824 return api->
fifo_read(dev, rx_data, size);
840static inline void z_impl_uart_irq_tx_enable(
const struct device *dev)
842#ifdef CONFIG_UART_INTERRUPT_DRIVEN
860static inline void z_impl_uart_irq_tx_disable(
const struct device *dev)
862#ifdef CONFIG_UART_INTERRUPT_DRIVEN
889#ifdef CONFIG_UART_INTERRUPT_DRIVEN
910static inline void z_impl_uart_irq_rx_enable(
const struct device *dev)
912#ifdef CONFIG_UART_INTERRUPT_DRIVEN
931static inline void z_impl_uart_irq_rx_disable(
const struct device *dev)
933#ifdef CONFIG_UART_INTERRUPT_DRIVEN
963#ifdef CONFIG_UART_INTERRUPT_DRIVEN
998#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1019static inline void z_impl_uart_irq_err_enable(
const struct device *dev)
1021#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1041static inline void z_impl_uart_irq_err_disable(
const struct device *dev)
1043#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1063static inline int z_impl_uart_irq_is_pending(
const struct device *dev)
1065#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1102static inline int z_impl_uart_irq_update(
const struct device *dev)
1104#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1133#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1174static inline int z_impl_uart_line_ctrl_set(
const struct device *dev,
1177#ifdef CONFIG_UART_LINE_CTRL
1181 if (api->line_ctrl_set == NULL) {
1184 return api->line_ctrl_set(dev, ctrl, val);
1203static inline int z_impl_uart_line_ctrl_get(
const struct device *dev,
1206#ifdef CONFIG_UART_LINE_CTRL
1210 if (api->line_ctrl_get == NULL) {
1213 return api->line_ctrl_get(dev, ctrl, val);
1237#ifdef CONFIG_UART_DRV_CMD
1258#include <syscalls/uart.h>
ZTEST_BMEM int timeout
Definition: main.c:31
void
Definition: eswifi_shell.c:15
static void cmd(uint32_t command)
Execute a display list command by co-processor engine.
Definition: ft8xx_reference_api.h:153
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition: util_macro.h:44
#define ENOSYS
Definition: errno.h:83
#define ENOTSUP
Definition: errno.h:115
uart_line_ctrl
Line control signals.
Definition: uart.h:33
void uart_poll_out(const struct device *dev, unsigned char out_char)
Output a character in polled mode.
int uart_irq_is_pending(const struct device *dev)
Check if any IRQs is pending.
int uart_err_check(const struct device *dev)
Check whether an error was detected.
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.
Definition: uart.h:591
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.
Definition: uart.h:316
void uart_irq_rx_enable(const struct device *dev)
Enable RX interrupt.
static int uart_irq_tx_ready(const struct device *dev)
Check if UART TX buffer can accept a new char.
Definition: uart.h:887
void(* uart_irq_config_func_t)(const struct device *dev)
For configuring IRQ on each individual UART device.
Definition: uart.h:327
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.
Definition: uart.h:249
void uart_irq_err_enable(const struct device *dev)
Enable error interrupt.
int uart_config_get(const struct device *dev, struct uart_config *cfg)
Get UART configuration.
uart_config_flow_control
Hardware flow control options.
Definition: uart.h:302
int uart_rx_enable(const struct device *dev, uint8_t *buf, size_t len, int32_t timeout)
Start receiving data through UART.
static int uart_irq_tx_complete(const struct device *dev)
Check if UART TX block finished transmission.
Definition: uart.h:961
void uart_irq_tx_enable(const struct device *dev)
Enable TX interrupt in IER.
int uart_configure(const struct device *dev, const struct uart_config *cfg)
Set UART configuration.
void uart_irq_rx_disable(const struct device *dev)
Disable RX interrupt.
int uart_drv_cmd(const struct device *dev, uint32_t cmd, uint32_t p)
Send extra command to driver.
int uart_tx_abort(const struct device *dev)
Abort current TX transmission.
void uart_irq_err_disable(const struct device *dev)
Disable error interrupt.
int uart_line_ctrl_set(const struct device *dev, uint32_t ctrl, uint32_t val)
Manipulate line control for UART.
static int uart_fifo_read(const struct device *dev, uint8_t *rx_data, const int size)
Read data from FIFO.
Definition: uart.h:816
uart_config_parity
Parity modes.
Definition: uart.h:270
uart_config_data_bits
Number of data bits.
Definition: uart.h:287
int uart_irq_update(const struct device *dev)
Start processing interrupts in ISR.
static void uart_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb)
Set the IRQ callback function pointer (legacy).
Definition: uart.h:1154
static int uart_irq_rx_ready(const struct device *dev)
Check if UART RX buffer has a received char.
Definition: uart.h:996
static int uart_callback_set(const struct device *dev, uart_callback_t callback, void *user_data)
Set event handler function.
Definition: uart.h:457
uart_rx_stop_reason
Reception stop reasons.
Definition: uart.h:155
int uart_poll_in(const struct device *dev, unsigned char *p_char)
Poll the device for input.
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.
Definition: uart.h:1129
uart_event_type
Types of events passed to callback in UART_ASYNC_API.
Definition: uart.h:93
void uart_irq_tx_disable(const struct device *dev)
Disable TX interrupt in IER.
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.
uart_config_stop_bits
Number of stop bits.
Definition: uart.h:279
int uart_rx_disable(const struct device *dev)
Disable RX.
int uart_line_ctrl_get(const struct device *dev, uint32_t ctrl, uint32_t *val)
Retrieve line control for UART.
static int uart_fifo_fill(const struct device *dev, const uint8_t *tx_data, int size)
Fill FIFO with data.
Definition: uart.h:778
@ UART_LINE_CTRL_DTR
Definition: uart.h:36
@ UART_LINE_CTRL_RTS
Definition: uart.h:35
@ UART_LINE_CTRL_BAUD_RATE
Definition: uart.h:34
@ UART_LINE_CTRL_DCD
Definition: uart.h:37
@ UART_LINE_CTRL_DSR
Definition: uart.h:38
@ UART_CFG_FLOW_CTRL_DTR_DSR
Definition: uart.h:305
@ UART_CFG_FLOW_CTRL_NONE
Definition: uart.h:303
@ UART_CFG_FLOW_CTRL_RTS_CTS
Definition: uart.h:304
@ UART_CFG_PARITY_MARK
Definition: uart.h:274
@ UART_CFG_PARITY_NONE
Definition: uart.h:271
@ UART_CFG_PARITY_ODD
Definition: uart.h:272
@ UART_CFG_PARITY_SPACE
Definition: uart.h:275
@ UART_CFG_PARITY_EVEN
Definition: uart.h:273
@ UART_CFG_DATA_BITS_5
Definition: uart.h:288
@ UART_CFG_DATA_BITS_8
Definition: uart.h:291
@ UART_CFG_DATA_BITS_7
Definition: uart.h:290
@ UART_CFG_DATA_BITS_6
Definition: uart.h:289
@ UART_CFG_DATA_BITS_9
Definition: uart.h:292
@ UART_ERROR_OVERRUN
Overrun error.
Definition: uart.h:157
@ UART_BREAK
Break interrupt.
Definition: uart.h:169
@ UART_ERROR_PARITY
Parity error.
Definition: uart.h:159
@ UART_ERROR_COLLISION
Collision error.
Definition: uart.h:179
@ UART_ERROR_FRAMING
Framing error.
Definition: uart.h:161
@ UART_RX_STOPPED
RX has stopped due to external event.
Definition: uart.h:145
@ UART_TX_ABORTED
Transmitting aborted due to timeout or uart_tx_abort call.
Definition: uart.h:103
@ UART_RX_BUF_REQUEST
Driver requests next buffer for continuous reception.
Definition: uart.h:127
@ UART_TX_DONE
Whole TX buffer was transmitted.
Definition: uart.h:95
@ UART_RX_RDY
Received data is ready for processing.
Definition: uart.h:115
@ UART_RX_DISABLED
RX has been disabled and can be reenabled.
Definition: uart.h:139
@ UART_RX_BUF_RELEASED
Buffer is no longer used by UART driver.
Definition: uart.h:131
@ UART_CFG_STOP_BITS_1_5
Definition: uart.h:282
@ UART_CFG_STOP_BITS_0_5
Definition: uart.h:280
@ UART_CFG_STOP_BITS_1
Definition: uart.h:281
@ UART_CFG_STOP_BITS_2
Definition: uart.h:283
struct k_pipe p
Definition: kobject.c:1311
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__INT32_TYPE__ int32_t
Definition: stdint.h:44
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
const void * api
Definition: device.h:373
UART controller configuration structure.
Definition: uart.h:261
uint8_t stop_bits
Definition: uart.h:264
uint8_t parity
Definition: uart.h:263
uint8_t data_bits
Definition: uart.h:265
uint32_t baudrate
Definition: uart.h:262
uint8_t flow_ctrl
Definition: uart.h:266
UART device configuration.
Definition: uart.h:337
uint32_t sys_clk_freq
Definition: uart.h:344
uint32_t port
Definition: uart.h:339
uart_irq_config_func_t irq_config_func
Definition: uart.h:347
uint32_t regs
Definition: uart.h:341
uint8_t * base
Definition: uart.h:340
Driver API structure.
Definition: uart.h:352
void(* irq_err_disable)(const struct device *dev)
Definition: uart.h:418
int(* irq_is_pending)(const struct device *dev)
Definition: uart.h:421
int(* drv_cmd)(const struct device *dev, uint32_t cmd, uint32_t p)
Definition: uart.h:441
int(* fifo_read)(const struct device *dev, uint8_t *rx_data, const int size)
Definition: uart.h:390
int(* poll_in)(const struct device *dev, unsigned char *p_char)
Definition: uart.h:372
void(* irq_tx_enable)(const struct device *dev)
Definition: uart.h:394
void(* poll_out)(const struct device *dev, unsigned char out_char)
Definition: uart.h:373
int(* err_check)(const struct device *dev)
Definition: uart.h:376
int(* irq_tx_ready)(const struct device *dev)
Definition: uart.h:400
int(* irq_rx_ready)(const struct device *dev)
Definition: uart.h:412
int(* irq_update)(const struct device *dev)
Definition: uart.h:424
void(* irq_tx_disable)(const struct device *dev)
Definition: uart.h:397
int(* fifo_fill)(const struct device *dev, const uint8_t *tx_data, int len)
Definition: uart.h:386
int(* irq_tx_complete)(const struct device *dev)
Definition: uart.h:409
void(* irq_rx_enable)(const struct device *dev)
Definition: uart.h:403
int(* tx_abort)(const struct device *dev)
Definition: uart.h:362
int(* rx_disable)(const struct device *dev)
Definition: uart.h:367
void(* irq_callback_set)(const struct device *dev, uart_irq_callback_user_data_t cb, void *user_data)
Definition: uart.h:427
void(* irq_rx_disable)(const struct device *dev)
Definition: uart.h:406
int(* rx_enable)(const struct device *dev, uint8_t *buf, size_t len, int32_t timeout)
Definition: uart.h:364
int(* tx)(const struct device *dev, const uint8_t *buf, size_t len, int32_t timeout)
Definition: uart.h:360
int(* rx_buf_rsp)(const struct device *dev, uint8_t *buf, size_t len)
Definition: uart.h:366
int(* config_get)(const struct device *dev, struct uart_config *cfg)
Definition: uart.h:381
void(* irq_err_enable)(const struct device *dev)
Definition: uart.h:415
int(* configure)(const struct device *dev, const struct uart_config *cfg)
Definition: uart.h:379
int(* callback_set)(const struct device *dev, uart_callback_t callback, void *user_data)
Definition: uart.h:356
UART RX buffer released event data.
Definition: uart.h:206
uint8_t * buf
Definition: uart.h:208
UART RX stopped data.
Definition: uart.h:212
struct uart_event_rx data
Last received data.
Definition: uart.h:216
enum uart_rx_stop_reason reason
Reason why receiving stopped.
Definition: uart.h:214
UART RX event data.
Definition: uart.h:196
uint8_t * buf
Pointer to current buffer.
Definition: uart.h:198
size_t len
Number of new bytes received.
Definition: uart.h:202
size_t offset
Currently received data offset in bytes.
Definition: uart.h:200
UART TX event data.
Definition: uart.h:183
const uint8_t * buf
Pointer to current buffer.
Definition: uart.h:185
size_t len
Number of bytes sent.
Definition: uart.h:187
Structure containing information about current event.
Definition: uart.h:220
union uart_event::uart_event_data data
enum uart_event_type type
Type of event.
Definition: uart.h:222
static const intptr_t user_data[5]
Definition: main.c:590
Event data.
Definition: uart.h:224
struct uart_event_tx tx
uart_event_type::UART_TX_DONE and uart_event_type::UART_TX_ABORTED events data.
Definition: uart.h:228
struct uart_event_rx_stop rx_stop
uart_event_type::UART_RX_STOPPED event data.
Definition: uart.h:236
struct uart_event_rx_buf rx_buf
uart_event_type::UART_RX_BUF_RELEASED event data.
Definition: uart.h:234
struct uart_event_rx rx
uart_event_type::UART_RX_RDY event data.
Definition: uart.h:230