WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
hal_uart.h
浏览该文件的文档.
1
9#ifndef HAL_UART_H
10#define HAL_UART_H
11
12#include <stdint.h>
13#include <stdbool.h>
14#include "common_def.h"
15#include "errcode.h"
16#include "uart_porting.h"
17
18#ifdef __cplusplus
19#if __cplusplus
20extern "C" {
21#endif /* __cplusplus */
22#endif /* __cplusplus */
23
47
65
81
95
112
120typedef enum {
121 UART_FIFO_INT_TX_LEVEL_EQ_0_CHARACTER = 0, // only for uart v100 and v151
122 UART_FIFO_INT_TX_LEVEL_1_8 = 0, // only for uart v120
123 UART_FIFO_INT_TX_LEVEL_EQ_2_CHARACTER = 1, // only for uart v100 and v151
126 UART_FIFO_INT_TX_LEVEL_3_4 = 4, // only for uart v120
127 UART_FIFO_INT_TX_LEVEL_7_8 = 5, // only for uart v120
129
192
216
231
242
250typedef struct uart_attr {
251 uint32_t baud_rate;
253 uint8_t data_bits;
255 uint8_t stop_bits;
257 uint8_t parity;
259 uint8_t flow_ctrl;
262
270typedef struct uart_extra_attr {
283#if defined(CONFIG_UART_SUPPORT_RX_THREAD)
284 bool rx_thread_enable;
286#endif
288
307
330 const hal_uart_attr_t *attr, hal_uart_flow_ctrl_t flow_ctrl,
331 hal_uart_extra_attr_t *extra_attr);
346
365
383typedef errcode_t (*hal_uart_write_t)(uart_bus_t bus, const uint8_t *data, uint16_t len);
384
402typedef int32_t (*hal_uart_read_t)(uart_bus_t bus, const uint8_t *data, uint16_t len);
403
415typedef void (*hal_uart_dma_cfg_t)(uart_bus_t bus, const hal_uart_extra_attr_t *extra_attr);
416
438
455
470
483
498
511
524
537
560 const hal_uart_attr_t *attr, hal_uart_flow_ctrl_t flow_ctrl, hal_uart_extra_attr_t *extra_attr);
575
594
612errcode_t hal_uart_write(uart_bus_t bus, const uint8_t *data, uint16_t len);
613
631int32_t hal_uart_read(uart_bus_t bus, const uint8_t *data, uint16_t len);
632
644void hal_uart_set_dma_config(uart_bus_t bus, const hal_uart_extra_attr_t *extra_attr);
645
650#ifdef __cplusplus
651#if __cplusplus
652}
653#endif /* __cplusplus */
654#endif /* __cplusplus */
655
656#endif
uart_bus_t
UART bus.
Definition platform_core.h:198
pin_t
Definition of pin.
Definition platform_core_rom.h:30
uint32_t errcode_t
Definition of error code.
Definition errcode.h:30
uart_fifo_rx_int_lvl_t
HAL层UART触发RX中断水线定义
Definition hal_uart.h:103
errcode_t(* hal_uart_callback_t)(uart_bus_t bus, hal_uart_evt_id_t evt, uintptr_t param)
UART的回调函数
Definition hal_uart.h:306
uintptr_t hal_uart_base_addrs_get(uart_bus_t bus)
获取指定UART的基地址。
Definition hal_uart.c:19
hal_uart_dma_process_t
DMA处理类型定义
Definition hal_uart.h:224
enum hal_uart_evt_id hal_uart_evt_id_t
HAL层UART事件ID的定义
hal_uart_stop_bit
UART停止位定义
Definition hal_uart.h:89
hal_uart_evt_id
HAL层UART事件ID的定义
Definition hal_uart.h:200
enum hal_uart_stop_bit hal_uart_stop_bit_t
UART停止位定义
errcode_t(* hal_uart_init_t)(uart_bus_t bus, hal_uart_callback_t callback, const hal_uart_pin_config_t *pins, const hal_uart_attr_t *attr, hal_uart_flow_ctrl_t flow_ctrl, hal_uart_extra_attr_t *extra_attr)
HAL层UART的初始化接口
Definition hal_uart.h:329
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_ctrl_id hal_uart_ctrl_id_t
UART控制ID定义
hal_uart_funcs_t * hal_uart_get_funcs(uart_bus_t bus)
获取Driver层UART和HAL层UART的接口实例,参考 hal_uart_funcs_t.
Definition hal_uart.c:51
errcode_t hal_uart_ctrl(uart_bus_t bus, hal_uart_ctrl_id_t id, uintptr_t param)
HAL层UART控制接口
Definition hal_uart.c:107
hal_uart_parity
UART奇偶校验位定义
Definition hal_uart.h:73
errcode_t(* hal_uart_deinit_t)(uart_bus_t bus)
HAL层UART去初始化接口
Definition hal_uart.h:345
errcode_t hal_uart_write(uart_bus_t bus, const uint8_t *data, uint16_t len)
HAL层UART发送数据接口
Definition hal_uart.c:95
void(* hal_uart_dma_cfg_t)(uart_bus_t bus, const hal_uart_extra_attr_t *extra_attr)
HAL层配置DMA传输接口
Definition hal_uart.h:415
struct uart_extra_attr hal_uart_extra_attr_t
UART扩展配置参数定义
int32_t hal_uart_read(uart_bus_t bus, const uint8_t *data, uint16_t len)
HAL层UART读取数据接口
Definition hal_uart.c:101
uart_fifo_tx_int_lvl_t
HAL层UART触发TX中断水线定义
Definition hal_uart.h:120
hal_uart_data_bit
UART数据位定义
Definition hal_uart.h:55
hal_uart_ctrl_id
UART控制ID定义
Definition hal_uart.h:137
errcode_t hal_uart_deinit(uart_bus_t bus)
HAL层UART去初始化接口
Definition hal_uart.c:89
errcode_t hal_uart_set_tx_fifo_int_level(uart_bus_t bus, uart_fifo_tx_int_lvl_t level)
设置uart触发中断的发送fifo阈值
Definition hal_uart.c:68
errcode_t hal_uart_regs_init(uart_bus_t bus)
初始化UART,设置寄存器的基地址
Definition hal_uart.c:24
struct uart_attr hal_uart_attr_t
UART基础配置参数定义
void hal_uart_set_dma_config(uart_bus_t bus, const hal_uart_extra_attr_t *extra_attr)
HAL层配置DMA传输接口
Definition hal_uart.c:117
errcode_t hal_uart_register_funcs(uart_bus_t bus, hal_uart_funcs_t *funcs)
注册 hal_uart_funcs_t 到 g_hal_uarts_funcs
Definition hal_uart.c:33
errcode_t hal_uart_unregister_funcs(uart_bus_t bus)
从g_hal_uarts_funcs注销 hal_uart_funcs_t
Definition hal_uart.c:42
enum hal_uart_parity hal_uart_parity_t
UART奇偶校验位定义
int32_t(* hal_uart_read_t)(uart_bus_t bus, const uint8_t *data, uint16_t len)
HAL层UART读取数据接口
Definition hal_uart.h:402
errcode_t hal_uart_init(uart_bus_t bus, hal_uart_callback_t callback, const hal_uart_pin_config_t *pins, const hal_uart_attr_t *attr, hal_uart_flow_ctrl_t flow_ctrl, hal_uart_extra_attr_t *extra_attr)
HAL层UART的初始化接口
Definition hal_uart.c:77
errcode_t(* hal_uart_write_t)(uart_bus_t bus, const uint8_t *data, uint16_t len)
HAL层UART发送数据接口
Definition hal_uart.h:383
errcode_t hal_uart_set_rx_fifo_int_level(uart_bus_t bus, uart_fifo_rx_int_lvl_t level)
设置uart触发接收中断的接收fifo阈值
Definition hal_uart.c:59
errcode_t(* hal_uart_ctrl_t)(uart_bus_t bus, hal_uart_ctrl_id_t id, uintptr_t param)
HAL层UART控制接口
Definition hal_uart.h:364
@ UART_FIFO_INT_RX_LEVEL_1_4
Definition hal_uart.h:106
@ UART_FIFO_INT_RX_LEVEL_1_CHARACTER
Definition hal_uart.h:104
@ UART_FIFO_INT_RX_LEVEL_1_8
Definition hal_uart.h:105
@ UART_FIFO_INT_RX_LEVEL_7_8
Definition hal_uart.h:110
@ UART_FIFO_INT_RX_LEVEL_2_LESS_THAN_FULL
Definition hal_uart.h:108
@ UART_FIFO_INT_RX_LEVEL_3_4
Definition hal_uart.h:109
@ UART_FIFO_INT_RX_LEVEL_1_2
Definition hal_uart.h:107
@ UART_DMA_PROCESS_FINISH
Definition hal_uart.h:227
@ UART_DMA_PROCESS_PREPARE
Definition hal_uart.h:225
@ UART_DMA_PROCESS_INVALID
Definition hal_uart.h:229
@ UART_STOP_BIT_2
Definition hal_uart.h:92
@ UART_STOP_BIT_1
Definition hal_uart.h:90
@ UART_EVT_TX_ISR
Definition hal_uart.h:203
@ UART_EVT_BREAK_ERR_ISR
Definition hal_uart.h:211
@ UART_EVT_OVERRUN_ERR_ISR
Definition hal_uart.h:213
@ UART_EVT_PARITY_ERR_ISR
Definition hal_uart.h:207
@ UART_EVT_FRAME_ERR_ISR
Definition hal_uart.h:209
@ UART_EVT_IDLE_ISR
Definition hal_uart.h:205
@ UART_EVT_RX_ISR
Definition hal_uart.h:201
@ UART_FLOW_CTRL_SOFT
Definition hal_uart.h:240
@ UART_FLOW_CTS
Definition hal_uart.h:237
@ UART_FLOW_CTRL_NONE
Definition hal_uart.h:236
@ UART_FLOW_RTS
Definition hal_uart.h:238
@ UART_FLOW_CTRL_RTS_CTS
Definition hal_uart.h:239
@ UART_PARITY_NONE
Definition hal_uart.h:74
@ UART_PARITY_EVEN
Definition hal_uart.h:78
@ UART_PARITY_ODD
Definition hal_uart.h:76
@ UART_FIFO_INT_TX_LEVEL_EQ_0_CHARACTER
Definition hal_uart.h:121
@ UART_FIFO_INT_TX_LEVEL_1_2
Definition hal_uart.h:125
@ UART_FIFO_INT_TX_LEVEL_7_8
Definition hal_uart.h:127
@ UART_FIFO_INT_TX_LEVEL_EQ_2_CHARACTER
Definition hal_uart.h:123
@ UART_FIFO_INT_TX_LEVEL_3_4
Definition hal_uart.h:126
@ UART_FIFO_INT_TX_LEVEL_1_4
Definition hal_uart.h:124
@ UART_FIFO_INT_TX_LEVEL_1_8
Definition hal_uart.h:122
@ UART_DATA_BIT_8
Definition hal_uart.h:62
@ UART_DATA_BIT_7
Definition hal_uart.h:60
@ UART_DATA_BIT_5
Definition hal_uart.h:56
@ UART_DATA_BIT_6
Definition hal_uart.h:58
@ UART_CTRL_SUSPEND
Definition hal_uart.h:179
@ UART_CTRL_CHECK_UART_BUSY
Definition hal_uart.h:174
@ UART_CTRL_MAX
Definition hal_uart.h:189
@ UART_CTRL_CHECK_TX_FIFO_FULL
Definition hal_uart.h:154
@ UART_CTRL_ID_INVALID
Definition hal_uart.h:190
@ UART_CTRL_EN_PARITY_ERR_INT
Definition hal_uart.h:150
@ UART_CTRL_EN_FRAME_ERR_INT
Definition hal_uart.h:152
@ UART_CTRL_GET_RX_FIFO_THRESHOLD
Definition hal_uart.h:187
@ UART_CTRL_EN_TX_INT
Definition hal_uart.h:143
@ UART_CTRL_GET_REG_ADDRS
Definition hal_uart.h:166
@ UART_CTRL_EN_IDLE_INT
Definition hal_uart.h:148
@ UART_CTRL_RESTORE
Definition hal_uart.h:172
@ UART_CTRL_GET_RX_FIFO_PASSNUM
Definition hal_uart.h:176
@ UART_CTRL_CHECK_RX_FIFO_EMPTY
Definition hal_uart.h:158
@ UART_CTRL_SET_TX_FIFO_LEVEL
Definition hal_uart.h:164
@ UART_CTRL_SET_RX_FIFO_LEVEL
Definition hal_uart.h:162
@ UART_CTRL_RESUME
Definition hal_uart.h:181
@ UART_CTRL_GET_ATTR
Definition hal_uart.h:140
@ UART_CTRL_EN_RX_INT
Definition hal_uart.h:146
@ UART_CTRL_SET_ATTR
Definition hal_uart.h:138
@ UART_CTRL_FIFO_ENABLE
Definition hal_uart.h:160
@ UART_CTRL_GET_DMA_DATA_ADDR
Definition hal_uart.h:185
@ UART_CTRL_FLOW_CTRL
Definition hal_uart.h:170
@ UART_CTRL_CHECK_TX_BUSY
Definition hal_uart.h:156
@ UART_CTRL_TX_DMA_PROCESS
Definition hal_uart.h:168
Driver层UART和HAL层UART的接口
Definition hal_uart.h:424
hal_uart_ctrl_t ctrl
Definition hal_uart.h:429
hal_uart_write_t write
Definition hal_uart.h:431
hal_uart_init_t init
Definition hal_uart.h:425
hal_uart_deinit_t deinit
Definition hal_uart.h:427
hal_uart_dma_cfg_t dma_cfg
Definition hal_uart.h:435
hal_uart_read_t read
Definition hal_uart.h:433
UART的PIN配置数据结构定义
Definition hal_uart.h:37
pin_t cts_pin
Definition hal_uart.h:42
pin_t tx_pin
Definition hal_uart.h:38
pin_t rx_pin
Definition hal_uart.h:40
pin_t rts_pin
Definition hal_uart.h:44
UART基础配置参数定义
Definition hal_uart.h:250
uint8_t data_bits
Definition hal_uart.h:253
uint8_t stop_bits
Definition hal_uart.h:255
uint8_t parity
Definition hal_uart.h:257
uint32_t baud_rate
Definition hal_uart.h:251
uint8_t flow_ctrl
Definition hal_uart.h:259
UART扩展配置参数定义
Definition hal_uart.h:270
uint8_t tx_int_threshold
Definition hal_uart.h:275
bool rx_dma_enable
Definition hal_uart.h:277
uint8_t rx_int_threshold
Definition hal_uart.h:281
bool tx_dma_enable
Definition hal_uart.h:271
unsigned int uintptr_t
Definition td_type.h:65
Definition hal_uart_v151_regs_def.h:38