⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parameters.h

📁 透明传输的DTU。实现配置:microchip 18F6520,协议DL/T645。 全部C源码文件。
💻 H
字号:
/*-------------------------------------------------------------------------
 * $Id: p18f6520.h,v 1.1.2.3 2004/03/26 20:37:16 sealep Exp $
 * MPLAB-Cxx  PIC18F6520 processor header
 *
 * (c) Copyright 1999-2004 Microchip Technology, All rights reserved
 *-------------------------------------------------------------------------*/
#ifndef __Param_H
#define __Param_H
#define CMGR_Echo 16
#define CMGL_SIZE 10
#define MGHeader 22					//从短信的第一个字符08截至到目的号码长度
#define MaxDNSIPSize 24
#define StartTime 0x08					//从短信的第一个字符08截至到目的号码长度
#define EndTime 0x18

#define	OPTION_INIT	B'10000101'	; weak pull-ups are disabled,
#define	T2CON_INIT	B'00000100'	; setup Timer1,1:1 prescale, int clock

#define	TXSTA_INIT	B'01000000'
#define	RCSTA_INIT	B'11010000'

#define _0   0x30
#define _1   0x31
#define _2   0x32
#define _3   0x33
#define _4   0x34
#define _5   0x35
#define _6   0x36
#define _7   0x37
#define _8   0x38
#define _9   0x39

#define _A   0x41
#define _B   0x42
#define _C   0x43
#define _D   0x44
#define _E   0x45
#define _F   0x46
#define _G   0x47
#define _H   0x48
#define _I   0x49
#define _J   0x4A
#define _K   0x4B
#define _L   0x4C
#define _M   0x4D
#define _N   0x4E
#define _O   0x4F
#define _P   0x50
#define _Q   0x51
#define _R   0x52
#define _S   0x53
#define _T   0x54
#define _U   0x55
#define _V   0x56
#define _W   0x57
#define _X   0x58
#define _Y   0x59
#define _Z   0x5A

#define _LF		0x0A		//换行
#define _CR		0x0D		//回车
#define _CTRLZ  0x1A		//CTRL+Z
#define _SPACE  0x20		//sp
#define _QUOTE	0x22		//"
#define _AND	0x26		//&
#define _PLUS   0x2B		//+
#define _COMMA	0x2C		//,
#define _DOT	0x2E		//.
#define _SLASH	0x2F		///
#define _COLON  0x3A		//:
#define _EQUAL  0x3D		//=
#define _YOUJ   0x3E		//>
#define _QustionMark   0x3F	//?

#define ATE0_SIZE 5
#define AT_CSCS_SIZE 15
#define AT_CMGS_SIZE 8
#define CFUN_SIZE 12
#define CIPSPRT_SIZE 13
#define CIPHEAD_SIZE 13
#define CIPSTATUS_SIZE 13
#define CCLK_SIZE 9
#define CIPSEND_SIZE 10		//含回车:11
#define CIPCLOSE_SIZE 12
#define CIPSHUT_SIZE 11
#define CIPDATA_SIZE 16
#define DataLength  256		//DL/T645协议规定电表回送的最长帧

//短信显示Unicode编码 --------------------------------------------------------
#define SMS_Header1_SIZE 10
const rom char  SMS_Header1[SMS_Header1_SIZE] = 
	{_0,_0,_1,_1,_0,_0,_0,_D,_9,_1};	// 长度不一定是0D

#define SMS_Header2_SIZE 6
const rom char  SMS_Header2[SMS_Header2_SIZE] = 
	{_0,_0,_0,_8,_0,_1};				//01:VP 有效期

#define PerEnergyDataLength 36
#define Energy_Length 16
const rom char  TotalE[Energy_Length] = 
	{_6,_7,_0,_9,_5,_2,_9,_F,_6,_0,_3,_B,_0,_0,_3,_A};				//有功总:
const rom char  LMTotalE[Energy_Length] = 
	{_4,_E,_0,_A,_6,_7,_0,_8,_6,_0,_3,_B,_0,_0,_3,_A};				//上月总:

#define TABChar_Length 8
const rom char  SharpE[TABChar_Length] = {_5,_C,_1,_6,_0,_0,_3,_A};	//尖:
const rom char  PeakE[TABChar_Length] = {_5,_C,_F,_0,_0,_0,_3,_A};	//峰:
const rom char  DayE[TABChar_Length] = {_5,_E,_7,_3,_0,_0,_3,_A};	//平:
const rom char  LowE[TABChar_Length] = {_8,_C,_3,_7,_0,_0,_3,_A};	//谷:
const rom char  invAE[TABChar_Length] = {_5,_3,_C,_D,_0,_0,_3,_A};	//反:
const rom char  leftM[TABChar_Length] = {_5,_2,_6,_9,_0,_0,_3,_A};	//剩:

#define SMS_OK_Length 8
const rom char  SMS_OK[SMS_OK_Length] = {_0,_0,_4,_F,_0,_0,_4,_B};	//OK

// hander set  ---------------------------------------------------------------
#define CSQ_SIZE 7						//信号强度
const rom char AT_CSQ_buf[CSQ_SIZE]=
		{_A,_T,_PLUS,_C,_S,_Q,_CR};
#define CNUM_SIZE 8						//SIM卡号码
const rom char AT_CNUM_buf[CNUM_SIZE]=
		{_A,_T,_PLUS,_C,_N,_U,_M,_CR};
#define SetCCLK_SIZE 31
const rom char  ATCCLK[SetCCLK_SIZE]=	//把AT+CCLK的命令格式准备好,用手掌机的最新时间替换
{_A,_T,_PLUS,_C,_C,_L,_K,_EQUAL,_QUOTE,
 _0,_5,_SLASH,_0,_1,_SLASH,_1,_1,_COMMA,_0,_9,_COLON,_5,_5,_COLON,_0,_1,_PLUS,_0,_0,
 _QUOTE,_CR
};

// ---------------------------------------------------------------------------
const rom char CMD_ATE0[ATE0_SIZE]=
	{_A,_T,_E,_0,_CR};
const rom char Ip_send_buf[CIPSEND_SIZE]={_A,_T,_PLUS,_C,_I,_P,_S,_E,_N,_D};
const rom char Ip_CIPSPRT_buf[CIPSPRT_SIZE]=		//设at+cipsprt=0 之后,发完cipsend后,不需大于号和空格
		{_A,_T,_PLUS,_C,_I,_P,_S,_P,_R,_T,_EQUAL,_0,_CR};//但是只延迟20ms不够

#define CREG_SIZE 10
const rom char Ip_CREG_buf[CREG_SIZE]=
		{_A,_T,_PLUS,_C,_R,_E,_G,_EQUAL,_1,_CR};
//应答:OK
#define CREG_ASK_SIZE 9
const rom char CREG_ASK_buf[CREG_ASK_SIZE]=
		{_A,_T,_PLUS,_C,_R,_E,_G,_QustionMark,_CR};
//应答:+CREG: 1,1
//		OK
#define L_CREGSta 17
const rom char CREGSta_buf[L_CREGSta]=
{_CR,_LF,_PLUS,_C,_R,_E,_G,_COLON,_SPACE,_1,_COMMA,_1,_CR,_LF,_O,_K,_CR};
const rom char Ip_CCLK_buf[CCLK_SIZE]=
		{_A,_T,_PLUS,_C,_C,_L,_K,_QustionMark,_CR};
const rom char AT_CSCS_buf[AT_CSCS_SIZE]=		//设AT+CSCS="UCS2"
		{_A,_T,_PLUS,_C,_S,_C,_S,_EQUAL,_QUOTE,_U,_C,_S,_2,_QUOTE,_CR};
const rom char AT_CMGS_buf[AT_CMGS_SIZE]=
		{_A,_T,_PLUS,_C,_M,_G,_S,_EQUAL};	
const rom char Ip_CIPHEAD_buf[CIPHEAD_SIZE]=		//设at+ciphead=1,远端发来的数据自动加上报头 +IPDn
		{_A,_T,_PLUS,_C,_I,_P,_H,_E,_A,_D,_EQUAL,_1,_CR};
const rom char AT_CIPSTATUS[CIPSTATUS_SIZE]=
		{_A,_T,_PLUS,_C,_I,_P,_S,_T,_A,_T,_U,_S,_CR};
#define L_Cipdpdp 18
const rom char ArrCipdpdp[L_Cipdpdp]=
		{_A,_T,_PLUS,_C,_I,_P,_D,_P,_D,_P,_EQUAL,_1,_COMMA,_1,_0,_COMMA,_3,_CR};
#define L_CPOWD 9
const rom char ArrCPOWD[L_CPOWD]=
		{_A,_T,_PLUS,_C,_P,_O,_W,_D,_CR};

#define L_start_buf1 19
const rom char Ip_start_buf1[L_start_buf1]={
  _A,_T,_PLUS,							//3
  _C,_I,_P,_S,_T,_A,_R,_T,_EQUAL,		//9
  _QUOTE,_T,_C,_P,_QUOTE,_COMMA,_QUOTE};//7
#define L_start_buf3 9
const rom char Ip_start_buf3[L_start_buf3]={
//  _QUOTE,_COMMA,_QUOTE,_2,_0,_2,_0,_QUOTE,_CR};		//9
  _QUOTE,_COMMA,_QUOTE,_5,_0,_0,_0,_QUOTE,_CR};		//9

const rom char Ip_close_buf[CIPCLOSE_SIZE]={_A,_T,_PLUS,_C,_I,_P,_C,_L,_O,_S,_E,_CR};

const rom char Ip_shut_buf[CIPSHUT_SIZE]={_A,_T,_PLUS,_C,_I,_P,_S,_H,_U,_T,_CR};

// **********  字符串资源   ************************************************************

//只比较第二个回车(含)之前的字符
#define L_OK 5
const rom char OK[L_OK]=
{_CR,_LF,_O,_K,_CR};
#define L_ERROR 8
const rom char ERROR[L_ERROR]=
{_CR,_LF,_E,_R,_R,_O,_R,_CR};
//#define L_PLUSCGATT 0x0C
//const rom char PLUSCGATT[L_PLUSCGATT]=
//{_CR,_LF,_PLUS,_C,_G,_A,_T,_T,_COLON,_SPACE,_1,_CR};//ate0时的应答:0D 0A 2B 43 47 41 54 54 3A 20 31 0D 0A 0D 0A 4F 4B 0D 0A

#define L_PLUSSCKS0 10
const rom char PLUSSCKS0[L_PLUSSCKS0]=
{_CR,_LF,_PLUS,_S,_C,_K,_S,_COLON,_0,_CR};

#define L_PlusCMGS 9
const rom char PlusCMGS[L_PlusCMGS]=
{_CR,_LF,_PLUS,_C,_M,_G,_S,_COLON,_SPACE};
#define L_SEND_OK 10		//0D 0A 53 45 4E 44 20 4F 4B 0D
const rom char SEND_OK[L_SEND_OK]=
{_CR,_LF,_S,_E,_N,_D,_SPACE,_O,_K,_CR};

//CIPSTATUS:
#define L_OK_CONNECT_OK 19					//AT命令模式连接成功后的应答
const rom char OK_CONNECT_OK[L_OK_CONNECT_OK]=
{_CR,_LF,_O,_K,_CR,_LF,_CR,_LF,_C,_O,_N,_N,_E,_C,_T,_SPACE,_O,_K,_CR};

#define L_OK_CONNECT 16						//透传模式连接成功后的应答
const rom char OK_CONNECT[L_OK_CONNECT]=
{_CR,_LF,_O,_K,_CR,_LF,_CR,_LF,_C,_O,_N,_N,_E,_C,_T,_CR};
//--------------------------------------------------------------------------
#define L_SHUT_OK 10
const rom char SHUT_OK[L_SHUT_OK]=
{_CR,_LF,_S,_H,_U,_T,_SPACE,_O,_K,_CR};

#define L_ALREADY_CONN 18
const rom char ALREADY_CONN[L_ALREADY_CONN]=
{_CR,_LF,_A,_L,_R,_E,_A,_D,_Y,_SPACE,_C,_O,_N,_N,_E,_C,_T,_CR};
#define L_IP_CLOSE 18
const rom char IP_CLOSE[L_IP_CLOSE]=
{_CR,_LF,_S,_T,_A,_T,_E,_COLON,_SPACE,_I,_P,_SPACE,_C,_L,_O,_S,_E,_CR};
#define L_IP_INITIAL 26
const rom char IP_INITIAL[L_IP_INITIAL]=
{_CR,_LF,_S,_T,_A,_T,_E,_COLON,_SPACE,_I,_P,_SPACE,_I,_N,_I,_T,_I,_A,_L,_CR,_LF,_CR,_LF,_O,_K,_CR};
#define L_IP_STATUS 19
const rom char IP_STATUS[L_IP_STATUS]=
{_CR,_LF,_S,_T,_A,_T,_E,_COLON,_SPACE,_I,_P,_SPACE,_S,_T,_A,_T,_U,_S,_CR};
#define L_DEACT 14
const rom char PDP_DEACT[L_DEACT]=
{_CR,_LF,_PLUS,_P,_D,_P,_COLON,_SPACE,_D,_E,_A,_C,_T,_CR};
#define L_ERROR513 18
const rom char ANS_ERROR513[L_ERROR513]=
{_CR,_LF,_PLUS,_C,_M,_S,_SPACE,_E,_R,_R,_O,_R,_COLON,_SPACE,_5,_1,_3,_CR};

//--------------------------------------------------------------------------
#define IP_SIZE 12
const rom char IPAddressEqual[IP_SIZE]=				//短信修改IP地址,前缀为:地址=
		{_5,_7,_3,_0,_5,_7,_4,_0,_0,_0,_3,_D};	
#define DNE_SIZE 12
#define DTE_SIZE 12
const rom char DateTimeEQUAL[DTE_SIZE]=				//短信修改时间,前缀为:时间=
		{_6,_5,_F,_6,_9,_5,_F,_4,_0,_0,_3,_D};	

//--------------------------------------------------------------------------
//module主动上报:
#define RDY_SIZE 6
const rom char Module_RDY[RDY_SIZE]=
{_CR,_LF,_R,_D,_Y,_CR};

#define L_CLOSED 9
const rom char CLOSED[L_CLOSED]=
{_CR,_LF,_C,_L,_O,_S,_E,_D,_CR};	//链接被断开

#define L_PLUSCMTI 8
const rom char PLUSCMTI[L_PLUSCMTI]=
{_CR,_LF,_PLUS,_C,_M,_T,_I,_COLON};		//MODULE收到短信

#define forwardChar	0xFE

// *****************************************************
//内部EEPROM 存储的数据地址分配(1k字节,000H~3FFH)

#define StartRegion		0x0000	//EEPROM起始地址
#define VirginTime 		0x0008	//初次上电判断:55AA,两个字节
#define AllMeters 		0x000A	//一个字节
#define LinkMode 		0x0010	//_1,_D、_1,_EH:永久在线/定时连接
#define BeatTime 		0x0012	//心跳包的间隔时间:分

#define DTUNO 			0x0018	//GPRS终端号,四个字节,八位
#define PASSWORDAddr	0x0020	//20H~2FH
#define UserNameAddr	0x0030	//30H~3FH
#define APNAddr 		0x0040	//40H~4FH,16 bytes

#define IPAddress 		0x0060	//IP地址:60H~6FH
#define PortAddr 		0x0070	//4 bytes,字符

// *****************************************************
//FLASH 存储的数据地址分配(32k字节,0000H~7FFFH)

//存储连接的32个表号区:32*6=192,0000H~00C0H
#define MeterNORegion	0x0000	

//0点数据区:每块表的0点数据占24个字节:总峰平谷反剩:4,4,4,4,4,4,最后八个字节保留
//共传输32个字节:32*32=1024,1000H~103FH
#define NO1Area		0x1000	
#define NO2Area		0x1020	
#define NO3Area		0x1040	
#define NO4Area		0x1060	
#define NO5Area		0x1080	
#define NO6Area		0x10A0	
#define NO7Area		0x10C0	
#define NO8Area		0x10E0	

#define NO9Area			0x1100	
#define NO10Area		0x1120	
#define NO11Area		0x1140	
#define NO12Area		0x1160	
#define NO13Area		0x1180	
#define NO14Area		0x11A0	
#define NO15Area		0x11C0	
#define NO16Area		0x11E0	

#define NO17Area		0x1200	
#define NO18Area		0x1220	
#define NO19Area		0x1240	
#define NO20Area		0x1260	
#define NO21Area		0x1280	
#define NO22Area		0x12A0	
#define NO23Area		0x12C0	
#define NO24Area		0x12E0	

#define NO25Area		0x1300	
#define NO26Area		0x1320	
#define NO27Area		0x1340	
#define NO28Area		0x1360	
#define NO29Area		0x1380	
#define NO30Area		0x13A0	
#define NO31Area		0x13C0	
#define NO32Area		0x13E0	

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -