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

📄 ident.h

📁 关于DeviceNet协议的仅限组2的从站代码
💻 H
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************
 *
 * Microchip DeviceNet Stack (Identity Object Header)
 *
 *****************************************************************************
 * FileName:        ident.h
 * Dependencies:    
 * Processor:       PIC18F with CAN
 * Compiler:       	C18 02.10.02 or higher
 * Linker:          MPLINK 03.20.01 or higher
 * Company:         Microchip Technology Incorporated
 *
 * Software License Agreement
 *
 * The software supplied herewith by Microchip Technology Incorporated
 * (the "Company") is intended and supplied to you, the Company's
 * customer, for use solely and exclusively with products manufactured
 * by the Company. 
 *
 * The software is owned by the Company and/or its supplier, and is 
 * protected under applicable copyright laws. All rights are reserved. 
 * Any use in violation of the foregoing restrictions may subject the 
 * user to criminal sanctions under applicable laws, as well as to 
 * civil liability for the breach of the terms and conditions of this 
 * license.
 *
 * THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES, 
 * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED 
 * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
 * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, 
 * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR 
 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 *
 *
 * Refer to Chapter 6 of Volume 2 for information about this object.
 *
 * Author               Date        Comment
 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Ross Fosler			04/03/03	...	
 * 
 *****************************************************************************/



/*********************************************************************
 * Identity object data structure
 ********************************************************************/
typedef struct _DNET_ID
{
	union _VENDOR_ID				// Vendor ID
	{
		UINT W;
		struct
		{
			USINT	L;
			USINT	H;
		}bytes;
	}vendorID;
	
	union _DEV_TYPE					// Device type
	{
		UINT W;
		struct
		{
			USINT	L;
			USINT	H;
		}bytes;
	}deviceType;

	union _PROD_CODE				// Product code
	{
		UINT W;
		struct
		{
			USINT	L;
			USINT	H;
		}bytes;
	}productCode;

	struct _REV						// Revision		
	{
		USINT	major;
		USINT 	minor;
	}revision;

	WORD status;					// Status

	union _SERIAL_NUM				// Serial number
	{
		UDINT	W;
		struct
		{
			USINT	L;
			USINT	H;
			USINT	UL;
			USINT	UH;
		}bytes;
	}serial;

	struct _DEV_NAME				// Device name
	{
		unsigned char len;
		//ROM unsigned char 	*p;	
	    unsigned char 	*p;	
	}name;

} DNET_ID;



/*********************************************************************
 * Identity object data structure declared global
 ********************************************************************/
extern DNET_ID uIdentity;




		   
/*********************************************************************
 * Function:        unsigned char _IdentityExplMsgHandler(void)
 *
 * PreCondition:    
 *
 * Input:           
 *					
 *                  
 * Output:         
 *				
 *				
 *			
 *
 * Side Effects:    
 *
 * Overview:        Handler for explicit messaging 
 *
 * Note:            None
 ********************************************************************/
unsigned char _IdentityExplMsgHandler(void);





/*********************************************************************
 * Function:        unsigned char IdentityInst0GetAttrib(void)
 
 *					unsigned char DNetGetAttrib(Instance, Attribute, *length)
 *
 * PreCondition:    
 *
 * Input:           gInstance - contains the requested instance.
 *					gAttribute - contains the attribute number.
 *                  
 * Output:          gResponse - contains the response or error code
 *					and any bytes following gResponse may also contain
 *					data.
 *					Returns 1 for success or 0 for error.
 *
 * Side Effects:    Overwrites gInstance, gAttribute, gResponse, and more
 *
 * Overview:        Gets an attribute within this object (DeviceNet Object) 
 *
 * Note:            None
 ********************************************************************/
unsigned char _IdentityInst0GetAttrib(void);



/*********************************************************************
 * Function:        unsigned char IdentityInst1GetAttrib(void)
 
 *					unsigned char DNetGetAttrib(Instance, Attribute, *length)
 *
 * PreCondition:    
 *
 * Input:           gInstance - contains the requested instance.
 *					gAttribute - contains the attribute number.
 *                  
 * Output:          gResponse - contains the response or error code
 *					and any bytes following gResponse may also contain
 *					data.
 *					Returns 1 for success or 0 for error.
 *
 * Side Effects:    Overwrites gInstance, gAttribute, gResponse, and more
 *
 * Overview:        Gets an attribute within this object (DeviceNet Object) 
 *
 * Note:            None
 ********************************************************************/
unsigned char _IdentityInst1GetAttrib(void);



/*********************************************************************
 * Function:        unsigned char IdentityReset(void)
 *
 * PreCondition:    
 *
 * Input:           
 *					
 *                  
 * Output:         
 *				
 *				
 *			
 *
 * Side Effects:    
 *
 * Overview:        Handler for explicit messaging 
 *
 * Note:            None
 ********************************************************************/
unsigned char IdentityReset(void);



/*********************************************************************
 * Function:        void IdentityInit(vendorID, deviceType, productCode, 
 *										majorRev, minorRev, status, 
 *										serial, nameLen, pName)
 *
 * PreCondition:    
 *
 * Input:           
 *					
 *                  
 * Output:         
 *				
 *				
 *			
 *
 * Side Effects:    
 *
 * Overview:        Init 
 *
 * Note:            None
 ********************************************************************/
#define mIdentityInit(vendor_id, device_type, product_code, major_rev, 		\
					 minor_rev, status_bits, serial_no, name_len, p_name) {	\
							uIdentity.name.p = p_name;						\
							uIdentity.name.len = name_len;					\
							uIdentity.serial.W = serial_no;					\
							uIdentity.status.W = status_bits;				\
							uIdentity.revision.minor = minor_rev;			\
							uIdentity.revision.major = major_rev;			\
							uIdentity.productCode.W.word = product_code;	\
						 	uIdentity.deviceType.W.word = device_type;		\
						 	uIdentity.vendorID.W.word = vendor_id;}				   					
					  	  		  


/*********************************************************************
 * Function:        void IdentitySetVendorID(UINT vendorID)
 *					void IdentitySetVendorIDL(USINT vendorID_L)
 *					void IdentitySetVendorIDH(USINT vendorID_H)
 *
 * PreCondition:    
 *
 * Input:    		vendorID       
 *                  
 * Output:     		none    
 *				
 * Side Effects:  	  
 *
 * Overview:        Writes the Identity class variable, vendorID. 
 *
 * Note:            None
 ********************************************************************/
#define	mIdentitySetVendorID(vendor_id)			(uIdentity.vendorID.W.word = vendor_id)
#define mIdentitySetVendorIDL(vendor_id_L)		(uIdentity.vendorID.bytes.L = vendor_id_L)
#define mIdentitySetVendorIDH(vendor_id_H)		(uIdentity.vendorID.bytes.H = vendor_id_H)


⌨️ 快捷键说明

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