📄 package.h
字号:
#ifndef _PACKAGE_H
#define _PACKAGE_H
#ifdef PACKAGE_C
#define EXTERN
#else
#define EXTERN extern
#endif
#define PKG_START 0xFA05
#define PKG_COM_T_CONNECT 0x01
#define PKG_COM_H_CONNECT_ACK 0x81
#define PKG_COM_T_QUESTION 0x02
#define PKG_COM_H_QUESTION_ACK 0x82
#define PKG_COM_T_FINISHED 0x03
#define PKG_COM_H_FINISHED_ACK 0x83
#define PKG_COM_T_MESSAGE 0x04
#define PKG_COM_H_MESSAGE_ACK 0x84
#define PKG_COM_T_COMM_ERR 0x05
#define PKG_COM_H_COMM_ERR 0x85
#define PKG_COM_H_RUN 0x86
#define PKG_COM_T_RUN_ACK 0x06
#define QST_YES 0x5A
#define QST_NO 0xA5
#define QST_NO_RESPONSE 0x00
#define FINISH_SUCCESS 0x0
#define FINISH_ERROR 0x1
#define FINISH_WARNING 0x2
#define FINISH_ERROR_WARNING 0x3
#define MES_NO_ERR_LOG 0x00
#define MES_NO_ERR_NOT_LOG 0x01
#define MES_AR 0x02
#define MES_WARNING 0xA0
#define MES_ERROR 0xB0
#define COMMERR_FINISH_ACK_TO 0x81
#define COMMERR_MESSAGE_ACK_TO 0x82
#define COMMERR_CRC_ERROR 0x83
#define COMMERR_UNDEFINED_HEAD 0x84
#define HCOMMERR_WAIT_T_RUN_ACK_TIME_OUT 0xB1
#define HCOMMERR_RESET_WIZARD 0xB2
#define HCOMMERR_CRC_ERROR 0xB3
#define HCOMMERR_UNDEFINED_HEAD 0xB4
#define WAIT_FOREVER 0x0
#define NO_WAIT (-1)
#define MAX_COM_DATA_LENGH 256
#define NO_ERROR 0xE0000
#define ERR_CRC_ERROR 0xE0001
#define ERR_UNKNOW_START 0xE0002
#define ERR_UNKNOW_TYPE 0xE0003
#define ERR_WRONG_PKG_ID 0xE0004
#define ERR_H_COMM_ERR 0xE0008
#define ERR_TIME_OUT 0xE0009
#define ERR_NO_DATA 0xE0010
#define BPS_9600 0
#define BPS_19200 1
#define BPS_38400 2
#define BPS_56000 3
#define BPS_57600 4
#define BPS_115200 5
#define DEFAULT_BPS BPS_115200
#define QUESTION_TIME_OUT_LONG (30+2)
#define QUESTION_TIME_OUT_SHORT (30+2)
#define TIME_OUT_VALUE 1000000 //1 Sec.
#define QUESTION_TIME_OUT_VALUE 10*1000000 //10 Sec.
typedef struct SS_Package_Head {
unsigned short Start ;
unsigned char Command ;
unsigned char Parameter0 ;
unsigned char Parameter1 ;
unsigned char Length ;
unsigned char PKG_ID ;
unsigned char CRC ;
} S_Package_Head;
typedef struct SS_Package{
S_Package_Head Head ;
unsigned char Data[MAX_COM_DATA_LENGH];
} S_Package;
extern S_Package G_Package;
void SayHelloToMaster(int ComPortSpeed);
int ReceivePackage(S_Package * PPackage);
int ProcessPackage (S_Package * PPackage);
int SendPackage(S_Package * PPackage, unsigned Timeout);
unsigned char CalculateCRC(S_Package_Head * PHead);
void SendNormalMessage(char * Message);
void SendErrorMessage(char * Message);
void SendWarningMessage(char * Message);
void FormatNormalMessage(char * fmt, ...);
void FormatErrorMessage(char * fmt, ...);
void FormatWarningMessage(char * fmt, ...);
int TestCoreFreq(void);
void SendARMessage(char * Message, unsigned int TimeoutInSec);
void SendQuestion(char * Message, unsigned int TimeoutInSec);
EXTERN unsigned char G_Parameter0; // Since there are some information are stored in Parameter0 and 1 in H_xxx_Package
EXTERN unsigned char G_Parameter1; // These 2 variables is used to save latest package parameter0 and parameter1.
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -