#ifndef _FRT_PROTOCOL_H_ #define _FRT_PROTOCOL_H_ #include "uart_dev.h" #include "pdebug.h" #include "comm_types.h" #include "arm_math.h" #ifdef __cplusplus extern "C" { #endif typedef struct _mcs_para{ float32_t current; /* 泄流电流值mA */ float32_t max_current; /* 最大泄漏电流值mA */ float32_t pulse_count; /* 脉冲次数 */ float32_t bat_v; /* 电池电压 */ uint8_t bat_charge; /* 充电状态 */ }mcs_para; /* 功能码 */ typedef enum { FRT_FUNCTION_CODE_READ_REGISTER = 0x03, /* 读寄存器 */ FRT_FUNCTION_CODE_WRITE_REGISTER = 0x10, /* 写寄存器 */ } FRT_MsgFunctionCode_e; /* 寄存器地址 */ typedef enum { FRT_REGISTER_CURRENT = 0x00, /* 泄流电流值mA */ FRT_REGISTER_MAX_CURRENT = 0x01, /* 最大泄漏电流值mA*/ FRT_REGISTER_PULSE_COUNT = 0x02, /* 脉冲次数 */ FRT_REGISTER_BAT_V = 0x03, /* 电池电压 */ FRT_REGISTER_BAT_CHARGE = 0x04, /* 充电状态 */ FRT_REGISTER_MAC_INFO = 0x05, /* MAC信息 */ FRT_REGISTER_DEVICE_ADDR = 0x31, /* 设备地址 */ FRT_REGISTER_NET_ID = 0x32, /* 网络ID */ FRT_REGISTER_CLEAR_MAX_CURRENT = 0x33, /* 清空最大泄漏电流 */ FRT_REGISTER_CLEAR_PULSE_COUNT = 0x34, /* 清空脉冲次数 */ FRT_REGISTER_REBOOT = 0x35, /* 重启 */ }FRT_MsgRegister; #define FRT_CLIMATE_PACK_SIZE(x) (sizeof(frt_climate_pack)) #define FRT_CLIMATE_PACK_CRC16(x) ((x->crc_low_byte)|(x->crc_high_byte<<8)) #define FRT_CLIMATE_BUFF_CRC16(x) ((x[MsgLen - 2]) | (x[MsgLen - 1] << 8)) typedef void (*MsgProcFunc)(device_handle device, void*); /* 功能码处理函数 */ typedef struct _FRT_FunctionMsgProcTable_s{ u_int32_t msgId; MsgProcFunc pMsgProc; } FRT_FuncionMsgProcTable_s; typedef u_int16_t (*RegProcFunc)(void*); /* 寄存器处理表 */ typedef struct _FRT_RegProcTable_s{ u_int32_t regId; RegProcFunc pRegProc; } FRT_RegProcTable_s; typedef struct _frt_climate_pack_resp{ unsigned char up_addr_h; unsigned char up_addr_l; unsigned char chanel; unsigned char addr; unsigned char func; unsigned char data_len; unsigned char data[1]; }frt_climate_pack_resp; //全局变量 extern mcs_para g_stMcs_Para; void read_and_process_uart_data(device_handle uart_handle); #ifdef __cplusplus } #endif #endif