stm32l431_xl_current/App/Inc/frt_protocol.h

87 lines
2.4 KiB
C
Raw Normal View History

2024-07-15 09:07:44 +00:00
#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>ѹ */
2024-07-24 02:31:30 +00:00
uint8_t bat_charge; /* <20><><EFBFBD><EFBFBD>״̬ */
2024-07-15 09:07:44 +00:00
}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 = 0x00, /* й<><D0B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵmA */
FRT_REGISTER_MAX_CURRENT = 0x01, /* <20><><EFBFBD><EFBFBD>й©<D0B9><C2A9><EFBFBD><EFBFBD>ֵmA*/
FRT_REGISTER_PULSE_COUNT = 0x02, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
FRT_REGISTER_BAT_V = 0x03, /* <20><><EFBFBD>ص<EFBFBD>ѹ */
FRT_REGISTER_BAT_CHARGE = 0x04, /* <20><><EFBFBD><EFBFBD>״̬ */
FRT_REGISTER_MAC_INFO = 0x05, /* MAC<41><43>Ϣ */
2024-07-15 09:07:44 +00:00
FRT_REGISTER_DEVICE_ADDR = 0x31, /* <20><EFBFBD><E8B1B8>ַ */
FRT_REGISTER_NET_ID = 0x32, /* <20><><EFBFBD><EFBFBD>ID */
FRT_REGISTER_CLEAR_MAX_CURRENT = 0x33, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>й©<D0B9><C2A9><EFBFBD><EFBFBD> */
FRT_REGISTER_CLEAR_PULSE_COUNT = 0x34, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
FRT_REGISTER_REBOOT = 0x35, /* <20><><EFBFBD><EFBFBD> */
2024-07-15 09:07:44 +00:00
}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 up_addr_h;
unsigned char up_addr_l;
unsigned char chanel;
2024-07-15 09:07:44 +00:00
unsigned char addr;
unsigned char func;
unsigned char data_len;
unsigned char data[1];
}frt_climate_pack_resp;
2024-07-24 02:31:30 +00:00
//ȫ<>ֱ<EFBFBD><D6B1><EFBFBD>
extern mcs_para g_stMcs_Para;
2024-07-15 09:07:44 +00:00
void read_and_process_uart_data(device_handle uart_handle);
#ifdef __cplusplus
}
#endif
#endif