uart_if.h

Overview

Related Modules:

UART

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 Name

Description

UartOpen (uint32_t port)

struct DevHandle  

Obtains the UART device handle.

UartClose (struct DevHandle handle)

void 

Releases the UART device handle.

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

int32_t 

Reads data of a specified size from a UART device.

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

int32_t 

Writes data of a specified size into a UART device.

UartGetBaud (struct DevHandle handle, uint32_t baudRate)

int32_t 

Obtains the baud rate of the UART device.

UartSetBaud (struct DevHandle handle, uint32_t baudRate)

int32_t 

Sets the baud rate for the UART device.

UartGetAttribute (struct DevHandle handle, struct UartAttribute attribute)

int32_t 

Obtains the UART attribute.

UartSetAttribute (struct DevHandle handle, struct UartAttribute attribute)

int32_t 

Sets the UART attribute.

UartSetTransMode (struct DevHandle handle, enum UartTransMode mode)

int32_t 

Sets the UART transmission mode.

Details

Macro Definition Documentation

UART_ATTR_CTS_DIS

  1. #define UART_ATTR_CTS_DIS 0

Description:

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

UART_ATTR_CTS_EN

  1. #define UART_ATTR_CTS_EN 1

Description:

Indicates that CTS is enabled for the UART device.

UART_ATTR_DATABIT_5

  1. #define UART_ATTR_DATABIT_5 3

Description:

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

UART_ATTR_DATABIT_6

  1. #define UART_ATTR_DATABIT_6 2

Description:

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

UART_ATTR_DATABIT_7

  1. #define UART_ATTR_DATABIT_7 1

Description:

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

UART_ATTR_DATABIT_8

  1. #define UART_ATTR_DATABIT_8 0

Description:

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

UART_ATTR_PARITY_EVEN

  1. #define UART_ATTR_PARITY_EVEN 2

Description:

Indicates that the UART device has an even parity bit.

UART_ATTR_PARITY_MARK

  1. #define UART_ATTR_PARITY_MARK 3

Description:

Indicates that the parity bit is 1.

UART_ATTR_PARITY_NONE

  1. #define UART_ATTR_PARITY_NONE 0

Description:

Indicates that the UART device has no parity bit.

UART_ATTR_PARITY_ODD

  1. #define UART_ATTR_PARITY_ODD 1

Description:

Indicates that the UART device has an odd parity bit.

UART_ATTR_PARITY_SPACE

  1. #define UART_ATTR_PARITY_SPACE 4

Description:

Indicates that the parity bit is 0.

UART_ATTR_RTS_DIS

  1. #define UART_ATTR_RTS_DIS 0

Description:

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

UART_ATTR_RTS_EN

  1. #define UART_ATTR_RTS_EN 1

Description:

Indicates that RTS is enabled for the UART device.

UART_ATTR_RX_FIFO_DIS

  1. #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

  1. #define UART_ATTR_RX_FIFO_EN 1

Description:

Indicates that FIFO is enabled for the receiving UART.

UART_ATTR_STOPBIT_1

  1. #define UART_ATTR_STOPBIT_1 0

Description:

Indicates that the UART device has 1 stop bit.

UART_ATTR_STOPBIT_1P5

  1. #define UART_ATTR_STOPBIT_1P5 1

Description:

Indicates that the UART device has 1.5 stop bits.

UART_ATTR_STOPBIT_2

  1. #define UART_ATTR_STOPBIT_2 2

Description:

Indicates that the UART device has 2 stop bits.

UART_ATTR_TX_FIFO_DIS

  1. #define UART_ATTR_TX_FIFO_DIS 0

Description:

Indicates that FIFO is disabled for the transmitting UART.

UART_ATTR_TX_FIFO_EN

  1. #define UART_ATTR_TX_FIFO_EN 1

Description:

Indicates that FIFO is enabled for the transmitting UART.