UART
Overview
Defines standard APIs of universal asynchronous receiver/transmitter (UART) capabilities.
You can use this module to access the UART and enable the driver to operate a UART-compliant device. The functions in this module help you to obtain and release the UART device handle, read and write data, obtain and set the baud rate and device attributes.
Since:
1.0
Summary
Files
Data Structures
Enumerations
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 } |
Functions
UartOpen (uint32_t port) |
struct DevHandle |
UartRead (struct DevHandle handle, uint8_t data, uint32_t size) |
|
UartWrite (struct DevHandle handle, uint8_t data, uint32_t size) |
|
UartGetBaud (struct DevHandle handle, uint32_t baudRate) |
|
UartSetBaud (struct DevHandle handle, uint32_t baudRate) |
|
UartGetAttribute (struct DevHandle handle, struct UartAttribute attribute) |
|
UartSetAttribute (struct DevHandle handle, struct UartAttribute attribute) |
|
UartSetTransMode (struct DevHandle handle, enum UartTransMode mode) |
Details
Enumeration Type Documentation
UartTransMode
enum [UartTransMode]($api-api-SmartVision-Devices-UART.md#gab9e041a0802a7e24da22215b458bf7db)
Description:
Enumerates UART transmission modes.
Attention:
The UART controller determines whether an enumerated transmission mode is supported.
UART_MODE_RD_BLOCK | |
UART_MODE_RD_NONBLOCK | |
UART_MODE_DMA_RX_EN | |
UART_MODE_DMA_RX_DIS | |
UART_MODE_DMA_TX_EN | |
UART_MODE_DMA_TX_DIS |
Function Documentation
UartClose()
void UartClose (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle)
Description:
Releases the UART device handle.
If you no longer need to access the UART device, you should call this function to close its handle so as to release unused memory resources.
Parameters:
handle | Indicates the pointer to the UART device handle, which is obtained via UartOpen. |
UartGetAttribute()
int32_t UartGetAttribute (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle, struct [UartAttribute]($api-api-SmartVision-Devices-UartAttribute.md) * attribute )
Description:
Obtains the UART attribute.
UART attributes include data bits, stop bits, parity bit, CTS, RTS, and receiving and transmitting FIFO.
Parameters:
handle | Indicates the pointer to the UART device handle, which is obtained via UartOpen. |
attribute | Indicates the pointer to the obtained UART attribute. |
Returns:
Returns 0 if the UART attribute is obtained; returns a negative number otherwise.
UartGetBaud()
int32_t UartGetBaud (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle, uint32_t * baudRate )
Description:
Obtains the baud rate of the UART device.
Parameters:
handle | Indicates the pointer to the UART device handle, which is obtained via UartOpen. |
baudRate | Indicates the pointer to the obtained baud rate. |
Returns:
Returns 0 if the baud rate is obtained; returns a negative number otherwise.
UartOpen()
struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* UartOpen (uint32_t port)
Description:
Obtains the UART device handle.
Before accessing the UART device, you must call this function to obtain the UART device handle.
Parameters:
port | Indicates the UART port. |
Returns:
Returns the pointer to the UART device handle if the handle is obtained; returns NULL otherwise.
UartRead()
int32_t UartRead (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle, uint8_t * data, uint32_t size )
Description:
Reads data of a specified size from a UART device.
Parameters:
handle | Indicates the pointer to the UART device handle, which is obtained via UartOpen. |
data | Indicates the pointer to the buffer for receiving the data. |
size | Indicates the size of the data to read. |
Returns:
Returns the size of the data that is successfully read; returns a negative number if the reading fails.
UartSetAttribute()
int32_t UartSetAttribute (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle, struct [UartAttribute]($api-api-SmartVision-Devices-UartAttribute.md) * attribute )
Description:
Sets the UART attribute.
UART attributes include data bits, stop bits, parity bit, CTS, RTS, and receiving and transmitting FIFO.
Parameters:
handle | Indicates the pointer to the UART device handle, which is obtained via UartOpen. |
attribute | Indicates the pointer to the UART attribute to set. |
Returns:
Returns 0 if the setting is successful; returns a negative number otherwise.
UartSetBaud()
int32_t UartSetBaud (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle, uint32_t baudRate )
Description:
Sets the baud rate for the UART device.
Parameters:
handle | Indicates the pointer to the UART device handle, which is obtained via UartOpen. |
baudRate | Indicates the baud rate to set. |
Returns:
Returns 0 if the setting is successful; returns a negative number otherwise.
UartSetTransMode()
int32_t UartSetTransMode (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle, enum [UartTransMode]($api-api-SmartVision-Devices-UART.md#gab9e041a0802a7e24da22215b458bf7db) mode )
Description:
Sets the UART transmission mode.
Parameters:
handle | Indicates the pointer to the UART device handle, which is obtained via UartOpen. |
mode | Indicates a transmission mode enumerated in {@linkUartTransMode}. |
Returns:
Returns 0 if the setting is successful; returns a negative number otherwise.
UartWrite()
int32_t UartWrite (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle, uint8_t * data, uint32_t size )
Description:
Writes data of a specified size into a UART device.
Parameters:
handle | Indicates the pointer to the UART device handle, which is obtained via UartOpen. |
data | Indicates the pointer to the data to write. |
size | Indicates the size of the data to write. |
Returns:
Returns 0 if the data is successfully written; returns a negative number otherwise.