micro_climate/App/Inc/jxct_protocol.h

90 lines
2.9 KiB
C
Raw Permalink Normal View History

2024-07-05 03:52:43 +00:00
#ifndef _JXCT_PROTOCOL_H_
#define _JXCT_PROTOCOL_H_
#include "uart_dev.h"
#include "pdebug.h"
#include "timer.h"
#include "comm_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/* <20><>Ѷ<EFBFBD><D1B6>ͨ<EFBFBD><CDA8><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> */
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> */
}FRT_MsgRegister;
#pragma pack(push,1)
typedef struct _frt_climate_pack{
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 crc_low_byte;
unsigned char crc_high_byte;
}frt_climate_pack;
#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))
typedef struct _frt_climate_pack_resp{
unsigned char addr;
unsigned char func;
unsigned char data_len;
unsigned char data[1];
}frt_climate_pack_resp;
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;
void read_and_process_uart_data(device_handle uart_handle);
#pragma pack(pop)
#ifdef __cplusplus
}
#endif
#endif