82 lines
2.3 KiB
C
82 lines
2.3 KiB
C
|
#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; /* й<><D0B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵmA */
|
|||
|
float32_t max_current; /* <20><><EFBFBD><EFBFBD>й©<D0B9><C2A9><EFBFBD><EFBFBD>ֵmA */
|
|||
|
float32_t pulse_count; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
float32_t bat_v; /* <20><><EFBFBD>ص<EFBFBD>ѹ */
|
|||
|
float32_t bat_charge; /* <20><><EFBFBD><EFBFBD>״̬ */
|
|||
|
float32_t mac_info; /* MAC<41><43>Ϣ */
|
|||
|
}mcs_para;
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
FRT_FUNCTION_CODE_READ_REGISTER = 0x03, /* <20><><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD> */
|
|||
|
FRT_FUNCTION_CODE_WRITE_REGISTER = 0x10, /* д<>Ĵ<EFBFBD><C4B4><EFBFBD> */
|
|||
|
} FRT_MsgFunctionCode_e;
|
|||
|
|
|||
|
/* <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ */
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
FRT_REGISTER_CURRENT = 0, /* й<><D0B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵmA */
|
|||
|
FRT_REGISTER_MAX_CURRENT = 1, /* <20><><EFBFBD><EFBFBD>й©<D0B9><C2A9><EFBFBD><EFBFBD>ֵmA*/
|
|||
|
FRT_REGISTER_PULSE_COUNT = 2, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
FRT_REGISTER_BAT_V = 3, /* <20><><EFBFBD>ص<EFBFBD>ѹ */
|
|||
|
FRT_REGISTER_BAT_CHARGE = 4, /* <20><><EFBFBD><EFBFBD>״̬ */
|
|||
|
FRT_REGISTER_MAC_INFO = 5, /* MAC<41><43>Ϣ */
|
|||
|
|
|||
|
FRT_REGISTER_DEVICE_ADDR = 31, /* <20>豸<EFBFBD><E8B1B8>ַ */
|
|||
|
FRT_REGISTER_NET_ID = 32, /* <20><><EFBFBD><EFBFBD>ID */
|
|||
|
FRT_REGISTER_CLEAR_MAX_CURRENT = 33, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>й©<D0B9><C2A9><EFBFBD><EFBFBD> */
|
|||
|
FRT_REGISTER_CLEAR_PULSE_COUNT = 34, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
FRT_REGISTER_REBOOT = 35, /* <20><><EFBFBD><EFBFBD> */
|
|||
|
}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*);
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>봦<EFBFBD><EBB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
typedef struct _FRT_FunctionMsgProcTable_s{
|
|||
|
u_int32_t msgId;
|
|||
|
MsgProcFunc pMsgProc;
|
|||
|
} FRT_FuncionMsgProcTable_s;
|
|||
|
|
|||
|
typedef u_int16_t (*RegProcFunc)(void*);
|
|||
|
/* <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
typedef struct _FRT_RegProcTable_s{
|
|||
|
u_int32_t regId;
|
|||
|
RegProcFunc pRegProc;
|
|||
|
} FRT_RegProcTable_s;
|
|||
|
|
|||
|
typedef struct _frt_climate_pack_resp{
|
|||
|
unsigned char addr;
|
|||
|
unsigned char func;
|
|||
|
unsigned char data_len;
|
|||
|
unsigned char data[1];
|
|||
|
}frt_climate_pack_resp;
|
|||
|
|
|||
|
void read_and_process_uart_data(device_handle uart_handle);
|
|||
|
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
}
|
|||
|
#endif
|
|||
|
|
|||
|
#endif
|