11bd4fe43Sopenharmony_ci/** 21bd4fe43Sopenharmony_ci * @file hi_uart.h 31bd4fe43Sopenharmony_ci * 41bd4fe43Sopenharmony_ci * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 51bd4fe43Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 61bd4fe43Sopenharmony_ci * you may not use this file except in compliance with the License. 71bd4fe43Sopenharmony_ci * You may obtain a copy of the License at 81bd4fe43Sopenharmony_ci * 91bd4fe43Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 101bd4fe43Sopenharmony_ci * 111bd4fe43Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 121bd4fe43Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 131bd4fe43Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 141bd4fe43Sopenharmony_ci * See the License for the specific language governing permissions and 151bd4fe43Sopenharmony_ci * limitations under the License. 161bd4fe43Sopenharmony_ci * 171bd4fe43Sopenharmony_ci * Description: UART Port APIs. \n 181bd4fe43Sopenharmony_ci */ 191bd4fe43Sopenharmony_ci/** @defgroup iot_uart UART Port 201bd4fe43Sopenharmony_ci * @ingroup drivers 211bd4fe43Sopenharmony_ci */ 221bd4fe43Sopenharmony_ci#ifndef __HI_UART_H__ 231bd4fe43Sopenharmony_ci#define __HI_UART_H__ 241bd4fe43Sopenharmony_ci 251bd4fe43Sopenharmony_ci#include <hi_types.h> 261bd4fe43Sopenharmony_ci#include "hi_mdm_types.h" 271bd4fe43Sopenharmony_ci 281bd4fe43Sopenharmony_ci#ifdef __cplusplus 291bd4fe43Sopenharmony_ciextern "C" { 301bd4fe43Sopenharmony_ci#endif 311bd4fe43Sopenharmony_ci 321bd4fe43Sopenharmony_ci/** 331bd4fe43Sopenharmony_ci * @ingroup iot_uart 341bd4fe43Sopenharmony_ci * 351bd4fe43Sopenharmony_ci * UART serial number. CNcomment:UART序号。CNend 361bd4fe43Sopenharmony_ci */ 371bd4fe43Sopenharmony_citypedef enum { 381bd4fe43Sopenharmony_ci HI_UART_IDX_0, /**< Physical port number 0.CNcomment:物理端口号0 CNend */ 391bd4fe43Sopenharmony_ci HI_UART_IDX_1, /**< Physical port number 1.CNcomment:物理端口号1 CNend */ 401bd4fe43Sopenharmony_ci HI_UART_IDX_2, /**< Physical port number 2.CNcomment:物理端口号2 CNend */ 411bd4fe43Sopenharmony_ci HI_UART_IDX_MAX /**< Maximum physical port number, which cannot be used. CNcomment:物理端口号最大值, 421bd4fe43Sopenharmony_ci 不可使用CNend */ 431bd4fe43Sopenharmony_ci} hi_uart_idx; 441bd4fe43Sopenharmony_ci 451bd4fe43Sopenharmony_ci/** 461bd4fe43Sopenharmony_ci * @ingroup iot_uart 471bd4fe43Sopenharmony_ci * 481bd4fe43Sopenharmony_ci * UART data bit. CNcomment:UART数据位。CNend 491bd4fe43Sopenharmony_ci */ 501bd4fe43Sopenharmony_citypedef enum { 511bd4fe43Sopenharmony_ci HI_UART_DATA_BIT_5 = 5, /**< Data bit: support option 5bit.CNcomment:数据位:支持配置5bit.CNend */ 521bd4fe43Sopenharmony_ci HI_UART_DATA_BIT_6, /**< Data bit: support option 6bit.CNcomment:数据位:支持配置6bit.CNend */ 531bd4fe43Sopenharmony_ci HI_UART_DATA_BIT_7, /**< Data bit: support option 7bit.CNcomment:数据位:支持配置7bit.CNend */ 541bd4fe43Sopenharmony_ci HI_UART_DATA_BIT_8, /**< Data bit: support option 8bit.CNcomment:数据位:支持配置8bit.CNend */ 551bd4fe43Sopenharmony_ci} hi_uart_data_bit; 561bd4fe43Sopenharmony_ci 571bd4fe43Sopenharmony_ci/** 581bd4fe43Sopenharmony_ci * @ingroup iot_uart 591bd4fe43Sopenharmony_ci * 601bd4fe43Sopenharmony_ci * UART stop bit. CNcomment:UART停止位。CNend 611bd4fe43Sopenharmony_ci */ 621bd4fe43Sopenharmony_citypedef enum { 631bd4fe43Sopenharmony_ci HI_UART_STOP_BIT_1 = 1, /**< Stop bit, 1bit.CNcomment:停止位,1bit停止位.CNend */ 641bd4fe43Sopenharmony_ci HI_UART_STOP_BIT_2 = 2, /**< Stop bit, 2bit.CNcomment:停止位,2bit停止位.CNend */ 651bd4fe43Sopenharmony_ci} hi_uart_stop_bit; 661bd4fe43Sopenharmony_ci 671bd4fe43Sopenharmony_ci/** 681bd4fe43Sopenharmony_ci * @ingroup iot_uart 691bd4fe43Sopenharmony_ci * 701bd4fe43Sopenharmony_ci * UART parity bit. CNcomment:UART校验位。CNend 711bd4fe43Sopenharmony_ci */ 721bd4fe43Sopenharmony_citypedef enum { 731bd4fe43Sopenharmony_ci HI_UART_PARITY_NONE = 0, /**< Parity bit, None. CNcomment:校验位,无校验CNend */ 741bd4fe43Sopenharmony_ci HI_UART_PARITY_ODD = 1, /**< Parity bit, odd. CNcomment:校验位,奇校验CNend */ 751bd4fe43Sopenharmony_ci HI_UART_PARITY_EVEN = 2, /**< Parity bit, even. CNcomment:校验位,偶校验CNend */ 761bd4fe43Sopenharmony_ci} hi_uart_parity; 771bd4fe43Sopenharmony_ci 781bd4fe43Sopenharmony_ci/** 791bd4fe43Sopenharmony_ci * @ingroup iot_uart 801bd4fe43Sopenharmony_ci * 811bd4fe43Sopenharmony_ci * UART FIFO interruption limitation. CNcomment:UART FIFO中断门限。CNend 821bd4fe43Sopenharmony_ci */ 831bd4fe43Sopenharmony_citypedef enum { 841bd4fe43Sopenharmony_ci HI_FIFO_LINE_ONE_EIGHT = 1, /**< FIFO interruption limitation, FIFO LINE = 1/8full. 851bd4fe43Sopenharmony_ci CNcomment:FIFO中断门限,FIFO LINE = 1/8full CNend */ 861bd4fe43Sopenharmony_ci HI_FIFO_LINE_ONE_QUARTER, /**< FIFO interruption limitation, FIFO LINE = 1/4full. 871bd4fe43Sopenharmony_ci CNcomment:FIFO中断门限,FIFO LINE = 1/4full CNend */ 881bd4fe43Sopenharmony_ci HI_FIFO_LINE_HALF, /**< FIFO interruption limitation, FIFO LINE = 1/2full. 891bd4fe43Sopenharmony_ci CNcomment:FIFO中断门限,FIFO LINE = 1/2full CNend */ 901bd4fe43Sopenharmony_ci HI_FIFO_LINE_THREE_QUARTERS, /**< FIFO interruption limitation, FIFO LINE = 3/4full. 911bd4fe43Sopenharmony_ci CNcomment:FIFO中断门限,FIFO LINE = 3/4full CNend */ 921bd4fe43Sopenharmony_ci HI_FIFO_LINE_SEVEN_EIGHTS, /**< FIFO interruption limitation, FIFO LINE = 7/8full. 931bd4fe43Sopenharmony_ci CNcomment:FIFO中断门限,FIFO LINE = 7/8full CNend */ 941bd4fe43Sopenharmony_ci} hi_uart_fifo_line; 951bd4fe43Sopenharmony_ci 961bd4fe43Sopenharmony_ci/** 971bd4fe43Sopenharmony_ci * @ingroup iot_uart 981bd4fe43Sopenharmony_ci * 991bd4fe43Sopenharmony_ci * UART block mode. CNcomment:UART 阻塞模式。CNend 1001bd4fe43Sopenharmony_ci */ 1011bd4fe43Sopenharmony_citypedef enum { 1021bd4fe43Sopenharmony_ci HI_UART_BLOCK_STATE_NONE_BLOCK = 1, /**< block mode, none-block. CNcomment:UART阻塞模式,非阻塞传输 CNend */ 1031bd4fe43Sopenharmony_ci HI_UART_BLOCK_STATE_BLOCK, /**< block mode, block. CNcomment:UART阻塞模式,阻塞传输 CNend */ 1041bd4fe43Sopenharmony_ci} hi_uart_block_state; 1051bd4fe43Sopenharmony_ci 1061bd4fe43Sopenharmony_ci/** 1071bd4fe43Sopenharmony_ci * @ingroup iot_uart 1081bd4fe43Sopenharmony_ci * 1091bd4fe43Sopenharmony_ci * UART DMA transmation mode. CNcomment:UART DMA传输模式。CNend 1101bd4fe43Sopenharmony_ci */ 1111bd4fe43Sopenharmony_citypedef enum { 1121bd4fe43Sopenharmony_ci HI_UART_NONE_DMA = 1, /**< None-DMA mode. CNcomment:DMA传输,不使用DMA CNend */ 1131bd4fe43Sopenharmony_ci HI_UART_USE_DMA, /**< DMA mode. CNcomment:DMA传输,使用DMA CNend */ 1141bd4fe43Sopenharmony_ci} hi_uart_dma_state; 1151bd4fe43Sopenharmony_ci 1161bd4fe43Sopenharmony_ci/** 1171bd4fe43Sopenharmony_ci * @ingroup iot_uart 1181bd4fe43Sopenharmony_ci * 1191bd4fe43Sopenharmony_ci * UART hardware flow control mode. CNcomment:UART 硬件流控控制模式。CNend 1201bd4fe43Sopenharmony_ci */ 1211bd4fe43Sopenharmony_citypedef enum { 1221bd4fe43Sopenharmony_ci HI_FLOW_CTRL_NONE, /**< hardware flow ctrl: disable flow ctrl.CNcomment:不使用。CNend */ 1231bd4fe43Sopenharmony_ci HI_FLOW_CTRL_RTS_CTS, /**< hardware flow ctrl: enable rts and cts.CNcomment:使用RTS和CTS CNend */ 1241bd4fe43Sopenharmony_ci HI_FLOW_CTRL_RTS_ONLY, /**< hardware flow ctrl: enable rts only.CNcomment:只使用RTS CNend */ 1251bd4fe43Sopenharmony_ci HI_FLOW_CTRL_CTS_ONLY, /**< hardware flow ctrl: enable cts only.CNcomment:只使用CTS CNend */ 1261bd4fe43Sopenharmony_ci} hi_flow_ctrl; 1271bd4fe43Sopenharmony_ci 1281bd4fe43Sopenharmony_ci/** 1291bd4fe43Sopenharmony_ci * @ingroup iot_uart 1301bd4fe43Sopenharmony_ci * 1311bd4fe43Sopenharmony_ci * UART basic settings. CNcomment:UART端口基本配置参数。CNend 1321bd4fe43Sopenharmony_ci */ 1331bd4fe43Sopenharmony_citypedef struct { 1341bd4fe43Sopenharmony_ci hi_u32 baud_rate; /**< Baud Rate.CNcomment:波特率。CNend */ 1351bd4fe43Sopenharmony_ci hi_u8 data_bits; /**< Data bit. CNcomment:数据位。CNend */ 1361bd4fe43Sopenharmony_ci hi_u8 stop_bits; /**< Stop bit. CNcomment:停止位。CNend */ 1371bd4fe43Sopenharmony_ci hi_u8 parity; /**< Parity check flag. CNcomment:奇偶校验位。CNend */ 1381bd4fe43Sopenharmony_ci hi_u8 pad; /**< reserved pad */ 1391bd4fe43Sopenharmony_ci} hi_uart_attribute; 1401bd4fe43Sopenharmony_ci 1411bd4fe43Sopenharmony_ci/** 1421bd4fe43Sopenharmony_ci * @ingroup iot_uart 1431bd4fe43Sopenharmony_ci * 1441bd4fe43Sopenharmony_ci * UART extra attributes.CNcomment:UART端口额外参数配置。CNend 1451bd4fe43Sopenharmony_ci */ 1461bd4fe43Sopenharmony_citypedef struct { 1471bd4fe43Sopenharmony_ci hi_uart_fifo_line tx_fifo_line; 1481bd4fe43Sopenharmony_ci hi_uart_fifo_line rx_fifo_line; 1491bd4fe43Sopenharmony_ci hi_uart_fifo_line flow_fifo_line; 1501bd4fe43Sopenharmony_ci hi_uart_block_state tx_block; 1511bd4fe43Sopenharmony_ci hi_uart_block_state rx_block; 1521bd4fe43Sopenharmony_ci hi_u16 tx_buf_size; 1531bd4fe43Sopenharmony_ci hi_u16 rx_buf_size; 1541bd4fe43Sopenharmony_ci hi_uart_dma_state tx_use_dma; 1551bd4fe43Sopenharmony_ci hi_uart_dma_state rx_use_dma; 1561bd4fe43Sopenharmony_ci} hi_uart_extra_attr; 1571bd4fe43Sopenharmony_ci 1581bd4fe43Sopenharmony_ci/** 1591bd4fe43Sopenharmony_ci* @ingroup iot_uart 1601bd4fe43Sopenharmony_ci* @brief UART initialization. CNcomment:UART初始化。CNend 1611bd4fe43Sopenharmony_ci* 1621bd4fe43Sopenharmony_ci* @par 描述: 1631bd4fe43Sopenharmony_ci* Set UART with configuration. CNcomment:根据参数配置指定UART。CNend 1641bd4fe43Sopenharmony_ci* 1651bd4fe43Sopenharmony_ci* @attention 1.If extra_attr is set to HI_NULL, all optimization parameters of the notification driver use the default 1661bd4fe43Sopenharmony_ci* values.CNcomment:extra_attr为HI_NULL表示通知驱动所有优化参数使用默认值;CNend 1671bd4fe43Sopenharmony_ci* 2.If the value of the member parameter in extra_attr is 0, it indicates that the member parameter 1681bd4fe43Sopenharmony_ci* is notified to the driver. The member parameter uses the default value. 1691bd4fe43Sopenharmony_ci* CNcomment:extra_attr中成员参数值为0表示通知驱动该成员参数使用默认值;CNend 1701bd4fe43Sopenharmony_ci* 3.After the UART initialization is complete, if you want to change the UART optimization parameter 1711bd4fe43Sopenharmony_ci* configuration, you need to call hi_uart_deinit to deinitialize the UART before calling hi_uart_init 1721bd4fe43Sopenharmony_ci* to change the optimization parameter configuration. CNcomment:UART初始化完成后,若要变更UART 1731bd4fe43Sopenharmony_ci优化参数配置,需先调用hi_uart_deinit去初始化UART,再调用hi_uart_init变更优化参数配置。CNend 1741bd4fe43Sopenharmony_ci* 1751bd4fe43Sopenharmony_ci* @param id [IN] type #hi_uart_idx,UART port id. CNcomment:UART端口号。CNend 1761bd4fe43Sopenharmony_ci* @param param [IN] type #const hi_uart_attribute*,UART base settings.CNcomment:UART基本参数。CNend 1771bd4fe43Sopenharmony_ci* @param extra_attr [IN] type #const hi_uart_extra_attr*,UART extra settings. CNcomment:UART优化参数。CNend 1781bd4fe43Sopenharmony_ci* 1791bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success. 1801bd4fe43Sopenharmony_ci* @retval #HI_ERR_FAILURE Failure. 1811bd4fe43Sopenharmony_ci* @par 依赖: 1821bd4fe43Sopenharmony_ci* @li hi_uart.h:Describes UART APIs.CNcomment:UART相关接口。CNend 1831bd4fe43Sopenharmony_ci* @see hi_uart_deinit。 1841bd4fe43Sopenharmony_ci*/ 1851bd4fe43Sopenharmony_cihi_u32 hi_uart_init(hi_uart_idx id, const hi_uart_attribute *param, const hi_uart_extra_attr *extra_attr); 1861bd4fe43Sopenharmony_ci 1871bd4fe43Sopenharmony_ci/** 1881bd4fe43Sopenharmony_ci* @ingroup iot_uart 1891bd4fe43Sopenharmony_ci* @brief Reads data.CNcomment:读数据。CNend 1901bd4fe43Sopenharmony_ci* 1911bd4fe43Sopenharmony_ci* @par 描述: 1921bd4fe43Sopenharmony_ci* Reads the data received by the UART. CNcomment:将UART接收到的数据读取出来。CNend 1931bd4fe43Sopenharmony_ci* 1941bd4fe43Sopenharmony_ci* @attention This API must be used after the hi_uart_open function is called. 1951bd4fe43Sopenharmony_ciCNcomment:须在调用完hi_uart_init函数之后使用。CNend 1961bd4fe43Sopenharmony_ci* @param id [IN] type #hi_uart_idx,UART port id. CNcomment:UART端口号。CNend 1971bd4fe43Sopenharmony_ci* @param data [OUT] type #hi_u8*,Start address of the data to be read.CNcomment:读到数据的首地址。CNend 1981bd4fe43Sopenharmony_ci* @param data_len [IN] type #hi_u32,Number of bytes to be read.CNcomment:要读取数据的字节数。CNend 1991bd4fe43Sopenharmony_ci* 2001bd4fe43Sopenharmony_ci* @retval #>=0 Number of bytes that are actually read.CNcomment:实际读到数据的字节数。CNend 2011bd4fe43Sopenharmony_ci* @retval #HI_ERR_FAILURE Data read error.CNcomment:读数据失败。CNend 2021bd4fe43Sopenharmony_ci* @par 依赖: 2031bd4fe43Sopenharmony_ci* @li hi_uart.h:Describes UART APIs.CNcomment:UART相关接口。CNend 2041bd4fe43Sopenharmony_ci* @see hi_uart_write。 2051bd4fe43Sopenharmony_ci*/ 2061bd4fe43Sopenharmony_cihi_s32 hi_uart_read(hi_uart_idx id, hi_u8 *data, hi_u32 data_len); 2071bd4fe43Sopenharmony_ci 2081bd4fe43Sopenharmony_ci/** 2091bd4fe43Sopenharmony_ci* @ingroup iot_uart 2101bd4fe43Sopenharmony_ci* @brief Reads data in specified timeout time.CNomment:在指定超时时间内读取数据。CNend 2111bd4fe43Sopenharmony_ci* 2121bd4fe43Sopenharmony_ci* @par 描述: 2131bd4fe43Sopenharmony_ci* Reads data in specified timeout time.CNomment:在指定超时时间内读取数据。CNend 2141bd4fe43Sopenharmony_ci* if Reads all data before timeout, function will return. 2151bd4fe43Sopenharmony_ciCNomment:超时前读取完成所有数据后,函数会立即返回。CNend 2161bd4fe43Sopenharmony_ci* 2171bd4fe43Sopenharmony_ci* @attention This API must be used after the hi_uart_open function is called. 2181bd4fe43Sopenharmony_ciCNcomment:须在调用完hi_uart_init函数之后使用。CNend 2191bd4fe43Sopenharmony_ci* @param id [IN] type #hi_uart_idx,UART port id. CNcomment:UART端口号。CNend 2201bd4fe43Sopenharmony_ci* @param data [OUT] type #hi_u8*,Start address of the data to be read.CNcomment:读到数据的首地址。CNend 2211bd4fe43Sopenharmony_ci* @param data_len [IN] type #hi_u32,Number of bytes to be read.CNcomment:要读取数据的字节数。CNend 2221bd4fe43Sopenharmony_ci* @param timeout_ms [IN] type #hi_u32,timeout.CNcomment:超时时间。CNend 2231bd4fe43Sopenharmony_ci* 2241bd4fe43Sopenharmony_ci* @retval #>=0 Number of bytes that are actually read.CNcomment:实际读到数据的字节数。CNend 2251bd4fe43Sopenharmony_ci* @retval #HI_ERR_FAILURE Data read error.CNcomment:读数据失败。CNend 2261bd4fe43Sopenharmony_ci* @par 依赖: 2271bd4fe43Sopenharmony_ci* @li hi_uart.h:Describes UART APIs.CNcomment:UART相关接口。CNend 2281bd4fe43Sopenharmony_ci* @see hi_uart_write。 2291bd4fe43Sopenharmony_ci*/ 2301bd4fe43Sopenharmony_cihi_s32 hi_uart_read_timeout(hi_uart_idx id, hi_u8 *data, hi_u32 len, hi_u32 timeout_ms); 2311bd4fe43Sopenharmony_ci 2321bd4fe43Sopenharmony_ci/** 2331bd4fe43Sopenharmony_ci* @ingroup iot_uart 2341bd4fe43Sopenharmony_ci* @brief Writes data.CNcomment:写数据。CNend 2351bd4fe43Sopenharmony_ci* 2361bd4fe43Sopenharmony_ci* @par 描述: 2371bd4fe43Sopenharmony_ci* Writes the data to be sent to the UART. The block mode is used by default. 2381bd4fe43Sopenharmony_ciCNcomment:将待发送的数据写到UART。CNend 2391bd4fe43Sopenharmony_ci* 2401bd4fe43Sopenharmony_ci* @attention This API must be used after the hi_uart_init function is called. 2411bd4fe43Sopenharmony_ciCNcomment:须在调用完hi_uart_init函数之后使用。CNend 2421bd4fe43Sopenharmony_ci* @param id [IN] type #hi_uart_idx,UART port id. CNcomment:UART端口号。CNend 2431bd4fe43Sopenharmony_ci* @param data [IN] type #const hi_u8*,Start address of the data to be written.CNcomment:待写数据的首地址。CNend 2441bd4fe43Sopenharmony_ci* @param data_len [IN] type #hi_u32,Number of bytes to be written.CNcomment:待写数据的字节数。CNend 2451bd4fe43Sopenharmony_ci* 2461bd4fe43Sopenharmony_ci* @retval #>=0 Number of bytes to be sent.CNcomment:实际发送数据的字节数。CNend 2471bd4fe43Sopenharmony_ci* @retval #HI_ERR_FAILURE Data send failure. CNcomment:发送数据失败。CNend 2481bd4fe43Sopenharmony_ci* @par 依赖: 2491bd4fe43Sopenharmony_ci* @li hi_uart.h:Describes UART APIs.CNcomment:UART相关接口。CNend 2501bd4fe43Sopenharmony_ci* @see hi_uart_read。 2511bd4fe43Sopenharmony_ci*/ 2521bd4fe43Sopenharmony_cihi_s32 hi_uart_write(hi_uart_idx id, const hi_u8 *data, hi_u32 data_len); 2531bd4fe43Sopenharmony_ci 2541bd4fe43Sopenharmony_ci/** 2551bd4fe43Sopenharmony_ci* @ingroup iot_uart 2561bd4fe43Sopenharmony_ci* @brief Deinitializes UART.CNcomment:去初始化UART。CNend 2571bd4fe43Sopenharmony_ci* 2581bd4fe43Sopenharmony_ci* @par 描述: 2591bd4fe43Sopenharmony_ci* Deinitializes UART.CNcomment:去初始化UART。CNend 2601bd4fe43Sopenharmony_ci* 2611bd4fe43Sopenharmony_ci* @attention This API is used together with hi_uart_init.CNcomment:与hi_uart_init成对使用。CNend 2621bd4fe43Sopenharmony_ci* @param id [IN] type #hi_uart_idx,UART port id. CNcomment:UART端口号。CNend 2631bd4fe43Sopenharmony_ci* 2641bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success. 2651bd4fe43Sopenharmony_ci* @retval #Other Failure. For details, see hi_errno.h. 2661bd4fe43Sopenharmony_ci* @par 依赖: 2671bd4fe43Sopenharmony_ci* @li hi_uart.h:Describes UART APIs.CNcomment:UART相关接口。CNend 2681bd4fe43Sopenharmony_ci* @see hi_uart_init。 2691bd4fe43Sopenharmony_ci*/ 2701bd4fe43Sopenharmony_cihi_u32 hi_uart_deinit(hi_uart_idx id); 2711bd4fe43Sopenharmony_ci 2721bd4fe43Sopenharmony_ci/** 2731bd4fe43Sopenharmony_ci* @ingroup iot_uart 2741bd4fe43Sopenharmony_ci* @brief Set UART hardware flow control.CNcomment:配置UART硬件流控功能。CNend 2751bd4fe43Sopenharmony_ci* 2761bd4fe43Sopenharmony_ci* @par 描述: 2771bd4fe43Sopenharmony_ci* Set UART hardware flow control.CNcomment:配置UART硬件流控功能。CNend 2781bd4fe43Sopenharmony_ci* 2791bd4fe43Sopenharmony_ci* @attention This API must be used after the hi_uart_init function is called. UART0 doesn't support flow control. 2801bd4fe43Sopenharmony_ciCNcomment:须在调用完hi_uart_init函数之后使用;UART0不支持流控功能。CNend 2811bd4fe43Sopenharmony_ci* 2821bd4fe43Sopenharmony_ci* @param id [IN] type #hi_uart_idx,UART port id. CNcomment:UART端口号。CNend 2831bd4fe43Sopenharmony_ci* @param flow_ctrl [IN] type #hi_flow_ctrl,haredware flow control mode. 2841bd4fe43Sopenharmony_ciCNcomment:硬件流控功能控制模式。CNend 2851bd4fe43Sopenharmony_ci* 2861bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success. 2871bd4fe43Sopenharmony_ci* @retval #Other Failure. For details, see hi_errno.h. 2881bd4fe43Sopenharmony_ci* @par 依赖: 2891bd4fe43Sopenharmony_ci* @li hi_uart.h:Describes UART APIs.CNcomment:UART相关接口。CNend 2901bd4fe43Sopenharmony_ci* @see 无。 2911bd4fe43Sopenharmony_ci*/ 2921bd4fe43Sopenharmony_cihi_u32 hi_uart_set_flow_ctrl(hi_uart_idx id, hi_flow_ctrl flow_ctrl); 2931bd4fe43Sopenharmony_ci 2941bd4fe43Sopenharmony_ci/** 2951bd4fe43Sopenharmony_ci* @ingroup iot_uart 2961bd4fe43Sopenharmony_ci* @brief Write data by polling. CNcomment:轮询写数据。CNend 2971bd4fe43Sopenharmony_ci* 2981bd4fe43Sopenharmony_ci* @par 描述: 2991bd4fe43Sopenharmony_ci* Write data by polling. CNcomment:通过轮询的方式将待发送的数据写到UART。CNend 3001bd4fe43Sopenharmony_ci* 3011bd4fe43Sopenharmony_ci* @attention This API must be used after the hi_uart_init function is called. 3021bd4fe43Sopenharmony_ciCNcomment:须在调用完hi_uart_init函数之后使用。CNend 3031bd4fe43Sopenharmony_ci* 3041bd4fe43Sopenharmony_ci* @param id [IN] type #hi_uart_idx,UART port id. CNcomment:UART端口号。CNend 3051bd4fe43Sopenharmony_ci* @param data [IN] type #const hi_u8*,Start address of the data to be written.CNcomment:待写数据的首地址。CNend 3061bd4fe43Sopenharmony_ci* @param data_len [IN] type #hi_u32,Number of bytes to be written.CNcomment:待写数据的字节数。CNend 3071bd4fe43Sopenharmony_ci* 3081bd4fe43Sopenharmony_ci* @retval #>=0 Number of bytes to be sent.CNcomment:实际发送数据的字节数。CNend 3091bd4fe43Sopenharmony_ci* @retval #HI_ERR_FAILURE Data send failure. CNcomment:发送数据失败。CNend 3101bd4fe43Sopenharmony_ci* @par 依赖: 3111bd4fe43Sopenharmony_ci* @li hi_uart.h:Describes UART APIs.CNcomment:UART相关接口。CNend 3121bd4fe43Sopenharmony_ci* @see None 3131bd4fe43Sopenharmony_ci*/ 3141bd4fe43Sopenharmony_cihi_s32 hi_uart_write_immediately(hi_uart_idx id, const hi_u8 *data, hi_u32 data_len); 3151bd4fe43Sopenharmony_ci 3161bd4fe43Sopenharmony_ci/** 3171bd4fe43Sopenharmony_ci* @ingroup iot_uart 3181bd4fe43Sopenharmony_ci* @brief Obtains UART settings. CNcomment:获取UART配置参数。CNend 3191bd4fe43Sopenharmony_ci* 3201bd4fe43Sopenharmony_ci* @par 描述: 3211bd4fe43Sopenharmony_ci* Obtains UART settings. CNcomment:获取指定UART当前配置参数。CNend 3221bd4fe43Sopenharmony_ci* 3231bd4fe43Sopenharmony_ci* @attention If extra_attr is HI_NULL, the current UART optimization parameters are not requested. This parameter 3241bd4fe43Sopenharmony_ci* must be used after the hi_uart_init function is invoked.CNcomment:extra_attr为HI_NULL表示不请求 3251bd4fe43Sopenharmony_ci当前UART的优化参数;须在调用完hi_uart_init函数之后使用。CNend 3261bd4fe43Sopenharmony_ci* 3271bd4fe43Sopenharmony_ci* @param id [IN] type #hi_uart_idx,UART port id. CNcomment:UART端口号。CNend 3281bd4fe43Sopenharmony_ci* @param attr [OUT] type #hi_uart_attribute*,UART base settings.CNcomment:UART基本参数。CNend 3291bd4fe43Sopenharmony_ci* @param extra_attr [OUT] type #hi_uart_extra_attr*,UART extra settings. CNcomment:UART优化参数。CNend 3301bd4fe43Sopenharmony_ci* 3311bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success. 3321bd4fe43Sopenharmony_ci* @retval #HI_ERR_FAILURE Failure. 3331bd4fe43Sopenharmony_ci* @par 依赖: 3341bd4fe43Sopenharmony_ci* @li hi_uart.h:Describes UART APIs.CNcomment:UART相关接口。CNend 3351bd4fe43Sopenharmony_ci* @see hi_uart_init。 3361bd4fe43Sopenharmony_ci*/ 3371bd4fe43Sopenharmony_cihi_u32 hi_uart_get_attribute(hi_uart_idx id, hi_uart_attribute *attr, hi_uart_extra_attr *extra_attr); 3381bd4fe43Sopenharmony_ci 3391bd4fe43Sopenharmony_ci/** 3401bd4fe43Sopenharmony_ci* @ingroup iot_uart 3411bd4fe43Sopenharmony_ci* @brief Determine FIFO and soft buf is empty. CNcomment:判断FIFO与软件BUF是否为空。CNend 3421bd4fe43Sopenharmony_ci* 3431bd4fe43Sopenharmony_ci* @par 描述: 3441bd4fe43Sopenharmony_ci* Determine FIFO and soft buf is empty. CNcomment:判断指定UART的FIFO与软件BUF是否为空。CNend 3451bd4fe43Sopenharmony_ci* 3461bd4fe43Sopenharmony_ci* @attention This API must be used after the hi_uart_init function is called. 3471bd4fe43Sopenharmony_ciCNcomment:须在调用完hi_uart_init函数之后使用。CNend 3481bd4fe43Sopenharmony_ci* 3491bd4fe43Sopenharmony_ci* @param id [IN] type #hi_uart_idx,UART port id. CNcomment:UART端口号。CNend 3501bd4fe43Sopenharmony_ci* @param empty [OUT] type #hi_bool*,Store query result, HI_TRUE means empty, HI_FALSE means non-empty. 3511bd4fe43Sopenharmony_ciCNcomment:存储查询结果,如果为HI_TRUE代表FIFO与软件BUF都为空,如果为HI_FALSE表示非空。CNend 3521bd4fe43Sopenharmony_ci* 3531bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success. 3541bd4fe43Sopenharmony_ci* @retval #HI_ERR_FAILURE Failure. 3551bd4fe43Sopenharmony_ci* @par 依赖: 3561bd4fe43Sopenharmony_ci* @li hi_uart.h:Describes UART APIs.CNcomment:UART相关接口。CNend 3571bd4fe43Sopenharmony_ci* @see hi_uart_init。 3581bd4fe43Sopenharmony_ci*/ 3591bd4fe43Sopenharmony_ciBSP_RAM_TEXT_SECTION hi_u32 hi_uart_is_buf_empty(hi_uart_idx id, hi_bool *empty); 3601bd4fe43Sopenharmony_ci 3611bd4fe43Sopenharmony_ci/** 3621bd4fe43Sopenharmony_ci* @ingroup iot_uart 3631bd4fe43Sopenharmony_ci* @brief Determine UART is busy. CNcomment:判断UART是否忙。CNend 3641bd4fe43Sopenharmony_ci* 3651bd4fe43Sopenharmony_ci* @par 描述: 3661bd4fe43Sopenharmony_ci* Determine UART is busy. CNcomment:判断指定UART是否忙。CNend 3671bd4fe43Sopenharmony_ci* 3681bd4fe43Sopenharmony_ci* @attention This API must be used after the hi_uart_init function is called. 3691bd4fe43Sopenharmony_ciCNcomment:须在调用完hi_uart_init函数之后使用。CNend 3701bd4fe43Sopenharmony_ci* 3711bd4fe43Sopenharmony_ci* @param id [IN] type #hi_uart_idx,UART port id. CNcomment:UART端口号。CNend 3721bd4fe43Sopenharmony_ci* @param busy [OUT] type #hi_bool*,Store query result, HI_TRUE means busy, HI_FALSE means not busy. 3731bd4fe43Sopenharmony_ciCNcomment:存储查询结果,如果为HI_TRUE代表UART在忙,如果为HI_FALSE表示空闲。CNend 3741bd4fe43Sopenharmony_ci* 3751bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success. 3761bd4fe43Sopenharmony_ci* @retval #HI_ERR_FAILURE Failure. 3771bd4fe43Sopenharmony_ci* @par 依赖: 3781bd4fe43Sopenharmony_ci* @li hi_uart.h:Describes UART APIs.CNcomment:UART相关接口。CNend 3791bd4fe43Sopenharmony_ci* @see hi_uart_init。 3801bd4fe43Sopenharmony_ci*/ 3811bd4fe43Sopenharmony_ciBSP_RAM_TEXT_SECTION hi_u32 hi_uart_is_busy(hi_uart_idx id, hi_bool *busy); 3821bd4fe43Sopenharmony_ci 3831bd4fe43Sopenharmony_ci/** 3841bd4fe43Sopenharmony_ci* @ingroup iot_uart 3851bd4fe43Sopenharmony_ci* @brief Quits Read data.CNcomment:退出阻塞读数据。CNend 3861bd4fe43Sopenharmony_ci* 3871bd4fe43Sopenharmony_ci* @par 描述: 3881bd4fe43Sopenharmony_ci* Quits Read data. CNcomment:退出阻塞读数据。CNend 3891bd4fe43Sopenharmony_ci* 3901bd4fe43Sopenharmony_ci* @attention Only apply in block read mode. 3911bd4fe43Sopenharmony_ciCNcomment:该接口仅应用在阻塞读数据模式下。CNend 3921bd4fe43Sopenharmony_ci* @param id [IN] type #hi_uart_idx,UART port id. CNcomment:UART端口号。CNend 3931bd4fe43Sopenharmony_ci* 3941bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success. 3951bd4fe43Sopenharmony_ci* @retval #Other Failure. 3961bd4fe43Sopenharmony_ci* @par 依赖: 3971bd4fe43Sopenharmony_ci* @li hi_uart.h:Describes UART APIs.CNcomment:UART相关接口。CNend 3981bd4fe43Sopenharmony_ci* @see hi_uart_quit_read。 3991bd4fe43Sopenharmony_ci*/ 4001bd4fe43Sopenharmony_cihi_u32 hi_uart_quit_read(hi_uart_idx id); 4011bd4fe43Sopenharmony_ci 4021bd4fe43Sopenharmony_ci/** 4031bd4fe43Sopenharmony_ci* @ingroup iot_uart 4041bd4fe43Sopenharmony_ci* @brief Save register-related values before going to deep sleep.CNcomment:深睡前保存相关寄存器内容。CNend 4051bd4fe43Sopenharmony_ci* 4061bd4fe43Sopenharmony_ci* @par 描述: 4071bd4fe43Sopenharmony_ci* Regs-related values are saved before entering deep sleep to facilitate sleep recovery. 4081bd4fe43Sopenharmony_ciCNcomment:深睡前保存相关寄存器内容,以便于睡醒恢复UART。CNend 4091bd4fe43Sopenharmony_ci* 4101bd4fe43Sopenharmony_ci* @attention Called before deep sleep. 4111bd4fe43Sopenharmony_ciCNcomment:在深睡前调用。CNend 4121bd4fe43Sopenharmony_ci* @param id [IN] type #hi_uart_idx,UART port id. CNcomment:UART端口号。CNend 4131bd4fe43Sopenharmony_ci* 4141bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success. 4151bd4fe43Sopenharmony_ci* @retval #Other Failure. 4161bd4fe43Sopenharmony_ci* @par 依赖: 4171bd4fe43Sopenharmony_ci* @li hi_uart.h:Describes UART APIs.CNcomment:UART相关接口。CNend 4181bd4fe43Sopenharmony_ci* @see hi_uart_lp_save。 4191bd4fe43Sopenharmony_ci*/ 4201bd4fe43Sopenharmony_cihi_u32 hi_uart_lp_save(hi_uart_idx id); 4211bd4fe43Sopenharmony_ci 4221bd4fe43Sopenharmony_ci/** 4231bd4fe43Sopenharmony_ci* @ingroup iot_uart 4241bd4fe43Sopenharmony_ci* @brief Restore register related values after deep sleep wake up.CNcomment:深睡唤醒后恢复寄存器内容。CNend 4251bd4fe43Sopenharmony_ci* 4261bd4fe43Sopenharmony_ci* @par 描述: 4271bd4fe43Sopenharmony_ci* Restore register related values after deep sleep wake up.CNcomment:深睡唤醒后恢复寄存器内容。CNend 4281bd4fe43Sopenharmony_ci* 4291bd4fe43Sopenharmony_ci* @attention Called after deep sleep wake up. 4301bd4fe43Sopenharmony_ciCNcomment:深睡唤醒后调用。CNend 4311bd4fe43Sopenharmony_ci* @param id [IN] type #hi_uart_idx,UART port id. CNcomment:UART端口号。CNend 4321bd4fe43Sopenharmony_ci* 4331bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS Success. 4341bd4fe43Sopenharmony_ci* @retval #Other Failure. 4351bd4fe43Sopenharmony_ci* @par 依赖: 4361bd4fe43Sopenharmony_ci* @li hi_uart.h:Describes UART APIs.CNcomment:UART相关接口。CNend 4371bd4fe43Sopenharmony_ci* @see hi_uart_lp_restore。 4381bd4fe43Sopenharmony_ci*/ 4391bd4fe43Sopenharmony_cihi_u32 hi_uart_lp_restore(hi_uart_idx id); 4401bd4fe43Sopenharmony_ci 4411bd4fe43Sopenharmony_ci#ifdef __cplusplus 4421bd4fe43Sopenharmony_ci} 4431bd4fe43Sopenharmony_ci#endif 4441bd4fe43Sopenharmony_ci 4451bd4fe43Sopenharmony_ci#endif 446