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

📄 can.h

📁 关于devicenet的源代码。micorchip公司的
💻 H
📖 第 1 页 / 共 2 页
字号:

/*****************************************************************************
 *
 * Microchip DeviceNet Stack (CAN Driver Header)
 *
 *****************************************************************************
 * FileName:        CAN.c
 * Dependencies:    
 * Processor:       PIC18F with CAN
 * Compiler:       	C18 02.20.00 or higher
 * Linker:          MPLINK 03.40.00 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.
 *
 *	This version of the CAN driver for DeviceNet is designed to be very
 *	simple. Filtering options are static and limited. Receive buffering is
 *	is restricted to only the two hardware receive buffers. And transmit 
 *	buffering is restricted to only one of three transmit buffers. However,
 *	the architecture of this driver lends itself to be upgradable to achieve 
 *	better performance without changes to the firmware using this driver.
 * 
 *
 *
 * Author               Date        Comment
 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Ross Fosler			04/28/03	...	
 * 
 *****************************************************************************/



/*********************************************************************
 * NEAR Access control
 ********************************************************************/	
#if USE_ACCESS == 1
#pragma	udata access	_A_CAN_FUNCTIONS
#define	NEAR near
#else
#define NEAR
#endif 

 

/*********************************************************************
 * Function:        NEAR unsigned char CANOpen(void)
 *
 * PreCondition:   	Bitrate and filters should be setup 
 *
 * Input:       	void
 *                  
 * Output:      	unsigned char status of the request
 *
 * Side Effects:   	 
 *
 * Overview:        Open CAN communications 
 *
 * Note:            This function should be interprited as a request
 *					rather than a command. Use CANIsOpen() to 
 *					verify the bus has been opened.
 ********************************************************************/
NEAR unsigned char CANOpen(void);


/*********************************************************************
 * Function:        NEAR unsigned char CANClose(void)
 *
 * PreCondition:   	Bus communications should be open. 
 *
 * Input:       	void
 *                  
 * Output:      	unsigned char status of the request
 *
 * Side Effects:   	 
 *
 * Overview:        Close CAN communications 
 *
 * Note:            This function should be interprited as a request
 *					rather than a command. Use CANIsOpen() to 
 *					verify the bus is still open.
 ********************************************************************/
NEAR unsigned char CANClose(void);


/*********************************************************************
 * Function:        NEAR unsigned char CANIsOpen(void)
 *
 * PreCondition:   	 
 *
 * Input:       	void
 *                  
 * Output:      	unsigned char status of the request
 *
 * Side Effects:   	 
 *
 * Overview:        Return the status of communication. 
 *					TRUE = Open, FALSE = Closed 
 *
 * Note:            
 ********************************************************************/
NEAR unsigned char CANIsOpen(void);


/*********************************************************************
 * Function:        NEAR unsigned char CANSetFilter(NEAR unsigned int filterID)
 *
 * PreCondition:   	 
 *
 * Input:       	16-bit filterID
 *                  
 * Output:      	unsigned char status of the request
 *
 * Side Effects:   	Communication may be temporarily interrupted
 *
 * Overview:        Adds a filter to the scan list.
 *
 * Note:            No scan list is actually created in this version;
 *					a hardware filter is to allow a CAN ID or group 
 *					of IDs to be received.
 ********************************************************************/
NEAR unsigned char CANSetFilter(NEAR unsigned int filterID);


/*********************************************************************
 * Function:        NEAR unsigned char CANClrFilter(NEAR unsigned int filterID)
 *
 * PreCondition:   	 
 *
 * Input:       	16-bit filterID
 *                  
 * Output:      	unsigned char status of the request
 *
 * Side Effects:   	Communication may be temporarily interrupted
 *
 * Overview:        Removes a filter from the scan list. 
 *
 * Note:           	No scan list is actually created in this version;
 *					a hardware filter is used to allow a CAN ID or 
 *					group of IDs to	be received.
 ********************************************************************/
NEAR unsigned char CANClrFilter(NEAR unsigned int filterID);


/*********************************************************************
 * Function:        NEAR unsigned char CANSetBitRate(NEAR unsigned char bitrate)
 *
 * PreCondition:   	 
 *
 * Input:       	bitrate
 *                  
 * Output:      	unsigned char status of the request
 *
 * Side Effects:   	Communication may be temporarily interrupted
 *
 * Overview:        Changes the bitrate of the node. 
 *
 * Note:           	
 ********************************************************************/
NEAR unsigned char CANSetBitRate(NEAR unsigned char bitrate);


/*********************************************************************
 * Function:        NEAR unsigned char CANIsBusError(void)
 *
 * PreCondition:   	 
 *
 * Input:       	none
 *                  
 * Output:      	unsigned char status of the request
 *
 * Side Effects:   	
 *
 * Overview:        Returns an error code. 
 *
 * Note:           	
 ********************************************************************/
NEAR unsigned char CANIsBusOffError(void);


/*********************************************************************
 * Function:        NEAR unsigned char CANIsRxRdy(void)
 *
 * PreCondition:   	 
 *
 * Input:       	none
 *                  
 * Output:      	unsigned char status of the request
 *
 * Side Effects:   	
 *
 * Overview:        Returns TRUE if there is data waiting. 
 *
 * Note:           	
 ********************************************************************/
NEAR unsigned char CANIsRxRdy(void);


/*********************************************************************
 * Function:        void CANRead(void)
 *
 * PreCondition:   	 
 *
 * Input:       	none
 *                  
 * Output:      	none
 *
 * Side Effects:   	
 *
 * Overview:        Indicates to the module that the data has been read.
 *
 * Note:           	This effectively frees the active hardware buffer 
 *					to continue receiving.
 ********************************************************************/
void CANRead(void);


/*********************************************************************
 * Function:        NEAR unsigned char CANIsTxRdy(void)
 *
 * PreCondition:   	 
 *
 * Input:       	none
 *                  
 * Output:      	unsigned char status of the request
 *
 * Side Effects:   	
 *
 * Overview:        Returns TRUE if the transmit engine is ready to 
 *					accept new data to transmit.
 *
 * Note:           	This function is as simple as it gets, i.e. direct
 *					access to only one TX buffer. 
 ********************************************************************/
NEAR unsigned char CANIsTxRdy(void);


/*********************************************************************
 * Function:        NEAR unsigned char CANIsMsgSent(void)
 *
 * PreCondition:   	 
 *
 * Input:       	none

⌨️ 快捷键说明

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