luat_soc_sdk_2024 V1.0
luat_uart.h
浏览该文件的文档.
1#ifndef LUAT_UART_H
2#define LUAT_UART_H
3
4#include "luat_base.h"
5#include "luat_uart_legacy.h"
31#define LUAT_PARITY_NONE 0
32#define LUAT_PARITY_ODD 1
33#define LUAT_PARITY_EVEN 2
38#define LUAT_BIT_ORDER_LSB 0
39#define LUAT_BIT_ORDER_MSB 1
44#define LUAT_0_5_STOP_BITS 0xf0
45#define LUAT_1_5_STOP_BITS 0xf1
47#define LUAT_VUART_ID_0 0x20
48
52typedef struct luat_uart {
53 int id;
56 uint8_t data_bits;
57 uint8_t stop_bits;
58 uint8_t bit_order;
59 uint8_t parity;
61 size_t bufsz;
62 uint32_t pin485;
63 uint32_t delay;
64 uint8_t rx_level;
66
74
83int luat_uart_write(int uart_id, void* data, size_t length);
84
93int luat_uart_read(int uart_id, void* buffer, size_t length);
94
99void luat_uart_clear_rx_cache(int uart_id);
100
107int luat_uart_close(int uart_id);
108
115int luat_uart_exist(int uart_id);
116
125
130typedef void (*luat_uart_recv_callback_t)(int uart_id, uint32_t data_len);
131
136typedef void (*luat_uart_sent_callback_t)(int uart_id, void *param);
137
147
156int luat_uart_ctrl(int uart_id, LUAT_UART_CTRL_CMD_E cmd, void* param);
157
165int luat_uart_pre_setup(int uart_id, uint8_t use_alt_type);
166
167#ifdef LUAT_USE_SOFT_UART
168#ifndef __BSP_COMMON_H__
169#include "c_common.h"
170#endif
178int luat_uart_soft_setup_hwtimer_callback(int hwtimer_id, CommonFun_t callback);
179void luat_uart_soft_gpio_fast_output(int pin, uint8_t value);
180uint8_t luat_uart_soft_gpio_fast_input(int pin);
181void luat_uart_soft_gpio_fast_irq_set(int pin, uint8_t onoff);
188uint32_t luat_uart_soft_cal_baudrate(uint32_t baudrate);
196void luat_uart_soft_hwtimer_onoff(int hwtimer_id, uint32_t period);
197
198void luat_uart_soft_sleep_enable(uint8_t is_enable);
199#endif
202#endif
int luat_uart_setup(luat_uart_t *uart)
uart初始化
struct luat_uart_ctrl_param luat_uart_ctrl_param_t
串口控制参数
enum LUAT_UART_CTRL_CMD LUAT_UART_CTRL_CMD_E
串口控制参数
int luat_uart_exist(int uart_id)
检测串口是否存在
int luat_uart_close(int uart_id)
关闭串口
int luat_uart_read(int uart_id, void *buffer, size_t length)
串口读数据
int luat_uart_ctrl(int uart_id, LUAT_UART_CTRL_CMD_E cmd, void *param)
串口控制
void(* luat_uart_sent_callback_t)(int uart_id, void *param)
发送回调函数
struct luat_uart luat_uart_t
luat_uart
int luat_uart_write(int uart_id, void *data, size_t length)
串口写数据
void luat_uart_clear_rx_cache(int uart_id)
清除uart的接收缓存数据
int luat_uart_pre_setup(int uart_id, uint8_t use_alt_type)
串口复用函数,目前支持UART0,UART2
LUAT_UART_CTRL_CMD
串口控制参数
void(* luat_uart_recv_callback_t)(int uart_id, uint32_t data_len)
接收回调函数
@ LUAT_UART_SET_RECV_CALLBACK
@ LUAT_UART_SET_SENT_CALLBACK
串口控制参数
luat_uart_sent_callback_t sent_callback_fun
luat_uart_recv_callback_t recv_callback_fun
luat_uart
uint32_t pin485
uint32_t delay
uint8_t rx_level
uint8_t data_bits
uint8_t parity
uint8_t bit_order
uint8_t stop_bits