micro_climate/App/Inc/frt_protocol.h

127 lines
4.6 KiB
C
Raw Normal View History

2024-07-05 03:52:43 +00:00
#ifndef _FRT_PROTOCOL_H_
#define _FRT_PROTOCOL_H_
#include "uart_dev.h"
#include "pdebug.h"
#include "timer.h"
#include "comm_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/* <20><><EFBFBD><EFBFBD>ͨ΢<CDA8><CEA2><EFBFBD><EFBFBD>modbus<75><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><D0AD> */
/* <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_MIN_WIND_DIRECTION = 0, /* <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD> */
FRT_REGISTER_AVERAGE_WIND_DIRECTION = 1, /* ƽ<><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
FRT_REGISTER_MAX_WIND_DIRECTION = 2, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
FRT_REGISTER_MIN_WIND_SPEED = 3, /* <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD> */
FRT_REGISTER_AVERAGE_WIND_SPEED = 4, /* ƽ<><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
FRT_REGISTER_MAX_WIND_SPEED = 5, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
FRT_REGISTER_TEMPERATURE = 6, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
FRT_REGISTER_HUMIDITY = 7, /* <20><><EFBFBD><EFBFBD>ʪ<EFBFBD><CAAA> */
FRT_REGISTER_PRESSURE = 8, /* <20><><EFBFBD><EFBFBD>ѹ */
FRT_REGISTER_RAIN = 9, /* <20><><EFBFBD><EFBFBD> */
FRT_REGISTER_PRECIPITATION_INTENSITY = 10, /* <20>ܷ<EFBFBD><DCB7><EFBFBD> */
2024-07-05 03:52:43 +00:00
FRT_REGISTER_DEVICE_ADDR = 20, /* <20><EFBFBD><E8B1B8>ַ */
FRT_REGISTER_COMMU_BAUDRATE = 21, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
FRT_REGISTER_SPEED_AVERAGE_TIME = 22, /* <20><><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD>ʱ<EFBFBD><CAB1> */
FRT_REGISTER_TEMPHUM_UPDATE_TIME = 23, /* <20><>ʪ<EFBFBD>ȸ<EFBFBD><C8B8><EFBFBD>ʱ<EFBFBD><CAB1> */
FRT_REGISTER_RAIN_POWER_CONTROL = 24, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD> */
FRT_REGISTER_RAIN_REST = 25, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ */
FRT_REGISTER_SOFT_REST = 26, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ */
FRT_REGISTER_REST_DEFAULT_SETTING = 27, /* <20>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
FRT_REGISTER_PROTOCOL_SETTING = 28, /* <20><><EFBFBD><EFBFBD>Э<EFBFBD><D0AD>:0-ASCII;1-MODBUSЭ<53><D0AD> */
2024-11-19 09:56:39 +00:00
FRT_REGISTER_TRANSDUCER_CFG_1R5 = 30, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
FRT_REGISTER_TRANSDUCER_CFG_4R5 = 31, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
FRT_REGISTER_TRANSDUCER_CFG_8R0 = 32, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
FRT_REGISTER_RSSI_RANGE = 33, /* RSSI<53><49>Ч<EFBFBD><D0A7>Χ */
FRT_REGISTER_DISTANCE = 34, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
2024-11-19 09:56:39 +00:00
FRT_REGISTER_ERROR_LOG = 35, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־ */
FRT_REGISTER_WIND_C = 36, /* <20><><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5>ķ<EFBFBD><C4B7><EFBFBD> */
FRT_REGISTER_LINEAR_POINT_X_1 = 37, /* <20><><EFBFBD>Բ<EFBFBD>ֵԭʼ<D4AD><CABC>1 */
FRT_REGISTER_LINEAR_POINT_X_2 = 38, /* <20><><EFBFBD>Բ<EFBFBD>ֵԭʼ<D4AD><CABC>2 */
FRT_REGISTER_LINEAR_POINT_X_3 = 39, /* <20><><EFBFBD>Բ<EFBFBD>ֵԭʼ<D4AD><CABC>3 */
FRT_REGISTER_LINEAR_POINT_X_4 = 40, /* <20><><EFBFBD>Բ<EFBFBD>ֵԭʼ<D4AD><CABC>4 */
FRT_REGISTER_LINEAR_POINT_X_5 = 41, /* <20><><EFBFBD>Բ<EFBFBD>ֵԭʼ<D4AD><CABC>5 */
FRT_REGISTER_LINEAR_POINT_Y_1 = 42, /* <20><><EFBFBD>Բ<EFBFBD>ֵУ׼<D0A3><D7BC>1 */
FRT_REGISTER_LINEAR_POINT_Y_2 = 43, /* <20><><EFBFBD>Բ<EFBFBD>ֵУ׼<D0A3><D7BC>2 */
FRT_REGISTER_LINEAR_POINT_Y_3 = 44, /* <20><><EFBFBD>Բ<EFBFBD>ֵУ׼<D0A3><D7BC>3 */
FRT_REGISTER_LINEAR_POINT_Y_4 = 45, /* <20><><EFBFBD>Բ<EFBFBD>ֵУ׼<D0A3><D7BC>4 */
FRT_REGISTER_LINEAR_POINT_Y_5 = 46, /* <20><><EFBFBD>Բ<EFBFBD>ֵУ׼<D0A3><D7BC>5 */
FRT_REGISTER_LINEAR_ENABLE = 47, /* <20><><EFBFBD>Բ<EFBFBD>ֵʹ<D6B5><CAB9> */
2024-07-05 03:52:43 +00:00
}FRT_MsgRegister;
#pragma pack(push,1)
typedef struct _frt_climate_pack{
2024-07-05 04:00:38 +00:00
unsigned char addr;
2024-07-05 03:52:43 +00:00
unsigned char func;
unsigned char addr_begin_high_byte;
unsigned char addr_begin_low_byte;
unsigned char regnum_begin_high_byte;
unsigned char regnum_begin_low_byte;
unsigned char crc_low_byte;
unsigned char crc_high_byte;
}frt_climate_pack;
2024-07-05 04:00:38 +00:00
typedef struct _frt_climate_pack_write{
unsigned char addr;
unsigned char func;
unsigned char addr_begin_high_byte;
unsigned char addr_begin_low_byte;
unsigned char regnum_begin_high_byte;
unsigned char regnum_begin_low_byte;
unsigned char byte_num;
unsigned char *reg_val;
unsigned char crc_low_byte;
unsigned char crc_high_byte;
}frt_climate_pack_write;
2024-07-05 03:52:43 +00:00
#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))
2024-07-05 03:52:43 +00:00
typedef struct _frt_climate_pack_resp{
unsigned char addr;
2024-07-05 03:52:43 +00:00
unsigned char func;
unsigned char data_len;
unsigned char data[1];
2024-07-05 03:52:43 +00:00
}frt_climate_pack_resp;
typedef void (*MsgProcFunc)(device_handle device, void*);
2024-07-05 03:52:43 +00:00
/* <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*);
2024-07-05 03:52:43 +00:00
/* <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
typedef struct _FRT_RegProcTable_s{
u_int32_t regId;
RegProcFunc pRegProc;
} FRT_RegProcTable_s;
void read_and_process_uart_data(device_handle uart_handle);
#pragma pack(pop)
#ifdef __cplusplus
}
#endif
#endif