# uart\_if.h - [Overview](#section1321589303165629) - [Summary](#section788592983165629) - [Data Structures](#nested-classes) - [Macros](#define-members) - [Enumerations](#enum-members) - [Functions](#func-members) - [Details](#section2141832930165629) - [Macro Definition](#section353483346165629) - [UART\_ATTR\_CTS\_DIS](#a326c98b1572b40a83a0e4635eb856e5e) - [UART\_ATTR\_CTS\_EN](#a097c9cebfaf73088fc9e8bea12bfe12f) - [UART\_ATTR\_DATABIT\_5](#af7add98615bfa0f6b9fa612aefcb1a86) - [UART\_ATTR\_DATABIT\_6](#a0170d90e903308157615a9d492522a45) - [UART\_ATTR\_DATABIT\_7](#a1a0f284bb3f73eb5f410a3b800f05c3d) - [UART\_ATTR\_DATABIT\_8](#af5e815055116901ca2031dfa07aab973) - [UART\_ATTR\_PARITY\_EVEN](#a9f3c0d0f62f5d9320567948fd4d92be2) - [UART\_ATTR\_PARITY\_MARK](#a22c4b8c1eb660d64564900a2088bd1ee) - [UART\_ATTR\_PARITY\_NONE](#a4babcc869fd207988d961ccca101abd2) - [UART\_ATTR\_PARITY\_ODD](#a5fee103697a67af905c21a2107141ceb) - [UART\_ATTR\_PARITY\_SPACE](#a1817d247706383e20fea3699a95a466a) - [UART\_ATTR\_RTS\_DIS](#a0266381d78b0452a252e195ff9515906) - [UART\_ATTR\_RTS\_EN](#a7cfdcad6fe75be1ccb06bed6d94da7e6) - [UART\_ATTR\_RX\_FIFO\_DIS](#acb395fb111f746ecf37ab86d255024a4) - [UART\_ATTR\_RX\_FIFO\_EN](#a1e1fcc1dbf4cfab102ea77fbae2b9bb5) - [UART\_ATTR\_STOPBIT\_1](#a985cd0b852a617f1265315030bc1cf8c) - [UART\_ATTR\_STOPBIT\_1P5](#a2ebde6313789cc5d787c274240f64deb) - [UART\_ATTR\_STOPBIT\_2](#a97875399f1914c0b66c5c6cea59afe38) - [UART\_ATTR\_TX\_FIFO\_DIS](#a220e22bdcc6c4bc4de7c9896a22b0ae2) - [UART\_ATTR\_TX\_FIFO\_EN](#aa434b054edcab341947c1c4dd71972eb) ## **Overview** **Related Modules:** [UART](UART.md) **Description:** Declares standard UART APIs. **Since:** 1.0 ## **Summary** ## Data Structures

Data Structure Name

Description

UartAttribute

Defines basic attributes of the UART port.

## Macros

Macro Name and Value

Description

UART_ATTR_DATABIT_8 0

Indicates the UART word length, which is 8 data bits per frame.

UART_ATTR_DATABIT_7 1

Indicates the UART word length, which is 7 data bits per frame.

UART_ATTR_DATABIT_6 2

Indicates the UART word length, which is 6 data bits per frame.

UART_ATTR_DATABIT_5 3

Indicates the UART word length, which is 5 data bits per frame.

UART_ATTR_PARITY_NONE 0

Indicates that the UART device has no parity bit.

UART_ATTR_PARITY_ODD 1

Indicates that the UART device has an odd parity bit.

UART_ATTR_PARITY_EVEN 2

Indicates that the UART device has an even parity bit.

UART_ATTR_PARITY_MARK 3

Indicates that the parity bit is 1.

UART_ATTR_PARITY_SPACE 4

Indicates that the parity bit is 0.

UART_ATTR_STOPBIT_1 0

Indicates that the UART device has 1 stop bit.

UART_ATTR_STOPBIT_1P5 1

Indicates that the UART device has 1.5 stop bits.

UART_ATTR_STOPBIT_2 2

Indicates that the UART device has 2 stop bits.

UART_ATTR_RTS_DIS 0

Indicates that Request To Send (RTS) is disabled for the UART device.

UART_ATTR_RTS_EN 1

Indicates that RTS is enabled for the UART device.

UART_ATTR_CTS_DIS 0

Indicates that Clear To Send (CTS) is disabled for the UART device.

UART_ATTR_CTS_EN 1

Indicates that CTS is enabled for the UART device.

UART_ATTR_RX_FIFO_DIS 0

Indicates that First In First Out (FIFO) is disabled for the receiving UART.

UART_ATTR_RX_FIFO_EN 1

Indicates that FIFO is enabled for the receiving UART.

UART_ATTR_TX_FIFO_DIS 0

Indicates that FIFO is disabled for the transmitting UART.

UART_ATTR_TX_FIFO_EN 1

Indicates that FIFO is enabled for the transmitting UART.

## Enumerations

Enumeration Name

Description

UartTransMode { UART_MODE_RD_BLOCK = 0, UART_MODE_RD_NONBLOCK, UART_MODE_DMA_RX_EN, UART_MODE_DMA_RX_DIS, UART_MODE_DMA_TX_EN, UART_MODE_DMA_TX_DIS }

Enumerates UART transmission modes.

## Functions

Function

Description

UartOpen (uint32_t port)

DevHandle

Obtains the UART device handle.

UartClose (DevHandle handle)

void

Releases the UART device handle.

UartRead (DevHandle handle, uint8_t *data, uint32_t size)

int32_t

Reads data of a specified size from a UART device.

UartWrite (DevHandle handle, uint8_t *data, uint32_t size)

int32_t

Writes data of a specified size into a UART device.

UartGetBaud (DevHandle handle, uint32_t *baudRate)

int32_t

Obtains the baud rate of the UART device.

UartSetBaud (DevHandle handle, uint32_t baudRate)

int32_t

Sets the baud rate for the UART device.

UartGetAttribute (DevHandle handle, struct UartAttribute *attribute)

int32_t

Obtains the UART attribute.

UartSetAttribute (DevHandle handle, struct UartAttribute *attribute)

int32_t

Sets the UART attribute.

UartSetTransMode (DevHandle handle, enum UartTransMode mode)

int32_t

Sets the UART transmission mode.

## **Details** ## **Macro Definition ** ## UART\_ATTR\_CTS\_DIS ``` #define UART_ATTR_CTS_DIS 0 ``` **Description:** Indicates that Clear To Send \(CTS\) is disabled for the UART device. ## UART\_ATTR\_CTS\_EN ``` #define UART_ATTR_CTS_EN 1 ``` **Description:** Indicates that CTS is enabled for the UART device. ## UART\_ATTR\_DATABIT\_5 ``` #define UART_ATTR_DATABIT_5 3 ``` **Description:** Indicates the UART word length, which is 5 data bits per frame. ## UART\_ATTR\_DATABIT\_6 ``` #define UART_ATTR_DATABIT_6 2 ``` **Description:** Indicates the UART word length, which is 6 data bits per frame. ## UART\_ATTR\_DATABIT\_7 ``` #define UART_ATTR_DATABIT_7 1 ``` **Description:** Indicates the UART word length, which is 7 data bits per frame. ## UART\_ATTR\_DATABIT\_8 ``` #define UART_ATTR_DATABIT_8 0 ``` **Description:** Indicates the UART word length, which is 8 data bits per frame. ## UART\_ATTR\_PARITY\_EVEN ``` #define UART_ATTR_PARITY_EVEN 2 ``` **Description:** Indicates that the UART device has an even parity bit. ## UART\_ATTR\_PARITY\_MARK ``` #define UART_ATTR_PARITY_MARK 3 ``` **Description:** Indicates that the parity bit is 1. ## UART\_ATTR\_PARITY\_NONE ``` #define UART_ATTR_PARITY_NONE 0 ``` **Description:** Indicates that the UART device has no parity bit. ## UART\_ATTR\_PARITY\_ODD ``` #define UART_ATTR_PARITY_ODD 1 ``` **Description:** Indicates that the UART device has an odd parity bit. ## UART\_ATTR\_PARITY\_SPACE ``` #define UART_ATTR_PARITY_SPACE 4 ``` **Description:** Indicates that the parity bit is 0. ## UART\_ATTR\_RTS\_DIS ``` #define UART_ATTR_RTS_DIS 0 ``` **Description:** Indicates that [Request](Request.md) To Send \(RTS\) is disabled for the UART device. ## UART\_ATTR\_RTS\_EN ``` #define UART_ATTR_RTS_EN 1 ``` **Description:** Indicates that RTS is enabled for the UART device. ## UART\_ATTR\_RX\_FIFO\_DIS ``` #define UART_ATTR_RX_FIFO_DIS 0 ``` **Description:** Indicates that First In First Out \(FIFO\) is disabled for the receiving UART. ## UART\_ATTR\_RX\_FIFO\_EN ``` #define UART_ATTR_RX_FIFO_EN 1 ``` **Description:** Indicates that FIFO is enabled for the receiving UART. ## UART\_ATTR\_STOPBIT\_1 ``` #define UART_ATTR_STOPBIT_1 0 ``` **Description:** Indicates that the UART device has 1 stop bit. ## UART\_ATTR\_STOPBIT\_1P5 ``` #define UART_ATTR_STOPBIT_1P5 1 ``` **Description:** Indicates that the UART device has 1.5 stop bits. ## UART\_ATTR\_STOPBIT\_2 ``` #define UART_ATTR_STOPBIT_2 2 ``` **Description:** Indicates that the UART device has 2 stop bits. ## UART\_ATTR\_TX\_FIFO\_DIS ``` #define UART_ATTR_TX_FIFO_DIS 0 ``` **Description:** Indicates that FIFO is disabled for the transmitting UART. ## UART\_ATTR\_TX\_FIFO\_EN ``` #define UART_ATTR_TX_FIFO_EN 1 ``` **Description:** Indicates that FIFO is enabled for the transmitting UART.