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

📄 can.h

📁 56f8300E系列dsp的BOOTloader
💻 H
字号:
#ifndef CAN_H
#define CAN_H
/*******************************************************************************
*
* Motorola Inc.
* (c) Copyright 2000 Motorola, Inc.
* ALL RIGHTS RESERVED.
*
********************************************************************************
*
* FILE NAME: can.h
*
*******************************************************************************/
//#include "configdefines.h"
/*
#ifndef SDK_LIBRARY
	

	#ifndef INCLUDE_CAN
		#error INCLUDE_CAN must be defined in appconfig.h to initialize the CAN driver
	#endif
#endif
*/

#include "port.h"

#include "io.h"


	/* values for Cmd */
	#define F_SETFL    0x0005 /* set file status flags */

/* values for OFlags */

#define O_RDONLY   0x0001 
#define O_WRONLY   0x0002
#define O_RDWR     0x0003
#define O_NONBLOCK 0x0008 /* non blocking I/O */
#define O_BLOCK    0x0000 /* blocking I/O 	  */

#define O_CAN_2B                    0x0008  /* */
#define O_LOOP_BACK_RESERVED        0x0010  /* */
#define O_LOOP_BACK                 0x0020  /* */


#define O_CAN_PRIORITY_SCHEDULE 0x0010	


/* types of Tx MSCAN driver assert in case of error */
typedef enum {
	CAN_ASSERT_WARNING,
	CAN_ASSERT_ERROR,
	CAN_ASSERT_BUSOFF
} can_eTxAssert;


/* types of char format */
typedef enum 
{
	CAN_8BIT = 7,
	CAN_16BIT = 8
} can_eFormat;


/* structure type for data exchange  */
typedef struct 
{
	UWord16 length; 		 /* length message */
	unsigned char data[8];	 /* message data */
} can_sData;


/* CAN specific raw call back type */

#if defined(DSP56838EVM)
#if defined( CAN20B )
	typedef  can_sData*  (*can_pRawCallBack)(UWord32);
#else
	typedef  can_sData*  (*can_pRawCallBack)(UWord16);
#endif
#else /* defined(DSP56838EVM) */
	typedef  can_sData*  (*can_pRawCallBack)(UWord32);
#endif /* defined(DSP56838EVM) */
/* error codes */

#define CAN_ERR_LOST			-1	 /* message lost */
#define CAN_ERR_SYNCH			-2	 /* synchronization error */
#define CAN_ERR_BUSOFF			-3	 /* bus off */
#define CAN_ERR_BUSY			1	 /* busy state */
#define CAN_ERR_PARAMETER		2	 /* incorrect parameter in API statement */
#define CAN_ERR_REOPEN			3	 /* opening a buffer for existing CANID*/
#define CAN_ERR_NO_BUFFERS		4	 /* no more free buffers */
#define CAN_ERR_CALL			5	 /* incorrect use of the API statement */


/* CAN clock source options */
#define CAN_EXTAL_CLK           0    /* external CLK usage */    
#define CAN_IP_BUS_CLOCK        1    /* IP Bus are used as external CLK */


#if defined(DSP56838EVM)
/* CAN status values returned by ioctl in CAN_GET_STATUS mode */
#define CAN_SYNCHRONIZED	0x1000	/* MSCAN is synchronized to a bus */
#define CAN_SLEEP			0x400	/* MSCAN is in the SLEEP mode */
#define CAN_WAKEUP			0x80	/* MSCAN is waked up */
#define CAN_RX_WARN			0x40	/* Receiver Warning state */
#define CAN_TX_WARN			0x20	/* Transmitter Warning state */
#define CAN_RX_ERR			0x10	/* Receiver Error Passive state */
#define CAN_TX_ERR			0x08	/* Transmitter Error Passive state */
#define CAN_BUSOFF			0x04	/* Bus-Off state */
#define CAN_OVERRUN			0x02	/* Overrun state */
#define CAN_RX_FULL			0x01	/* Receive Buffer Full */
#else /* defined(DSP56838EVM) */
#define CAN_SYNCHRONIZED	0x0008	/* FlexCAN no error */
#define CAN_SLEEP			0x0000	/* n/a */
#define CAN_WAKEUP			0x0001	/* FlexCAN is waked up */
#define CAN_RX_WARN			0x0100	/* Receiver Warning state */
#define CAN_TX_WARN			0x0200	/* Transmitter Warning state */
#define CAN_RX_ERR			0x0002	/* Receiver Error Passive state */
#define CAN_TX_ERR			0x0002	/* Transmitter Error Passive state */
#define CAN_BUSOFF			0x0004	/* Bus-Off state */
#define CAN_OVERRUN			0x0000	/* n/a */
#define CAN_RX_FULL			0x0000	/* n/a */

#endif /* defined(DSP56838EVM) */


/* CANID status  values returned by ioctl in CANID_GET_STATUS mode */
#define CANID_EMPTY 		0x0001	 /* message buffer is empty */
#define CANID_FULL			0x0002	 /* message buffer is full */
#define CANID_OVERFLOW		0x0004	 /* message buffer data is overwritten */
#define CANID_ERROR		    0x0008	 /* message buffer data is lost */
#define CANID_RESET         0x1000   /* message buffer data is unknown */

extern int CANErrno;	/* last error code in CAN driver */

enum io_can 
{
  CAN_GET_STATUS    =   IO_OFFSET(io_sInterface, pIoctl[0] ),
  CANID_GET_STATUS  =   IO_OFFSET(io_sInterface, pIoctl[1] ),
  CAN_RESET 	    =   IO_OFFSET(io_sInterface, pIoctl[2] ),
  CAN_SET_SLEEP     =   IO_OFFSET(io_sInterface, pIoctl[3] ),
  CAN_SET_WAKEUP    =   IO_OFFSET(io_sInterface, pIoctl[4] ),
  CANID_SET_MASK    =   IO_OFFSET(io_sInterface, pIoctl[5] )
};



#endif /* CAN_H */

⌨️ 快捷键说明

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