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

📄 canpie.h.svn-base

📁 canpie 一个can bus的协议栈 - CAN interface for embedded control - CAN interface for PC (without local
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
/*----------------------------------------------------------------------------*/
/*!
** \enum    CP_MODE
** \brief   Mode of CAN controller
**
** These values are used as parameter for the function CpCoreCANMode() in
** order to change the state of the CAN controller.
*/
enum CP_MODE {
   /*!   Set controller in Stop mode (no reception / transmission possible)
   */
   CP_MODE_STOP = 0,

   /*!   Set controller into normal operation
   */
   CP_MODE_START,

   /*!   Start Autobaud Detection
   */
   CP_MODE_AUTO_BAUD,

   /*!   Set controller into Sleep mode
   */
   CP_MODE_SLEEP
};


/*----------------------------------------------------------------------------*/
/*!
** \enum    CP_STATE
** \brief   State of CAN controller
**
** These values are used as return value for the function CpCoreCANState().
*/
enum CP_STATE {
   /*!
   ** CAN controller is in stopped mode
   */
   CP_STATE_STOPPED  = 0,


   /*!
   ** CAN controller is active, no errors
   */
   CP_STATE_ACTIVE,


   /*!
   ** CAN controller is in Sleep mode
   */
   CP_STATE_SLEEPING,

   /*!
   ** CAN controller is active, warning level is reached
   */
   CP_STATE_BUS_WARN  = 6,

   /*!
   ** CAN controller is error passive
   */
   CP_STATE_BUS_PASSIVE,

   /*!
   ** CAN controller went into Bus Off
   */
   CP_STATE_BUS_OFF,

   /*!
   ** General failure of physical layer detected (if supported by hardware)
   */
   CP_STATE_PHY_FAULT = 10,

   /*!
   ** Fault on CAN-H detected (Low Speed CAN)
   */
   CP_STATE_PHY_H,

   /*!
   ** Fault on CAN-L detected (Low Speed CAN)
   */
   CP_STATE_PHY_L,

   CP_STATE_ERR_BIT   = 0x10,
   CP_STATE_ERR_STUFF = 0x20,
   CP_STATE_ERR_FORM  = 0x30,
   CP_STATE_ERR_CRC   = 0x40,
   CP_STATE_ERR_ACK   = 0x50
};


/*----------------------------------------------------------------------------*/
/*!
** \enum    CP_BUFFER
** \brief   Buffer definition
**
** The enumeration CP_BUFFER is used to define a message buffer inside a
** FullCAN controller. The index for the first buffer starts at 1.
*/
enum CP_BUFFER {
   CP_BUFFER_1 = 1,
   CP_BUFFER_2,
   CP_BUFFER_3,
   CP_BUFFER_4,
   CP_BUFFER_5,
   CP_BUFFER_6,
   CP_BUFFER_7,
   CP_BUFFER_8,
   CP_BUFFER_9,
   CP_BUFFER_10,
   CP_BUFFER_11,
   CP_BUFFER_12,
   CP_BUFFER_13,
   CP_BUFFER_14,
   CP_BUFFER_15
};


/*----------------------------------------------------------------------------*/
/*!
** \enum    CP_BUFFER_DIR
** \brief   Buffer direction definition
*/
enum CP_BUFFER_DIR {
   /*!
   **    Buffer direction is receive
   */
   CP_BUFFER_DIR_RX = 0,

   /*!
   **    Buffer direction is transmit
   */
   CP_BUFFER_DIR_TX
};


/*----------------------------------------------------------------------------*\
** Structures                                                                 **
**                                                                            **
\*----------------------------------------------------------------------------*/


struct CpTime_s {
   _U32  ulSec1970;
   _U32  ulNanoSec;
};

typedef struct CpTime_s  _TsCpTime;


/*----------------------------------------------------------------------------*/
/*!
** \struct  CpCanMsg_s   canpie.h
** \brief   CAN message structure
**
** For transmission and reception of CAN messages a structure which holds
** all necessary informations is used. The structure has the following
** data fields:
*/
struct CpCanMsg_s {

   /*!   The identifier field may have 11 bits for standard frames
   **    (CAN specification 2.0A) or 29 bits for extended frames
   **    (CAN specification 2.0B). The three most significant bits
   **    are reserved (always read 0).
   */
   union {
      _U16  uwStd;
      _U32  ulExt;
   } tuMsgId;

   /*!   The data field has up to 8 bytes (64 bit) of message data.
   **    The number of used bytes is described via the structure
   **    member <b>ubDLC</b>.
   */
   union {
      /*!   byte access, array of 8 byte     */
      _U08  aubByte[8];

      /*!   word access, array of 4 words    */
      _U16  auwWord[4];
      _U32  aulLong[2];
   } tuMsgData;


   /*!   The data length code denotes the number of data bytes
   **    which are transmitted by a message.
   **    The possible value range for the data length code is
   **    from 0 to 8 (bytes).<p>
   */
   _U08  ubMsgDLC;


   /*!   The structure member <b>ubMsgCtrl</b> defines the
   **    different data frames (2.0A / 2.0B) and the RTR frames.
   **    <ul>
   **    <li>Bit 0: Extended Frame if set to 1, else Standard Frame
   **    <li>Bit 1: Remote Frame if set to 1, else Data Frame
   **    <li>Bit 2: Receiver Overrun if set to 1, else normal reception
   **    </ul>
   */
   _U08  ubMsgCtrl;


#if CP_CAN_MSG_TIME == 1
   /*!   The time stamp field defines the time when a CAN message
   **    was received by the CAN controller. The time stamp is a
   **    relative value, which is created by a free running timer.
   **    The time base is one microsecond (1 us). This means a
   **    maximum time span of 4294,96 seconds (1 hour 11 minutes)
   **    between two messages can be measured. This is an optional
   **    field (available if #CP_CAN_MSG_TIME is set to 1).
   */
   _TsCpTime ulMsgTime;
#endif

#if CP_CAN_MSG_USER == 1

   /*!   The field user data can hold a 32 bit value, which is
   **    defined by the user. This is an optional field
   **    (available if #CP_CAN_MSG_USER is set to 1).
   */
   _U32  ulMsgUser;
#endif

};



/*----------------------------------------------------------------------------*/
/*!
** \typedef _TsCpCanMsg
** \brief   CAN message structure
**
** For transmission and reception of CAN messages the structure CpCanMsg_s
** is used.
*/
typedef struct CpCanMsg_s  _TsCpCanMsg;


/*----------------------------------------------------------------------------*/
/*!
** \struct  CpStruct_HDI   canpie.h
** \brief   Hardware description interface
**
** The Hardware Description Interface provides a method to gather
** information about the CAN hardware and the functionality of the driver.
** All items in the structure CpStruct_HDI are constant and must be
** supplied by the designer of the CAN driver. The hardware description
** structure is available for every physical CAN channel.
*/

struct CpHdi_s {
   /*!   Bit coded value that decribes the features of the CAN driver.
   **    <ul>
   **    <li>Bit 0/1: 0 = Standard Frame, 1 = Extended Frame passive,
   **        2 = Extended Frame active
   **    <li>Bit 2: 0 = BasicCAN, 1 = FullCAN
   **    <li>Bit 3: 0 = No IRQ Handler, 1 = Has IRQ Handler
   **    <li>Bit 4: 0 = No identifier filter, 1 = software identifier filter
   **    <li>Bit 5: 0 = No timestamp, 1 = has timestamp
   **    <li>Bit 6: 0 = No user data field, 1 = has user data field
   **    <li>Bit 7: reserved
   **    </ul>
   */
   _U08  ubSupportFlags;

   /*!   Constant value that identifies the used CAN controller
   **    chip. Possible values for this member are listed
   **    in the header file cp_cc.h
   */
   _U08  ubControllerType;

   /*!   Defines the number of the interrupt which is used.
   **    If the flag IRQHandler is set to 0, the value of
   **    IRQNumber will be undefined.
   */
   _U08  ubIRQNumber;

   /*!   Holds the major version number of the CANpie driver
   **    release (current value = 0).
   */
   _U08  ubVersionMajor;

   /*!   Holds the minor version number of the CANpie
   **    driver release (current value = 4).
   */
   _U08  ubVersionMinor;

   /*!   A null terminated string which holds the name of the
   **    specific CAN driver. The string can be used to
   **    distinguish between different vendors.
   */
   char* szDriverName;

   /*!   A null terminated string which holds the version of
   **    the specific CAN driver (e.g. DLL version, firmware
   **    version).
   */
   char* szVersionNumber;
};


/*----------------------------------------------------------------------------*/
/*!
** \typedef CpStruct_HDI
** \brief   Hardware description interface structure
**
** The structure CpHdi_s provides fields to gather information about
** the CAN hardware. This typedef makes it compatible to older versions
** of CANpie. Please use _TsCpHdi for new applications.
*/
typedef struct CpHdi_s  CpStruct_HDI;


/*----------------------------------------------------------------------------*/
/*!
** \typedef _TsCpHdi
** \brief   Hardware description interface structure
**
** The structure CpHdi_s provides fields to gather information about
** the CAN hardware.
*/
typedef struct CpHdi_s  _TsCpHdi;


/*----------------------------------------------------------------------------*/
/*!
** \struct  CpBitTiming_s   canpie.h
** \brief   Bit timing structure
**
*/
struct CpBitTiming_s {

   /*!   holds the value from enum CP_BAUD
   */
   _U08     ubBaudSel;

   /*!   Bit timing register 0
   */
   _U08     ubBtr0;

   /*!   Bit timing register 1
   */
   _U08     ubBtr1;

   /*!   Syncronisation jump width
   */
   _U08     ubSjw;


   /*!   Baudrate prescaler
   */
   _U08     ubBrp;
};


typedef struct CpBitTiming_s  _TsCpBitTiming;


/*----------------------------------------------------------------------------*/
/*!
** \struct  CpStats_s   canpie.h
** \brief   CAN statistic structure
**
*/
struct CpStats_s {

   /*!   Total number of received data & remote frames
   */
   _U32     ulRcvMsgCount;

   /*!   Total number of transmitted data & remote frames
   */
   _U32     ulTrmMsgCount;

   /*!   Total number of error frames
   */
   _U32     ulErrMsgCount;

};

typedef struct CpStats_s _TsCpStats;



#endif   /* _CANPIE_H_   */

⌨️ 快捷键说明

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