micro_climate/App/Inc/com.h

87 lines
2.7 KiB
C
Raw Normal View History

2024-07-05 03:52:43 +00:00
#ifndef COM_H_
#define COM_H_
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
//<2F><EFBFBD><EAB6A8>
#define COMMAND_TYPE_SET_ADDR 1 //<2F>趨װ<E8B6A8>õ<EFBFBD>ַ
#define COMMAND_TYPE_SCAN_ADDR 2 //<2F><>ѯװ<D1AF>õ<EFBFBD>ַ
#define COMMAND_TYPE_GETDATA 5 //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
#define COMMAND_TYPE_GET_WORKMODE 11 //<2F><>ѯ<EFBFBD><D1AF><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>ģʽ
#define COMMAND_TYPE_SET_WORKMODE 12 //<2F><EFBFBD><E8B6A8><EFBFBD>ݴ<EFBFBD><DDB4>ͷ<EFBFBD>ʽ<EFBFBD><CABD>1<EFBFBD><31><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define COMMAND_TYPE_SCALE 13 //У<><D0A3>
#define COMMAND_TYPE_CALL_ORIGINALVALUE 14 //<2F><>ԭʼֵ
#define COMMAND_TYPE_SCALE_RESET 15 //<2F><><EFBFBD><EFBFBD>У<EFBFBD><D0A3>
#define COMMAND_TYPE_CALLINFO 16 //<2F><>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>Ϣ
#define FRAME_HEAD_L 0 //֡ͷ<D6A1><CDB7><EFBFBD>ֽ<EFBFBD>
#define FRAME_HEAD_H 1 //֡ͷ<D6A1><CDB7><EFBFBD>ֽ<EFBFBD>
#define FRAME_LENGTH_L 2 //֡<><D6A1><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
#define FRAME_LENGTH_H 3 //֡<><D6A1><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
#define FRAME_DEVICE_TYPE 4 //װ<><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define FRAME_DEVICE_ADDR 5 //װ<>õ<EFBFBD>ַ
#define FRAME_TYPE 6 //֡<><D6A1><EFBFBD><EFBFBD>
#define FRAME_CMD_TYPE 7 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define FRAME_DATE_START 8 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ
#define FRAME_HEAD_LEN 9 //֡ͷ<D6A1>̶<EFBFBD><CCB6><EFBFBD><EFBFBD>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD>CRCУ<43><D0A3><EFBFBD><EFBFBD>
#define SENDBUFFER_LEN 256 //<2F><><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define SENDDATA_LEN_MAX (SENDBUFFER_LEN - FRAME_HEAD_LEN) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󳤶<EFBFBD>
#define ASDU_MUN 32 //<2F><><EFBFBD><EFBFBD><E0BBBA>32<33><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡
#define ASDU_LEN_MAX 20
//<2F><><EFBFBD>ݽṹ
typedef struct{
DT_UINT8 WriteIP; //дָ<D0B4><D6B8>
DT_UINT8 ReadIP; //<2F><>ָ<EFBFBD><D6B8>
DT_UINT8 Lock;
DT_UINT8 AsduFrame[ASDU_MUN][ASDU_LEN_MAX]; //<2F><><EFBFBD><EFBFBD><EEBBBA><EFBFBD><EFBFBD>
}tagComDataRecv;
//<2F>ⲿ<EFBFBD>ӿ<EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void Handle_upSend_Data(unsigned char *pFrame);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void UpSendDataActive(void);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD>
void CheckComData(void);
void Com_SendData(unsigned char *pDataBuffer,unsigned int dataLen,unsigned char addr,unsigned char cmdtype);
//<2F><><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD><EFBFBD>Ľӿ<C4BD>
//<2F>̻<EFBFBD><CCBB><EFBFBD><EFBFBD><EFBFBD>
extern void Write_App_Params(void);
//<2F><>ȡ<EFBFBD><EFBFBD><E8B6A8><EFBFBD><EFBFBD>
extern void Read_App_Params(void);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
extern void UART_Send(unsigned char *pBuffer, unsigned int Length);
//<2F><><EFBFBD>õ<EFBFBD>ַ
extern void SetAddress(unsigned char addr);
//<2F><>ȡ<EFBFBD><C8A1>ַ
extern unsigned char ReadAddress(void);
//<2F><>ȡ<EFBFBD>Ƕȼ<C7B6><C8BC><EFBFBD>ֵ
extern int GetAngleMeasureValue(float *pAngle_X,float *pAngle_Y,float *pAngle_Z);
//<2F>Ƕ<EFBFBD>У<EFBFBD><D0A3>
extern void AngleScale(void);
//<2F><>λ<EFBFBD>Ƕ<EFBFBD>У<EFBFBD><D0A3>
extern void AngleScale_Reset(void);
//<2F><>ʼ<EFBFBD><CABC>ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>
extern void StartWave(unsigned char object);
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
extern void ReadWorkMode(unsigned char *workMode, unsigned short *upSendFreq);
//<2F><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD>ģʽ
extern void SetWorkMode(unsigned char workMode, short upSendFreq);
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
extern int GetSensorInfo(unsigned char *pBuffer);
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif