同步操作将从 OpenHarmony/docs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
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
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 } |
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) |
enum [UartTransMode](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 |
void UartClose (struct [DevHandle](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. |
int32_t UartGetAttribute (struct [DevHandle](DevHandle.md) * handle, struct [UartAttribute](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.
int32_t UartGetBaud (struct [DevHandle](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.
struct [DevHandle](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.
int32_t UartRead (struct [DevHandle](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.
int32_t UartSetAttribute (struct [DevHandle](DevHandle.md) * handle, struct [UartAttribute](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.
int32_t UartSetBaud (struct [DevHandle](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.
int32_t UartSetTransMode (struct [DevHandle](DevHandle.md) * handle, enum [UartTransMode](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.
int32_t UartWrite (struct [DevHandle](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.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。