Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
|
UART Interface . More...
Topics | |
Async UART API | |
Interrupt-driven UART API | |
Polling UART API | |
Data Structures | |
struct | uart_config |
UART controller configuration structure. More... | |
Functions | |
int | uart_err_check (const struct device *dev) |
Check whether an error was detected. | |
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. | |
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. | |
UART Interface .
#include <zephyr/drivers/uart.h>
Number of data bits.
Enumerator | |
---|---|
UART_CFG_DATA_BITS_5 | 5 data bits |
UART_CFG_DATA_BITS_6 | 6 data bits |
UART_CFG_DATA_BITS_7 | 7 data bits |
UART_CFG_DATA_BITS_8 | 8 data bits |
UART_CFG_DATA_BITS_9 | 9 data bits |
#include <zephyr/drivers/uart.h>
Hardware flow control options.
With flow control set to none, any operations related to flow control signals can be managed by user with uart_line_ctrl functions. In other cases, flow control is managed by hardware/driver.
Enumerator | |
---|---|
UART_CFG_FLOW_CTRL_NONE | No flow control. |
UART_CFG_FLOW_CTRL_RTS_CTS | RTS/CTS flow control. |
UART_CFG_FLOW_CTRL_DTR_DSR | DTR/DSR flow control. |
UART_CFG_FLOW_CTRL_RS485 | RS485 flow control. |
enum uart_config_parity |
#include <zephyr/drivers/uart.h>
Parity modes.
Enumerator | |
---|---|
UART_CFG_PARITY_NONE | No parity. |
UART_CFG_PARITY_ODD | Odd parity. |
UART_CFG_PARITY_EVEN | Even parity. |
UART_CFG_PARITY_MARK | Mark parity. |
UART_CFG_PARITY_SPACE | Space parity. |
#include <zephyr/drivers/uart.h>
Number of stop bits.
Enumerator | |
---|---|
UART_CFG_STOP_BITS_0_5 | 0.5 stop bit |
UART_CFG_STOP_BITS_1 | 1 stop bit |
UART_CFG_STOP_BITS_1_5 | 1.5 stop bits |
UART_CFG_STOP_BITS_2 | 2 stop bits |
enum uart_line_ctrl |
#include <zephyr/drivers/uart.h>
Line control signals.
enum uart_rx_stop_reason |
#include <zephyr/drivers/uart.h>
Reception stop reasons.
Values that correspond to events or errors responsible for stopping receiving.
int uart_config_get | ( | const struct device * | dev, |
struct uart_config * | cfg ) |
#include <zephyr/drivers/uart.h>
Get UART configuration.
Stores current UART configuration to *cfg, can be used to retrieve initial configuration after device was initialized using data from DTS.
dev | UART device instance. |
cfg | UART configuration structure. |
0 | If successful. |
-errno | Negative errno code in case of failure. |
-ENOSYS | If driver does not support getting current configuration. |
-ENOTSUP | If API is not enabled. |
int uart_configure | ( | const struct device * | dev, |
const struct uart_config * | cfg ) |
#include <zephyr/drivers/uart.h>
Set UART configuration.
Sets UART configuration using data from *cfg.
dev | UART device instance. |
cfg | UART configuration structure. |
0 | If successful. |
-errno | Negative errno code in case of failure. |
-ENOSYS | If configuration is not supported by device or driver does not support setting configuration in runtime. |
-ENOTSUP | If API is not enabled. |
#include <zephyr/drivers/uart.h>
Send extra command to driver.
Implementation and accepted commands are driver specific. Refer to the drivers for more information.
dev | UART device instance. |
cmd | Command to driver. |
p | Parameter to the command. |
0 | If successful. |
-ENOSYS | If this function is not implemented. |
-ENOTSUP | If API is not enabled. |
-errno | Other negative errno value in case of failure. |
int uart_err_check | ( | const struct device * | dev | ) |
#include <zephyr/drivers/uart.h>
Check whether an error was detected.
dev | UART device instance. |
0 | If no error was detected. |
err | Error flags as defined in uart_rx_stop_reason |
-ENOSYS | If not implemented. |
#include <zephyr/drivers/uart.h>
Retrieve line control for UART.
dev | UART device instance. |
ctrl | The line control to retrieve (see enum uart_line_ctrl). |
val | Pointer to variable where to store the line control value. |
0 | If successful. |
-ENOSYS | If this function is not implemented. |
-ENOTSUP | If API is not enabled. |
-errno | Other negative errno value in case of failure. |
#include <zephyr/drivers/uart.h>
Manipulate line control for UART.
dev | UART device instance. |
ctrl | The line control to manipulate (see enum uart_line_ctrl). |
val | Value to set to the line control. |
0 | If successful. |
-ENOSYS | If this function is not implemented. |
-ENOTSUP | If API is not enabled. |
-errno | Other negative errno value in case of failure. |