WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
uart.h
浏览该文件的文档.
1
9#ifndef UART_H
10#define UART_H
11
12#include <stdint.h>
13#include <stddef.h>
14#include "errcode.h"
15#include "hal_uart.h"
16#include "uart_porting.h"
17
18#if !defined(CONFIG_UART_SUPPORT_TX) && !defined(CONFIG_UART_SUPPORT_RX)
19#error UART must support TX or RX
20#endif /* !defined(CONFIG_UART_SUPPORT_TX) && !defined(CONFIG_UART_SUPPORT_RX) */
21
22#ifdef __cplusplus
23#if __cplusplus
24extern "C" {
25#endif /* __cplusplus */
26#endif /* __cplusplus */
27
42
51
60
69
78
87
96
97#if defined(CONFIG_UART_SUPPORT_TX) && defined(CONFIG_UART_SUPPORT_DMA)
140#endif /* defined(CONFIG_UART_SUPPORT_TX) && defined(CONFIG_UART_SUPPORT_DMA) */
141
155
156#if defined(CONFIG_UART_SUPPORT_RX)
157
158#define UART_RX_CONDITION_MASK_IDLE 1
159#define UART_RX_CONDITION_MASK_SUFFICIENT_DATA 2
160#define UART_RX_CONDITION_MASK_FULL 4
161
194
212typedef void (*uart_rx_callback_t)(const void *buffer, uint16_t length, bool error);
213
214#if defined(CONFIG_UART_SUPPORT_INT_TRIGGER_DMA) && defined(CONFIG_UART_SUPPORT_DMA)
233typedef void (*uart_rx_by_dma_callback_t)(uart_bus_t bus, const void *buffer, uint32_t length,
234 uart_write_dma_config_t *dma_cfg);
235#endif /* defined(CONFIG_UART_SUPPORT_INT_TRIGGER_DMA) && defined(CONFIG_UART_SUPPORT_DMA) */
236#endif /* CONFIG_UART_SUPPORT_RX */
237
238#if defined(CONFIG_UART_SUPPORT_TX)
254typedef void (*uart_tx_callback_t)(const void *buffer, uint32_t length, const void *params);
255#endif /* CONFIG_UART_SUPPORT_TX */
256
272typedef void (*uart_error_callback_t)(uint32_t *err_info, uint32_t len);
273
296 const uart_attr_t *attr, const uart_extra_attr_t *extra_attr,
298
313
330
347
360
373
386
387#if defined(CONFIG_UART_SUPPORT_RX)
410 uint32_t size, uart_rx_callback_t callback);
411
422
441
460
479#endif /* CONFIG_UART_SUPPORT_RX */
480
481#if defined(CONFIG_UART_SUPPORT_TX)
499int32_t uapi_uart_write(uart_bus_t bus, const uint8_t *buffer, uint32_t length, uint32_t timeout);
500
526errcode_t uapi_uart_write_int(uart_bus_t bus, const uint8_t *buffer, uint32_t length,
527 void *params, uart_tx_callback_t finished_with_buffer_func);
528
529#if defined(CONFIG_UART_SUPPORT_DMA)
547int32_t uapi_uart_write_by_dma(uart_bus_t bus, const void *buffer, uint32_t length, uart_write_dma_config_t *dma_cfg);
548
566int32_t uapi_uart_read_by_dma(uart_bus_t bus, const void *buffer, uint32_t length, uart_write_dma_config_t *dma_cfg);
567
568#if defined(CONFIG_UART_SUPPORT_INT_TRIGGER_DMA)
584errcode_t uapi_uart_register_read_by_dma_callback(uart_bus_t bus, uart_write_dma_config_t *dma_cfg);
585
595void uapi_uart_unregister_read_by_dma_callback(uart_bus_t bus);
596#endif /* CONFIG_UART_SUPPORT_INT_TRIGGER_DMA */
597#endif /* CONFIG_UART_SUPPORT_DMA */
598#endif /* CONFIG_UART_SUPPORT_TX */
599
600#if defined(CONFIG_UART_SUPPORT_RX)
618int32_t uapi_uart_read(uart_bus_t bus, const uint8_t *buffer, uint32_t length, uint32_t timeout);
619
634
652errcode_t uapi_uart_update_rx_buff(uart_bus_t bus, uint8_t *rx_buffer, uint16_t rx_buffer_size);
653#endif /* CONFIG_UART_SUPPORT_RX */
654
655#if defined(CONFIG_UART_SUPPORT_LPM)
670
685#endif /* CONFIG_UART_SUPPORT_LPM */
686
691#ifdef __cplusplus
692#if __cplusplus
693}
694#endif /* __cplusplus */
695#endif /* __cplusplus */
696
697#endif
uart_bus_t
UART bus.
Definition platform_core.h:198
uint32_t errcode_t
Definition of error code.
Definition errcode.h:30
bool uapi_uart_rx_fifo_is_empty(uart_bus_t bus)
判断RX FIFO是否为空。
Definition uart.c:1451
hal_uart_extra_attr_t uart_extra_attr_t
UART扩展属性定义。
Definition uart.h:86
errcode_t uapi_uart_register_overrun_error_callback(uart_bus_t bus, uart_error_callback_t callback)
注册溢出错误处理回调函数。
struct uart_write_dma_config uart_write_dma_config_t
UART DMA配置数据结构定义。
struct uart_buffer_config uart_buffer_config_t
UART 缓存数据结构定义。
void(* uart_error_callback_t)(uint32_t *err_info, uint32_t len)
UART错误处理回调函数,通过uapi_uart_register_frame_error_callback注册到驱动中。
Definition uart.h:272
#define UART_RX_CONDITION_MASK_SUFFICIENT_DATA
Definition uart.h:159
void(* uart_rx_callback_t)(const void *buffer, uint16_t length, bool error)
UART接收数据的回调函数,通过 uapi_uart_register_rx_callback 注册到驱动中。
Definition uart.h:212
hal_uart_stop_bit_t uart_stop_bit_t
UART停止位定义。
Definition uart.h:68
errcode_t uapi_uart_register_parity_error_callback(uart_bus_t bus, uart_error_callback_t callback)
注册奇偶校验错误处理的回调函数。
Definition uart.c:626
errcode_t uapi_uart_register_rx_callback(uart_bus_t bus, uart_rx_condition_t condition, uint32_t size, uart_rx_callback_t callback)
注册接收回调函数,这个回调函数会根据触发条件和Size触发。
Definition uart.c:583
int32_t uapi_uart_write_by_dma(uart_bus_t bus, const void *buffer, uint32_t length, uart_write_dma_config_t *dma_cfg)
通过DMA发送数据。
Definition uart.c:824
void(* uart_tx_callback_t)(const void *buffer, uint32_t length, const void *params)
UART发送数据的回调函数,在调用 uapi_uart_write_int 时传递给函数。
Definition uart.h:254
errcode_t uapi_uart_update_rx_buff(uart_bus_t bus, uint8_t *rx_buffer, uint16_t rx_buffer_size)
更新UART接收Buffer的地址和长度。
hal_uart_attr_t uart_attr_t
UART基本属性定义。
Definition uart.h:77
errcode_t uapi_uart_deinit(uart_bus_t bus)
去初始化指定的串口。
Definition uart.c:525
hal_uart_parity_t uart_parity_t
UART奇偶校验位定义。
Definition uart.h:59
int32_t uapi_uart_read(uart_bus_t bus, const uint8_t *buffer, uint32_t length, uint32_t timeout)
从UART读取数据。
Definition uart.c:937
#define UART_RX_CONDITION_MASK_FULL
Definition uart.h:160
hal_uart_flow_ctrl_t uart_flow_ctrl_t
UART流控类型定义。
Definition uart.h:95
#define UART_RX_CONDITION_MASK_IDLE
Definition uart.h:158
bool uapi_uart_has_pending_transmissions(uart_bus_t bus)
判断是否存在正在等待的传输。
Definition uart.c:1426
hal_uart_pin_config_t uart_pin_config_t
UART PIN配置结构体。
Definition uart.h:41
int32_t uapi_uart_write(uart_bus_t bus, const uint8_t *buffer, uint32_t length, uint32_t timeout)
将数据发送到已经打开的UART上,使用直接发送的方式。
Definition uart.c:672
errcode_t uapi_uart_suspend(uintptr_t arg)
挂起所有的UART通道。
Definition uart.c:1128
int32_t uapi_uart_read_by_dma(uart_bus_t bus, const void *buffer, uint32_t length, uart_write_dma_config_t *dma_cfg)
通过DMA读取数据。
Definition uart.c:892
errcode_t uapi_uart_get_attr(uart_bus_t bus, const uart_attr_t *attr)
获取串口的基础配置参数。
Definition uart.c:571
errcode_t uapi_uart_init(uart_bus_t bus, const uart_pin_config_t *pins, const uart_attr_t *attr, const uart_extra_attr_t *extra_attr, uart_buffer_config_t *uart_buffer_config)
初始化指定的串口。
Definition uart.c:470
errcode_t uapi_uart_flush_rx_data(uart_bus_t bus)
刷新UART接收Buffer中的数据。
errcode_t uapi_uart_set_attr(uart_bus_t bus, const uart_attr_t *attr)
设置串口的基础配置参数。
Definition uart.c:557
errcode_t uapi_uart_register_frame_error_callback(uart_bus_t bus, uart_error_callback_t callback)
注册帧错误处理回调函数。
Definition uart.c:642
void uapi_uart_unregister_rx_callback(uart_bus_t bus)
去注册接收回调函数。
Definition uart.c:1483
errcode_t uapi_uart_write_int(uart_bus_t bus, const uint8_t *buffer, uint32_t length, void *params, uart_tx_callback_t finished_with_buffer_func)
使用中断模式将数据发送到已经打开的UART上,当数据发送完成,会调用回调函数。
Definition uart.c:721
enum uart_rx_condition uart_rx_condition_t
UART在数据接收的时候触发回调的条件定义。
hal_uart_data_bit_t uart_data_bit_t
UART停止位定义。
Definition uart.h:50
bool uapi_uart_tx_fifo_is_empty(uart_bus_t bus)
判断TX FIFO是否为空。
Definition uart.c:1467
uart_rx_condition
UART在数据接收的时候触发回调的条件定义。
Definition uart.h:169
errcode_t uapi_uart_resume(uintptr_t arg)
恢复所有的UART通道。
Definition uart.c:1144
@ UART_RX_CONDITION_FULL_OR_SUFFICIENT_DATA
Definition uart.h:183
@ UART_RX_CONDITION_FULL_OR_IDLE
Definition uart.h:175
@ UART_RX_CONDITION_FULL_OR_SUFFICIENT_DATA_OR_IDLE
Definition uart.h:190
enum hal_uart_stop_bit hal_uart_stop_bit_t
UART停止位定义
hal_uart_flow_ctrl_t
Definition of UART Flow Control.
Definition hal_uart.h:235
enum hal_uart_data_bit hal_uart_data_bit_t
UART数据位定义
enum hal_uart_parity hal_uart_parity_t
UART奇偶校验位定义
UART的PIN配置数据结构定义
Definition hal_uart.h:37
UART基础配置参数定义
Definition hal_uart.h:250
UART 缓存数据结构定义。
Definition uart.h:149
void * rx_buffer
Definition uart.h:150
size_t rx_buffer_size
Definition uart.h:152
UART扩展配置参数定义
Definition hal_uart.h:270
UART DMA配置数据结构定义。
Definition uart.h:105
uint8_t burst_length
Definition uart.h:124
uint8_t priority
Definition uart.h:137
uint8_t src_width
Definition uart.h:106
uint8_t dest_width
Definition uart.h:115
unsigned int uintptr_t
Definition td_type.h:65