实现基本串口回传
This commit is contained in:
131
app/drivers/sertrf/device.h
Normal file
131
app/drivers/sertrf/device.h
Normal file
@@ -0,0 +1,131 @@
|
||||
#pragma once
|
||||
|
||||
#include "../data_port/uart/uart_port.h"
|
||||
#include "../data_port/sb_data_port.h"
|
||||
#include "../data_port/ble_spp/ble_spp_server.h"
|
||||
#include "../data_port/ble_spp/ble_spp_client.h"
|
||||
#include "../data_port/socket_inet/socket_inet_server_shell.h"
|
||||
#include "../data_port/socket_inet/wifi.h"
|
||||
#include "sys_log.h"
|
||||
|
||||
#define UART_ENABLE 1
|
||||
#define BLE_ENABLE 0
|
||||
#define WIFI_ENABLE 0
|
||||
|
||||
enum DEVICE_ERROR
|
||||
{
|
||||
DEVICE_OK = 0,
|
||||
DEVICE_UART_ERROR,
|
||||
DEVICE_BLE_ERROR,
|
||||
DEVICE_WIFI_ERROR,
|
||||
DEVICE_EMBEDDED_ERROR,
|
||||
DEVICE_PC_ERROR,
|
||||
|
||||
DEVICE_WRN_EMBEDDED_TYPE = 110,
|
||||
DEVICE_WRN_PC_TYPE
|
||||
|
||||
};
|
||||
enum DATA_PORT_TYPE
|
||||
{
|
||||
DATA_PORT_TYPE_UART = 1,
|
||||
DATA_PORT_TYPE_WIFI,
|
||||
DATA_PORT_TYPE_BLE_CMD,
|
||||
DATA_PORT_TYPE_BLE_VAL
|
||||
};
|
||||
typedef struct
|
||||
{
|
||||
sb_data_port_t* uart_port;
|
||||
sb_data_port_t* ble_spp_server_cmd;
|
||||
sb_data_port_t* ble_spp_server_val;
|
||||
sb_data_port_t* ble_spp_client_cmd;
|
||||
sb_data_port_t* ble_spp_client_val;
|
||||
sb_data_port_t* wifi;
|
||||
}init_device_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t embedded_device_type;
|
||||
uint8_t pc_device_type;
|
||||
sb_data_port_t* embedded_device;
|
||||
sb_data_port_t* pc_device;
|
||||
init_device_t init_device;
|
||||
|
||||
// int (*embedded_read)(device_t *port, void *buffer, uint32_t length);
|
||||
// int (*embedded_write)(device_t *port, const void *data, uint32_t size);
|
||||
|
||||
|
||||
}device_t;
|
||||
|
||||
/**
|
||||
* @brief 初始化设备
|
||||
*
|
||||
* @param port 由对应的驱动提供的绑定接口获得的句柄
|
||||
* @retval 0 成功
|
||||
*/
|
||||
uint8_t device_init(device_t *port);
|
||||
/**
|
||||
* @brief UART 初始化
|
||||
*
|
||||
* @param port 由对应的驱动提供的绑定接口获得的句柄
|
||||
* @retval 0 成功
|
||||
*/
|
||||
uint8_t uart_init(init_device_t *port);
|
||||
/**
|
||||
* @brief 蓝牙 初始化
|
||||
*
|
||||
* @param port 由对应的驱动提供的绑定接口获得的句柄
|
||||
* @retval 0 成功
|
||||
*/
|
||||
uint8_t ble_init(init_device_t *port);
|
||||
/**
|
||||
* @brief WIFI 初始化
|
||||
*
|
||||
* @param port 由对应的驱动提供的绑定接口获得的句柄
|
||||
* @retval 0 成功
|
||||
*/
|
||||
uint8_t wifi_init(init_device_t *port);
|
||||
/**
|
||||
* @brief 嵌入式设备数据接口
|
||||
*
|
||||
* @param port 由对应的驱动提供的绑定接口获得的句柄
|
||||
* @param type 对应的数据接口类型
|
||||
* @retval 0 成功
|
||||
*/
|
||||
uint8_t embedded_device_choice(device_t *port, uint8_t type);
|
||||
/**
|
||||
* @brief PC OR 手机数据接口
|
||||
*
|
||||
* @param port 由对应的驱动提供的绑定接口获得的句柄
|
||||
* @param type 对应的数据接口类型
|
||||
* @retval 0 成功
|
||||
*/
|
||||
uint8_t pc_device_choice(device_t *port, uint8_t type);
|
||||
/**
|
||||
* @brief 嵌入式设备数据接口读操作
|
||||
*
|
||||
* @param port 由对应的驱动提供的绑定接口获得的句柄
|
||||
* @param buffer 读取数据缓存
|
||||
* @param length 读取数据长度
|
||||
* @retval < 0 操作失败或在指定的时间内未满足指定的操作长度
|
||||
* @retval >= 0 实际已缓存的长度
|
||||
*/
|
||||
int embedded_device_read(device_t *port, void *buffer, uint32_t length);
|
||||
/**
|
||||
* @brief 嵌入式设备数据接口写操作
|
||||
*
|
||||
* @param port 由对应的驱动提供的绑定接口获得的句柄
|
||||
* @param data 写入数据
|
||||
* @param size 写入数据长度
|
||||
* @retval < 0 操作失败或在指定的时间内未满足指定的操作长度
|
||||
* @retval >= 0 实际已缓存的长度
|
||||
*/
|
||||
int embedded_device_write(device_t *port, void *buffer, uint32_t length);
|
||||
/**
|
||||
* @brief 嵌入式设备数据接口写操作
|
||||
*
|
||||
* @param port 由对应的驱动提供的绑定接口获得的句柄
|
||||
* @param data 写入数据
|
||||
* @param size 写入数据长度
|
||||
* @retval 缓存中可读取的字节数
|
||||
*/
|
||||
uint32_t embedded_device_get_rx_length(device_t *port);
|
||||
Reference in New Issue
Block a user