72 lines
2.1 KiB
C
72 lines
2.1 KiB
C
/**
|
||
* @file hart.h
|
||
* @author: xxx
|
||
* @date: 2023-08-25 00:14:59
|
||
* @brief
|
||
* @copyright: Copyright (c) 2023 by xxx, All Rights Reserved.
|
||
*/
|
||
|
||
#ifndef _HART_H_
|
||
#define _HART_H_
|
||
#include "lib.h"
|
||
#include "flow.h"
|
||
#include "./hart_frame.h"
|
||
#include "hart_storage.h"
|
||
#define HART_INIT_FLAG (0x0520) ///< 初始化标志
|
||
#ifdef MASTER
|
||
#include "../master/inc/hart_master.h"
|
||
#endif
|
||
|
||
#ifdef SLAVE
|
||
#include "../slave/inc/hart_slave.h"
|
||
#endif
|
||
|
||
typedef enum
|
||
{
|
||
MODULE_MASTER = 1,
|
||
MODULE_SLAVE = 2,
|
||
} modul_e; // 模块工作模式
|
||
|
||
#pragma pack(1)
|
||
|
||
typedef struct
|
||
{
|
||
float32 timer_cycle;
|
||
// 计数器
|
||
uint16_t counter;
|
||
} hart_timer_interupt_t;
|
||
|
||
typedef struct
|
||
{
|
||
uint8_t hart_protocol_version; // hart协议版本号,传入模块初始化参数
|
||
uint8_t dir; // 1:master 2:slave; 模块工作模式,传入模块初始化参数
|
||
|
||
uint8_t master_address_bit; // 主机参数,为1时表示基本主设备,为0时表示副主设备,传入模块初始化参数
|
||
hart_interface_t interface; // 模块接口
|
||
hart_timer_interupt_t hart_timer; // 定时器周期计数器 ,用于HART测试
|
||
// 模块初始化参数,存放全局变量
|
||
union
|
||
{
|
||
#ifdef MASTER
|
||
hart_master_init_t _master;
|
||
#endif
|
||
|
||
#ifdef SLAVE
|
||
hart_slave_init_t _slave;
|
||
#endif
|
||
} hart_module_u;
|
||
|
||
} hart_init_t; // 模块初始化参数结构:hart_init
|
||
|
||
#pragma pack()
|
||
|
||
extern BOOL hart_init(const hart_init_t *const init); // 模块初始化接口
|
||
extern hart_init_t *hart_get_handle(void); // 获取模块初始化参数
|
||
extern BOOL hart_handle(uint8_t uart_index, uint8_t *rxBuf, uint16_t len); // 模块数据处理接口
|
||
extern void perform_self_test_finish(void); // 自检完成
|
||
extern void hart_cache_data_send(uint64_t uuid); // 缓存数据发送
|
||
extern void ble_send_cmd(uint8_t *cmd); // 发送蓝牙指令
|
||
extern BOOL get_device_lock(void); // 是否锁定装置
|
||
|
||
#endif
|