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

📄 project_type.h

📁 ZIGBEE 2006协议栈 BAT测试代码 RADIO PULSE MG2455
💻 H
字号:

/*******************************************************************************
	- Chip		: MG24500/55
	- Author		: RadioPulse Inc, 2007.
	- Date		: 2007-05-23
	- Version		: VER 1.0	
*******************************************************************************/


#ifndef __KEIL_DATA_TYPE__

	#define	__KEIL_DATA_TYPE__

	typedef 	unsigned long		UINT32;
	typedef 	unsigned short 	UINT16;
	typedef 	unsigned char		UINT8;
	typedef 	unsigned char		UINT1;
	typedef	long				INT32;
	typedef 	short			INT16;
	typedef 	char				INT8;
	
#endif


#define	HIB_ADDRESS		0x1000	// If HPIB is used, this value should not be modified.
#define	HIB_LENGTH			64
#define	INFO_ADDRESS		0x1200

typedef struct
{
	UINT8	IEEE_ADDR[8];		// IEEE Address
	UINT8	ChipID;				// 1=MG2400-F48, 2=MG2450/55
	UINT8	PowerID;			// 0x15=1.5V, 0x18=1.8V
	UINT8	ModemID;			// 0=250K, 1=500K, 2=1M
	UINT8	StackVersion;		// 0x10=ZigBee 2004, 0x11=2005, 0x12=2006, 0x13=2007
	UINT8	Channel;			// 0x0B~0x1A
	UINT8	PanID[2];
	UINT8	NwkAddr[2];			// LSB=NwkAddr[15:8], MSB=NwkAddr[7:0]
	UINT8	SecurityLevel;		// 0=No, 1=MIC32, 2=MIC64, 3=MIC128, 4=ENC, 5=ENCMIC32, 6=ENCMIC64, 7=ENCMIC128
	UINT8	PreConfigMode;		// 0x00 ~ 0xFF
	UINT8	NwkKey[16];			// Nwk Security Key
	UINT8	Reserved_0[16];		// reserved
	UINT8	Reserved_1[12];		// reserved
	UINT8	CSUM;				// SUM(IEEE_ADDR + Reserved_1) + CSUM = 0x00
	UINT8	Space[448];			// For fitting to 512Byte(1Page) size
} HW_INFORMATION;


typedef struct {
	// Identifier : 0x00 ~ 0x03
	UINT8	phyCurrentChannel;
	UINT32	phyChannelsSupported;
	UINT8	phyTransmitPower;
	UINT8	phyCCAMode;
} PHY_INFORMATION_BASE;


typedef struct {		// stored in FLASH

	// Identifier : 0x40 ~ 0x4F
	UINT16	macAckWaitDuration;			// 54 ot 120
	UINT8	macAssociationPermit;			// TF
	UINT8	macAutoRequest;				// TF
	UINT8	macBattLifeExt;					// TF
	UINT8	macBattLifeExtPeriods;
	UINT8	macBeaconPayload[16];			// dMAC_MAX_BEACON_PAYLOAD_DEPTH
	UINT8	macBeaconPayloadLength;
	UINT8	macBeaconOrder;
	UINT32	macBeaconTxTime;
	UINT8	macBSN;
	UINT16	macCoordExtendAddr[4];
	UINT16	macCoordShortAddr;
	UINT8	macDSN;
	UINT8	macGTSPermit;
	UINT8	macMaxCSMABackoffs;
	UINT8	macMinBE;	
	
	// Identifier : 0x50 ~ 0x55
	UINT16	macPANId;
	UINT8	macPromiscuousMode;
	UINT8	macRxOnWhenIdle;	
	UINT16	macShortAddr;
	UINT8	macSuperframeOrder;
	UINT16	macTransactionPersistenceTime;	

	UINT16	IEEE_ExtendAddr[4];				// 0x7F

	// Identifier : 0x70 ~ 0x76
	UINT8		macSecurityMode;	// 0x76

	// RadioPulse Specific
	UINT8		EnableFFD;
	UINT8		EnablePanCoordi;
	UINT8		JoinedToPanCoordi;
	UINT8		TrackingBO;
} MAC_INFORMATION_BASE;

typedef struct
{
	// RadioPulse Specific
	UINT8	DEVTYPE;		// 'C'=Coordinator, 'R'=Router, 'E'=End Device, 'N'=Not Joined
	UINT8	RREQNum;		// Route Request Sequence Number
	UINT8	RouteCapa;

	UINT8	Child_AssignZR;		// Address Allocation.
	UINT8	Child_CurrZR;		// Associated ZR's number
	UINT8	Child_ReuseZR;		// Reuse Address Number
	
	UINT8	Child_AssignZED;
	UINT8	Child_CurrZED;
	UINT8	Child_ReuseZED;
	
	// ZigBee2006 Standard
	UINT8	nwkDSN;					// 0x81
	UINT8	nwkPassiveAckTimeout;		// 0x82	// in sec
	UINT8	nwkMaxBroadcastRetry;		// 0x83
	UINT8	nwkMaxChildren;				// 0x84
	UINT8	nwkMaxDepth;				// 0x85
	UINT8	nwkMaxRouter;				// 0x86
//	NS_NT	*pnwkNT;					// 0x87
	UINT8	nwkNetBroadDeliverTime;	// 0x88	// in sec.
	UINT8	nwkReportConstantCost;		// 0x89	// 0=Link Cost by LQI, 1=constant Link Cost
	UINT8	nwkRouDiscRetryPermit;		// 0x8A
//	NS_RT	*pnwkRT;					// 0x8B
	// 0x8C : rsv
	// 0x8D : rsv
	UINT8	nwkSymLink;				// 0x8E
	//-- nwkCapaInfo
	//	bit[7]	: AllocAddr	
	//	bit[6]	: SecureCapa 
	//	bit[5:4]	: rsv			- 
	//	bit[3]	: RxOnIdle 	- 
	//	bit[2]	: PowerSrc 	- 1=Mains-powered
	//	bit[1]	: DevType 	- 1=(Joining Device is ZR) && (JoinAsRouter=1). RouteCapa.
	//	bit[0]	: AlterCoord	- 
	UINT8	nwkCapaInfo;				// 0x8F	
	UINT8	nwkUseTreeAddrAlloc;		// 0x90
	UINT8	nwkUseTreeRoute;			// 0x91
	UINT16	nwkNextAddr;				// 0x92
	UINT16	nwkAvailAddr;				// 0x93
	UINT16	nwkAddrIncrement;			// 0x94
	UINT16	nwkTransPersisTime;		// 0x95	// in superframe periods(macTransactionTime)
	UINT16	nwkShortAddr;				// 0x96
	UINT8	nwkStackProfile;				// 0x97
	UINT8	nwkProtocolVer;				// 0x98
//	NS_GID	*pnwkGID;
	UINT8	nwkEPID[8];					// 0x9A	
} NS_PIB;

typedef struct
{
	NS_PIB	NIB;
	MAC_INFORMATION_BASE	MPIB;
	PHY_INFORMATION_BASE	PPIB;
} LAYER_INFORMATION;

typedef union
{
	UINT8	BUFF[512];
	HW_INFORMATION		DataHIB;
	LAYER_INFORMATION	LayerInfo;
} FLASH_AREA;

//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//		UART API Definition
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------

#define MAX_API_PACKET      124


typedef struct _API_PACKET
{
    UINT8 layer;
    UINT8 Opcode;
    UINT8 Type;
    UINT8 Size;
    UINT8 Arguments[MAX_API_PACKET];
} API_PACKET;

typedef struct _API_SERIAL_PACKET
{
    UINT8 STX;      			/*	0xAA										*/
    UINT8 LEN;      			/* 	Size of PKT									*/
    API_PACKET PKT; 		/* 	PACKET BUFFER								*/
    UINT8 SUM;      			/* 	SUM = SUM(PKT)	, IF SUM == 0, SUM is Ignored	*/
    UINT8 ETX;      			/* 	0x55										*/
} API_SERIAL_PACKET;



	#define 	CFG_TOP_LAYER			0x00
	#define 	CFG_NWK_INFO			0x01
	#define 	CFG_SYS_VERSION		0x7F
	#define 	CFG_SYS_BACKUP		0x0F
	#define 	CFG_TOP_LAYER_GET		0x80
	#define 	CFG_NWK_INFO_GET		0x81

	#define	ZIGBEE_VERSION			0x30

	#define 	cCOMMON_LENGTH_ERROR 	0xF0
	#define 	cCOMMON_CRC_ERROR      		0xF1

	//	Layer
	#define 	COMM_LAYER			0x01
	#define 	APS_LAYER				0x10
	#define 	NWK_LAYER				0x20
	#define 	MAC_LAYER				0x30
	#define 	PHY_LAYER				0x40
	#define 	OOB_LAYER				0x50
	#define 	APP_LAYER				0x80
	
	//	Type
	#define 	REQ_TYPE				0x10
	#define 	CON_TYPE				0x11
	#define 	IND_TYPE				0x12
	#define 	RSP_TYPE				0x13
	#define 	COMM_TYPE				0x01
	
	//	Common Layer
	#define 	COMM_OPCODE			0x01

	// 	MAC Layer	
	#define	M_RESET_OPC			0x01
	#define	M_START_OPC			0x02
	#define	M_SCAN_OPC			0x03
	#define	M_ASSO_OPC			0x04
	#define	M_DISA_OPC				0x05
	#define	M_GTS_OPC				0x06
	#define	M_SYNC_OPC			0x07
	#define	M_POLL_OPC				0x08
	#define	M_SET_OPC				0x09
	#define	M_GET_OPC				0x0A
	#define	M_RX_ENA_OPC			0x0B
	#define	M_DATA_OPC			0x0C
	#define	M_PURGE_OPC			0x0D
	#define	M_BEA_NOTI_OPC		0x0E
	#define	M_ORPH_OPC			0x0F
	#define	M_SYNC_LOSS_OPC		0x10
	#define	M_COMM_STA_OPC		0x11	

	//	NWK Layer
	#define 	N_DATA_OPC			0x10
	#define 	N_NET_DIS_OPC         	0x11
	#define 	N_NET_FOR_OPC          	0x12
	#define 	N_PERMIT_JOIN_OPC		0x13
	#define 	N_START_ROUTE_OPC	0x14
	#define 	N_JOIN_OPC				0x15
	#define 	N_DIRECT_JOIN_OPC		0x16
	#define 	N_LEAVE_OPC			0x17
	#define 	N_RESET_OPC			0x18
	#define 	N_SYNC_OPC				0x19
	#define 	N_GET_OPC				0x20
	#define 	N_SET_OPC				0x21
	#define	N_ROUTE_DISC_OPC		0x30
	#define 	N_ROUTE_ERR_OPC		0x31
	#define	N_FORCE_JOIN_OPC		0x32
	#define	N_GET_TABLE_OPC		0x33
	#define 	N_DEBUG_OPC			0xD0

	//	APS Layer
	#define 	A_DATA_OPC 			0x10
	#define 	A_BIND_OPC				0x11
	#define 	A_UNBIND_OPC			0x12	
	#define 	A_GET_OPC				0x13
	#define 	A_SET_OPC				0x14
	#define 	A_ESTABLISH_KEY		0x15
	#define 	A_TRANSPORT_KEY		0x16
	#define 	A_UPDATE_DEVICE		0x17
	#define 	A_REMOVE_DEVICE		0x18
	#define 	A_REQUEST_KEY			0x19
	#define 	A_SWITCH_KEY			0x1A
	#define 	A_ADD_GRP_OPC			0x1B
	#define 	A_RM_GRP_OPC			0x1C
	#define	A_RM_ALL_GRP_OPC		0x1D	
	#define 	A_SKKE0				0x20
	#define 	A_SKKE1				0x21
	#define 	A_SKKE2				0x22
	#define 	A_SKKE3				0x23
	#define 	A_SKKE4				0x24

	// 	APP Layer	
 	#define	APP_MGR_OPC			0x80
	#define	APP_EVT_OPC			0xE0

⌨️ 快捷键说明

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