📄 canpie.h.svn-base
字号:
/*****************************************************************************\
* CANpie *
* *
* File : canpie.h *
* Description : Definitions / Constants for CANpie *
* Author : Uwe Koppe *
* e-mail : koppe@microcontrol.net *
* *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
* *
* History *
* Vers. Date Comment Aut. *
* ----- ---------- --------------------------------------------- ---- *
* 0.1 04.12.1998 Initial version UK *
* 0.2 29.04.1999 Changed structures, new data type definitions UK *
* 0.3 - no changes - *
* 0.4 - no changes - *
* 0.5 - no changes - *
* 0.6 15.06.2000 moved defintions from cpmsg.h UK *
* set to CANpie release 0.6 *
* 0.7 06.11.2000 added new error codes UK *
* added missing buffer number *
* 0.8 15.02.2001 set to CANpie release 0.8 UK *
* *
\*****************************************************************************/
#ifndef _CANPIE_H_
#define _CANPIE_H_
//------------------------------------------------------------------------------
// CVS version information:
// $Id: canpie.h,v 1.4 2006/03/28 09:53:09 koppe Exp $
// $Name: $ --- $State: Exp $
//------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
/*! \file canpie.h
** \brief CANpie constants, structures and enumerations
**
** This file holds constants and structures used within CANpie.
**
*/
/*----------------------------------------------------------------------------*\
** Include files **
** **
\*----------------------------------------------------------------------------*/
#include "cp_arch.h" // Architecture dependent definitions
/*----------------------------------------------------------------------------*\
** Definitions & Enumerations **
** **
\*----------------------------------------------------------------------------*/
#ifndef CP_CAN_MSG_TIME
#define CP_CAN_MSG_TIME 0
#endif
#ifndef CP_CAN_MSG_USER
#define CP_CAN_MSG_USER 0
#endif
#ifndef CP_CAN_MSG_MACRO
#define CP_CAN_MSG_MACRO 0
#endif
#ifndef CP_CHANNEL_MAX
#define CP_CHANNEL_MAX 1
#endif
#define CP_VERSION_MAJOR 2
#define CP_VERSION_MINOR 0
/*-----------------------------------------------------------------------------
** CP_MASK_XXX
** mask for CAN message (RTR, Extended CAN)
*/
/*-------------------------------------------------------------------*/
/*!
** \def CP_MASK_STD_FRAME
**
** Mask for standard frame (11 bits)
*/
#define CP_MASK_STD_FRAME 0x000007FF
/*-------------------------------------------------------------------*/
/*!
** \def CP_MASK_EXT_FRAME
**
** Mask for extended frame (29 bits)
*/
#define CP_MASK_EXT_FRAME 0x1FFFFFFF
/*-------------------------------------------------------------------*/
/*!
** \def CP_MASK_EXT_BIT
**
** Set the EXT bit (extended frame) in the ubMsgCtrl field of
** the _TsCpCanMsg structure.
*/
#define CP_MASK_EXT_BIT 0x01
/*-------------------------------------------------------------------*/
/*!
** \def CP_MASK_RTR_BIT
**
** Set the RTR bit (remote frame) in the ubMsgCtrl field of
** the _TsCpCanMsg structure.
*/
#define CP_MASK_RTR_BIT 0x02
/*-------------------------------------------------------------------*/
/*!
** \def CP_MASK_OVR_BIT
**
** Set the OVR bit (overrun) in the ubMsgCtrl field of
** the _TsCpCanMsg structure.
*/
#define CP_MASK_OVR_BIT 0x04
/*----------------------------------------------------------------------------*/
/*!
** \enum CpErr
** \brief CANpie Error codes
**
**
*/
enum CpErr {
/*! No error (00dec / 00hex)
*/
CpErr_OK = 0,
/*! Error not specified (01dec / 01hex)
*/
CpErr_GENERIC,
/*! Hardware failure (02dec / 02hex)
*/
CpErr_HARDWARE,
/*! Initialisation failure (03dec / 03hex)
*/
CpErr_INIT_FAIL,
/*! Channel is initialized, ready to run (04dec / 04hex)
*/
CpErr_INIT_READY,
/*! CAN channel was not initialized (05dec / 05hex)
*/
CpErr_INIT_MISSING,
/*! Receive buffer is empty (05dec / 05hex)
*/
CpErr_RCV_EMPTY,
/*! Receive buffer overrun (06dec / 06hex)
*/
CpErr_OVERRUN,
/*! Transmit buffer is full (07dec / 07hex)
*/
CpErr_TRM_FULL,
/*! CAN message has wrong format (10dec / 0Ahex)
*/
CpErr_CAN_MESSAGE = 10,
/*! CAN identifier not valid (11dec / 0Bhex)
*/
CpErr_CAN_ID,
/*! CAN data length code not valid (12dec / 0Chex)
*/
CpErr_CAN_DLC,
/*! FIFO is empty (20dec / 14hex)
*/
CpErr_FIFO_EMPTY = 20,
/*! Message is waiting in FIFO (21dec / 15hex)
*/
CpErr_FIFO_WAIT,
/*! FIFO is full (22dec / 16hex)
*/
CpErr_FIFO_FULL,
/*! FIFO size is out of range (23dec / 17hex)
*/
CpErr_FIFO_SIZE,
/*! Parameter of FIFO function is out of range (24dec / 18hex)
*/
CpErr_FIFO_PARM,
/*! Controller is in error passive (30dec / 1Ehex)
*/
CpErr_BUS_PASSIVE = 30,
/*! Controller is in bus off (31dec / 1Fhex)
*/
CpErr_BUS_OFF,
/*! Controller is in warning status (32dec / 20hex)
*/
CpErr_BUS_WARNING,
/*! Channel out of range (40dec / 28hex)
*/
CpErr_CHANNEL = 40,
/*! Register address out of range (41dec / 29hex)
*/
CpErr_REGISTER,
/*! Baudrate out of range (42dec / 2Ahex)
*/
CpErr_BAUDRATE,
/*! Buffer number out of range (43dec / 2Bhex)
*/
CpErr_BUFFER,
/*! Parameter number out of range (44dec / 2Chex)
*/
CpErr_PARAM,
/*! Function is not supported (50dec / 32hex)
*/
CpErr_NOT_SUPPORTED = 50
};
/*----------------------------------------------------------------------------*/
/*!
** \enum CP_FIFO
** \brief FIFO Buffer numbers
*/
enum CP_FIFO {
CP_FIFO_RCV = 0,
CP_FIFO_TRM
};
/*----------------------------------------------------------------------------*/
/*!
** \enum CP_CALLBACK
** \brief Callback Return Codes
**
** These return values are used by the callback functions that can be
** installed by the function CpUserIntFunctions(). <p>
** \b Example
** \code
** _U08 MyCallback(_TsCpCanMsg * pCanMsgV)
** {
** // Do something with IDs < 100
** if( CpMacGetStdId(pCanMsgV) < 100)
** {
** //.....
** return(CP_CALLBACK_PROCESSED)
** }
**
** // Put all other messages into the FIFO
** return (CP_CALLBACK_PUSH_FIFO);
** }
** \endcode
** <br>
*/
enum CP_CALLBACK {
/*!
** Message was processed by callback and is not inserted in the FIFO
*/
CP_CALLBACK_PROCESSED = 0,
/*!
** Message was processed by callback and is inserted in the FIFO
*/
CP_CALLBACK_PUSH_FIFO
};
/*----------------------------------------------------------------------------*/
/*!
** \enum CP_BAUD
** \brief Fixed baudrates
**
** The values of the enumeration CP_BAUD are used as parameter for the
** functions CpUserBaudrate() and CpCoreBaudrate().
*/
enum CP_BAUD {
/*!
** Baudrate 10 kBit/sec
*/
CP_BAUD_10K = 0,
/*!
** Baudrate 20 kBit/sec
*/
CP_BAUD_20K,
/*!
** Baudrate 50 kBit/sec
*/
CP_BAUD_50K,
/*!
** Baudrate 100 kBit/sec
*/
CP_BAUD_100K,
/*!
** Baudrate 125 kBit/sec
*/
CP_BAUD_125K,
/*!
** Baudrate 250 kBit/sec
*/
CP_BAUD_250K,
/*!
** Baudrate 500 kBit/sec
*/
CP_BAUD_500K,
/*!
** Baudrate 800 kBit/sec
*/
CP_BAUD_800K,
/*!
** Baudrate 1 MBit/sec
*/
CP_BAUD_1M,
/*!
** Use automatic baudrate detection
*/
CP_BAUD_AUTO,
CP_BAUD_MAX = CP_BAUD_AUTO
};
/*----------------------------------------------------------------------------*/
/*!
** \enum CP_CHANNEL
** \brief Channel definition
*/
enum CP_CHANNEL {
CP_CHANNEL_1 = 0,
CP_CHANNEL_2,
CP_CHANNEL_3,
CP_CHANNEL_4,
CP_CHANNEL_5,
CP_CHANNEL_6,
CP_CHANNEL_7,
CP_CHANNEL_8
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -