micro_climate/App/Inc/com.h

87 lines
2.7 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef COM_H_
#define COM_H_
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
//宏定义
#define COMMAND_TYPE_SET_ADDR 1 //设定装置地址
#define COMMAND_TYPE_SCAN_ADDR 2 //查询装置地址
#define COMMAND_TYPE_GETDATA 5 //读取数据
#define COMMAND_TYPE_GET_WORKMODE 11 //查询数据传输模式
#define COMMAND_TYPE_SET_WORKMODE 12 //设定数据传送方式1被动应答2主动上送
#define COMMAND_TYPE_SCALE 13 //校正
#define COMMAND_TYPE_CALL_ORIGINALVALUE 14 //召原始值
#define COMMAND_TYPE_SCALE_RESET 15 //清除校正
#define COMMAND_TYPE_CALLINFO 16 //召装置信息
#define FRAME_HEAD_L 0 //帧头低字节
#define FRAME_HEAD_H 1 //帧头高字节
#define FRAME_LENGTH_L 2 //帧长低字节
#define FRAME_LENGTH_H 3 //帧长高字节
#define FRAME_DEVICE_TYPE 4 //装置类型
#define FRAME_DEVICE_ADDR 5 //装置地址
#define FRAME_TYPE 6 //帧类型
#define FRAME_CMD_TYPE 7 //命令类型
#define FRAME_DATE_START 8 //数据域其实
#define FRAME_HEAD_LEN 9 //帧头固定长度包含CRC校验码
#define SENDBUFFER_LEN 256 //发送缓冲区长度
#define SENDDATA_LEN_MAX (SENDBUFFER_LEN - FRAME_HEAD_LEN) //发送数据最大长度
#define ASDU_MUN 32 //最多缓冲32个命令帧
#define ASDU_LEN_MAX 20
//数据结构
typedef struct{
DT_UINT8 WriteIP; //写指针
DT_UINT8 ReadIP; //读指针
DT_UINT8 Lock;
DT_UINT8 AsduFrame[ASDU_MUN][ASDU_LEN_MAX]; //命令缓冲区
}tagComDataRecv;
//外部接口
//上送数据
void Handle_upSend_Data(unsigned char *pFrame);
//主动上送数据
void UpSendDataActive(void);
//检测接收到的数据并反馈
void CheckComData(void);
void Com_SendData(unsigned char *pDataBuffer,unsigned int dataLen,unsigned char addr,unsigned char cmdtype);
//需外部定义的接口
//固化参数
extern void Write_App_Params(void);
//读取设定参数
extern void Read_App_Params(void);
//发送数据
extern void UART_Send(unsigned char *pBuffer, unsigned int Length);
//设置地址
extern void SetAddress(unsigned char addr);
//读取地址
extern unsigned char ReadAddress(void);
//获取角度计算值
extern int GetAngleMeasureValue(float *pAngle_X,float *pAngle_Y,float *pAngle_Z);
//角度校正
extern void AngleScale(void);
//复位角度校正
extern void AngleScale_Reset(void);
//开始召原始数据
extern void StartWave(unsigned char object);
//读取工作方式参数
extern void ReadWorkMode(unsigned char *workMode, unsigned short *upSendFreq);
//设置工作模式
extern void SetWorkMode(unsigned char workMode, short upSendFreq);
//读取传感器信息
extern int GetSensorInfo(unsigned char *pBuffer);
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif