mirror of https://github.com/rusefi/openblt.git
Refs #316. Added Kvaser Leaf Light v2 CAN interface support to LibOpenBLT.
git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@352 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
This commit is contained in:
parent
dbd3903f11
commit
cd29bb84b9
Binary file not shown.
|
@ -0,0 +1,249 @@
|
|||
/*
|
||||
** Copyright 1999 by KVASER AB
|
||||
** P.O Box 4076 SE-51104 KINNAHULT, SWEDEN
|
||||
** E-mail: staff@kvaser.se WWW: http://www.kvaser.se
|
||||
**
|
||||
** This software is furnished under a license and may be used and copied
|
||||
** only in accordance with the terms of such license.
|
||||
**
|
||||
**
|
||||
** Description:
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** DO NOT USE THIS FILE. THE DATA STRUCTURES AND CONSTANTS HERE ARE
|
||||
** NOT YET IMPLEMENTED AND WILL CHANGE IN A FUTURE RELEASE.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
*/
|
||||
#ifndef _CANEVT_H_
|
||||
#define _CANEVT_H_
|
||||
|
||||
#include <pshpack1.h>
|
||||
|
||||
#define CANEVT_NO_COMMAND 0
|
||||
|
||||
// Events
|
||||
#define CANEVT_RECEIVE_MSG 1
|
||||
#define CANEVT_STATISTIC_STD 2
|
||||
#define CANEVT_STATISTIC_EXT 3
|
||||
#define CANEVT_CHIP_STATE 4
|
||||
#define CANEVT_CLOCK_OVERFLOW 5
|
||||
#define CANEVT_TRIGGER 6
|
||||
#define CANEVT_ERROR 7
|
||||
#define CANEVT_TIMER 8
|
||||
#define CANEVT_TRANSCEIVER 9
|
||||
|
||||
// Commands
|
||||
#define CANEVT_TRANSMIT_MSG 10
|
||||
#define CANEVT_SET_TIMER 11
|
||||
#define CANEVT_RESET_CLOCK 12
|
||||
#define CANEVT_INIT_CHIP 13
|
||||
#define CANEVT_START_CHIP 14
|
||||
#define CANEVT_STOP_CHIP 15
|
||||
#define CANEVT_RESET_CHIP 16
|
||||
#define CANEVT_SET_ACCEPTANCE 17
|
||||
//#define CANEVT_SET_DRIVERMODE 18
|
||||
#define CANEVT_GET_STATISTIC 19
|
||||
#define CANEVT_GET_CHIP_STATE 20
|
||||
#define CANEVT_SET_OUTPUT_MODE 21
|
||||
#define CANEVT_FUNCTION 22
|
||||
#define CANEVT_GET_TRANSCEIVER 23
|
||||
#define CANEVT_GET_TRANSCEIVER_RESP 24
|
||||
#define CANEVT_SET_TRANSCEIVER 25
|
||||
// 26, 27, 28 reserved
|
||||
#define CANEVT_INIT_HARDWARE 29
|
||||
#define CANEVT_EXIT_HARDWARE 30
|
||||
#define CANEVT_READ_CLOCK 31
|
||||
|
||||
|
||||
#define MAX_MSG_LEN 8
|
||||
#define EXT_MSG 0x80000000 // signs an extended identifier
|
||||
|
||||
#define MSGFLAG_ERROR_FRAME 0x01 // Msg is a bus error
|
||||
#define MSGFLAG_OVERRUN 0x02 // Msgs following this has been lost
|
||||
#define MSGFLAG_NERR 0x04 // NERR active during this msg
|
||||
#define MSGFLAG_WAKEUP 0x08 // Msg rcv'd in wakeup mode
|
||||
#define MSGFLAG_REMOTE_FRAME 0x10 // Msg is a remote frame
|
||||
#define MSGFLAG_RESERVED_1 0x20 // Reserved for future usage
|
||||
#define MSGFLAG_TX 0x40 // TX acknowledge
|
||||
#define MSGFLAG_TXRQ 0x80 // TX request
|
||||
|
||||
typedef struct {
|
||||
unsigned long id;
|
||||
unsigned char flags;
|
||||
unsigned char dlc;
|
||||
unsigned char data[MAX_MSG_LEN];
|
||||
} CanEventMessage;
|
||||
|
||||
|
||||
#define CHIPSTAT_BUSOFF 0x01
|
||||
#define CHIPSTAT_ERROR_PASSIVE 0x02
|
||||
#define CHIPSTAT_ERROR_WARNING 0x04
|
||||
#define CHIPSTAT_ERROR_ACTIVE 0x08
|
||||
|
||||
typedef struct {
|
||||
unsigned char busStatus;
|
||||
unsigned char txErrorCounter;
|
||||
unsigned char rxErrorCounter;
|
||||
} CanEventChipState;
|
||||
|
||||
typedef struct {
|
||||
unsigned long stdData;
|
||||
unsigned long stdRemote;
|
||||
unsigned long errFrame;
|
||||
unsigned short busLoad; // 0.00-100.00%
|
||||
} CanEventStatisticsStd;
|
||||
|
||||
typedef struct {
|
||||
unsigned long extData;
|
||||
unsigned long extRemote;
|
||||
unsigned long ovrFrame;
|
||||
} CanEventStatisticsExt;
|
||||
|
||||
typedef struct {
|
||||
unsigned char code; // qqq
|
||||
} CanEventErrorCode;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// commands
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
typedef struct {
|
||||
unsigned long code;
|
||||
unsigned long mask;
|
||||
} CanEventAcceptanceFilter;
|
||||
|
||||
typedef struct {
|
||||
unsigned char mode;
|
||||
} CanEventDriverMode;
|
||||
|
||||
typedef struct {
|
||||
unsigned long rate;
|
||||
} CanEventSetTimer;
|
||||
|
||||
typedef struct {
|
||||
unsigned char level;
|
||||
} CanEventSetDebugLevel;
|
||||
|
||||
#define OUTPUT_MODE_SILENT 0
|
||||
#define OUTPUT_MODE_NORMAL 1
|
||||
|
||||
typedef struct {
|
||||
unsigned char mode;
|
||||
} CanEventSetOutputMode;
|
||||
|
||||
typedef struct {
|
||||
unsigned char code;
|
||||
} CanEventFunction;
|
||||
|
||||
// The following definitions are copied from lapcmds.h !!
|
||||
#if 0
|
||||
#define TRANSCEIVER_EVENT_ERROR 1
|
||||
#define TRANSCEIVER_EVENT_CHANGED 2
|
||||
|
||||
// event
|
||||
#define TRANSCEIVER_EVENT_NONE 0
|
||||
#define TRANSCEIVER_EVENT_NERR 1
|
||||
#define TRANSCEIVER_EVENT_REMOVED 2
|
||||
#define TRANSCEIVER_EVENT_DETECTED 3
|
||||
|
||||
// type
|
||||
#define TRANSCEIVER_TYPE_NONE 0
|
||||
#define TRANSCEIVER_TYPE_251 1
|
||||
#define TRANSCEIVER_TYPE_252 2
|
||||
#define TRANSCEIVER_TYPE_DNOPTO 3
|
||||
#define TRANSCEIVER_TYPE_W210 4
|
||||
#define TRANSCEIVER_TYPE_SWC_PROTO 5 // Prototype. Driver may latch-up.
|
||||
#define TRANSCEIVER_TYPE_SWC 6
|
||||
|
||||
|
||||
// lineMode
|
||||
#define TRANSCEIVER_LINEMODE_NA 0
|
||||
#define TRANSCEIVER_LINEMODE_TWO_LINE 1
|
||||
#define TRANSCEIVER_LINEMODE_CAN_H 2
|
||||
#define TRANSCEIVER_LINEMODE_CAN_L 3
|
||||
#define TRANSCEIVER_LINEMODE_SWC_SLEEP 4 // SWC Sleep Mode.
|
||||
#define TRANSCEIVER_LINEMODE_SWC_NORMAL 5 // SWC Normal Mode.
|
||||
#define TRANSCEIVER_LINEMODE_SWC_FAST 6 // SWC High-Speed Mode.
|
||||
#define TRANSCEIVER_LINEMODE_SWC_WAKEUP 7 // SWC Wakeup Mode.
|
||||
#define TRANSCEIVER_LINEMODE_SLEEP 8
|
||||
#define TRANSCEIVER_LINEMODE_NORMAL 9
|
||||
#define TRANSCEIVER_LINEMODE_STDBY 10 // Standby for those who support it
|
||||
#define TRANSCEIVER_LINEMODE_TT_CAN_H 11 // Truck & Trailer: operating mode single wire using CAN high
|
||||
#define TRANSCEIVER_LINEMODE_TT_CAN_L 12 // Truck & Trailer: operating mode single wire using CAN low
|
||||
#define TRANSCEIVER_LINEMODE_OEM1 13 // Reserved for OEM apps
|
||||
#define TRANSCEIVER_LINEMODE_OEM2 14 // Reserved for OEM apps
|
||||
#define TRANSCEIVER_LINEMODE_OEM3 15 // Reserved for OEM apps
|
||||
#define TRANSCEIVER_LINEMODE_OEM4 16 // Reserved for OEM apps
|
||||
|
||||
|
||||
// resNet
|
||||
#define TRANSCEIVER_RESNET_NA 0
|
||||
#define TRANSCEIVER_RESNET_MASTER 1
|
||||
#define TRANSCEIVER_RESNET_MASTER_STBY 2
|
||||
#define TRANSCEIVER_RESNET_SLAVE 3
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
unsigned char event; // TRANSCEIVER_EVENT_xxx
|
||||
} CanEventTransceiver;
|
||||
|
||||
typedef struct {
|
||||
unsigned char type; // TRANSCEIVER_TYPE_xxx
|
||||
unsigned char lineMode; // TRANSCEIVER_LINEMODE_xxx
|
||||
unsigned char resNet; // TRANSCEIVER_RESNET_xxx
|
||||
} CanEventGetTransceiverResponse;
|
||||
|
||||
typedef struct {
|
||||
unsigned char type; // TRANSCEIVER_TYPE_xxx
|
||||
unsigned char lineMode; // TRANSCEIVER_LINEMODE_xxx
|
||||
unsigned char resNet; // TRANSCEIVER_RESNET_xxx
|
||||
} CanEventSetTransceiver;
|
||||
|
||||
|
||||
typedef union {
|
||||
CanEventMessage canEventMessage;
|
||||
CanEventChipState canEventChipState;
|
||||
CanEventStatisticsStd canEventStatisticsStd;
|
||||
CanEventStatisticsExt canEventStatisticsExt;
|
||||
CanEventErrorCode canEventErrorCode;
|
||||
CanEventAcceptanceFilter canEventAcceptanceFilter;
|
||||
CanEventDriverMode canEventDriverMode;
|
||||
CanEventSetTimer canEventSetTimer;
|
||||
CanEventSetDebugLevel canEventSetDebugLevel;
|
||||
CanEventSetOutputMode canEventSetOutputMode;
|
||||
CanEventFunction canEventFunction;
|
||||
CanEventTransceiver canEventTransceiver;
|
||||
CanEventGetTransceiverResponse canEventGetTransceiverResponse;
|
||||
CanEventSetTransceiver canEventSetTransceiver;
|
||||
} CanEventUnion;
|
||||
|
||||
|
||||
typedef struct {
|
||||
unsigned char tag;
|
||||
unsigned char chanIndex;
|
||||
unsigned char _internal1;
|
||||
unsigned char _internal2;
|
||||
unsigned long timeStamp;
|
||||
CanEventUnion x;
|
||||
} CanEvent, *PCanEvent;
|
||||
|
||||
|
||||
#include <poppack.h>
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,497 @@
|
|||
/**
|
||||
* \section LICENSE
|
||||
* Copyright 1994-2013 by KVASER AB, SWEDEN
|
||||
*
|
||||
* WWW: http://www.kvaser.com
|
||||
*
|
||||
* This software is furnished under a license and may be used and copied
|
||||
* only in accordance with the terms of such license.
|
||||
*
|
||||
* \section DESCRIPTION
|
||||
*
|
||||
* Definitions for the CANLIB API.
|
||||
*
|
||||
* \file canlib.h
|
||||
* \author Kvaser AB
|
||||
*
|
||||
* \note MATLAB users on Windows: if you define WIN32_LEAN_AND_MEAN before
|
||||
* including this file, you will see a lot less warnings.
|
||||
*
|
||||
* \defgroup General General
|
||||
* \defgroup CAN CAN
|
||||
* \defgroup ObjectBuffers Object buffers
|
||||
* \win_start
|
||||
* \defgroup TimeDomainHandling Time Domain Handling
|
||||
* \defgroup NamedParameterSettings Named Parameter Settings
|
||||
* \defgroup tScript t-script
|
||||
* \win_end
|
||||
*/
|
||||
#ifndef _CANSTAT_H_
|
||||
#define _CANSTAT_H_
|
||||
|
||||
//
|
||||
// Don't forget to update canGetErrorText in canlib.c if this is changed!
|
||||
//
|
||||
|
||||
/**
|
||||
* \name canERR_xxx
|
||||
* \anchor canERR_xxx
|
||||
*
|
||||
* Generally, a return code greater than or equal to zero means success. A
|
||||
* value less than zero means failure.
|
||||
*
|
||||
* You should avoid testing for a specific error code unless it is explicitly
|
||||
* stated in the documentation for the API in question that this specific error
|
||||
* code is returned. Instead, check if the error code is less than zero. Use
|
||||
* \ref canGetErrorText() to obtain an error message suitable for a message to the
|
||||
* user, or for a line in an error log file.
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* <b>Normal successful completion</b>; The driver is just fine, and really
|
||||
* believes it carried out your command to everyone's satisfaction.
|
||||
*/
|
||||
canOK = 0,
|
||||
/**
|
||||
* <b>Error in one or more parameters</b>; a parameter \ref canERR_xxx
|
||||
* specified in the call was invalid, out of range, or so. This status code
|
||||
* will also be returned when the call is not implemented.
|
||||
*/
|
||||
canERR_PARAM = -1,
|
||||
/**
|
||||
* <b>There were no messages to read</b>; A function tried to read a message,
|
||||
* but there was no message to read.
|
||||
*/
|
||||
canERR_NOMSG = -2,
|
||||
/**
|
||||
* <b>Specified device or channel not found.</b> There is no hardware
|
||||
* available that matches the given search criteria. For example, you may
|
||||
* have specified \ref canOPEN_REQUIRE_EXTENDED but there's no controller
|
||||
* capable of extended CAN. You may have specified a channel number that is
|
||||
* out of the range for the hardware in question. You may have requested
|
||||
* exclusive access to a channel, but the channel is already occupied.
|
||||
*/
|
||||
canERR_NOTFOUND = -3,
|
||||
/**
|
||||
* <b>Out of memory</b>; A memory allocation failed.
|
||||
*/
|
||||
canERR_NOMEM = -4,
|
||||
/**
|
||||
* <b>No channels available</b>; There is indeed hardware matching the
|
||||
* criteria you specified, but there are no channels available, or the
|
||||
* channel you specified is already occupied.
|
||||
*/
|
||||
canERR_NOCHANNELS = -5,
|
||||
|
||||
canERR_INTERRUPTED = -6, ///< Interrupted by signals
|
||||
/**
|
||||
* <b>Timeout occurred</b>; A function waited for something to happen (for
|
||||
* example, the arrival of a message), but that something didn't happen.
|
||||
*/
|
||||
canERR_TIMEOUT = -7,
|
||||
/**
|
||||
* <b>The library is not initialized</b>; The driver is not
|
||||
* initialized. \ref canInitializeLibrary() was probably not called?
|
||||
*/
|
||||
canERR_NOTINITIALIZED = -8,
|
||||
/**
|
||||
* <b>Out of handles</b>; No handles are available inside canlib32. The
|
||||
* application has too many handles open (i.e. has called \ref canOpenChannel() too
|
||||
* many times, or there's a memory leak somewhere.)
|
||||
*
|
||||
* \note We are not talking about Windows handles here, it's CANLIB's own
|
||||
* internal handles.
|
||||
*/
|
||||
canERR_NOHANDLES = -9,
|
||||
/**
|
||||
* <b>Handle is invalid</b>; The CANLIB handle you specified (if the API call
|
||||
* includes a handle) is not valid. Ensure you are passing the handle and
|
||||
* not, for example, a channel number.
|
||||
*/
|
||||
canERR_INVHANDLE = -10,
|
||||
canERR_INIFILE = -11, ///< Error in the ini-file (16-bit only)
|
||||
/**
|
||||
* <b>Driver type not supported</b>; CAN driver mode is not supported by the
|
||||
* present hardware.
|
||||
*/
|
||||
canERR_DRIVER = -12,
|
||||
/**
|
||||
* <b>Transmit buffer overflow</b>; The transmit queue was full, so the
|
||||
* message was dropped.
|
||||
*/
|
||||
canERR_TXBUFOFL = -13,
|
||||
canERR_RESERVED_1 = -14, ///< Reserved
|
||||
/**
|
||||
* <b>A hardware error has occurred</b>; Something probably related to the
|
||||
* hardware happened. This could mean that the device does not respond (IRQ
|
||||
* or address conflict?), or that the response was invalid or unexpected
|
||||
* (faulty card?).
|
||||
*/
|
||||
canERR_HARDWARE = -15,
|
||||
/**
|
||||
* <b>A driver DLL can't be found or loaded</b>; (One of) the DLL(s)
|
||||
* specified in the registry failed to load. This could be a driver
|
||||
* installation problem.
|
||||
*/
|
||||
canERR_DYNALOAD = -16,
|
||||
/**
|
||||
* <b>A DLL seems to have wrong version</b>; DLL version mismatch. (One of)
|
||||
* the DLL(s) specified in the registry is - probably - too old, or - less
|
||||
* likely - too new.
|
||||
*/
|
||||
canERR_DYNALIB = -17,
|
||||
/**
|
||||
* <b>Error when initializing a DLL</b>; Something failed when a device
|
||||
* driver was being initialized. In other words, we can open the driver but
|
||||
* it makes a lot of fuss about something we don't understand.
|
||||
*/
|
||||
canERR_DYNAINIT = -18,
|
||||
canERR_NOT_SUPPORTED = -19, ///< Operation not supported by hardware or firmware
|
||||
canERR_RESERVED_5 = -20, ///< Reserved
|
||||
canERR_RESERVED_6 = -21, ///< Reserved
|
||||
canERR_RESERVED_2 = -22, ///< Reserved
|
||||
/**
|
||||
* <b>Can't find or load kernel driver</b>; A device driver (kernel mode
|
||||
* driver for NT, VxD for W95/98) failed to load; or the DLL could not open
|
||||
* the device. Privileges? Driver file missing?
|
||||
*/
|
||||
canERR_DRIVERLOAD = -23,
|
||||
/**
|
||||
* <b>DeviceIOControl failed</b>; Use Win32 GetLastError() to learn what
|
||||
* really happened.
|
||||
*/
|
||||
canERR_DRIVERFAILED = -24,
|
||||
canERR_NOCONFIGMGR = -25, ///< Can't find req'd config s/w (e.g. CS/SS)
|
||||
canERR_NOCARD = -26, ///< The card was removed or not inserted
|
||||
canERR_RESERVED_7 = -27, ///< Reserved
|
||||
/**
|
||||
* <b>Error (missing data) in the Registry</b>; A registry key is missing,
|
||||
* invalid, malformed, has gone for lunch or what not. can_verify.exe might
|
||||
* provide some insight.
|
||||
*/
|
||||
canERR_REGISTRY = -28,
|
||||
canERR_LICENSE = -29, ///< The license is not valid.
|
||||
/**
|
||||
* <b>Internal error in the driver</b>; Indicates an error condition in the
|
||||
* driver or DLL, which couldn't be properly handled. Please contact the
|
||||
* friendly support at support@kvaser.com.
|
||||
*/
|
||||
canERR_INTERNAL = -30,
|
||||
/**
|
||||
* <b>Access denied</b>; This means that you tried to set the bit rate on a
|
||||
* handle to which you haven't got init access or you tried to open a channel
|
||||
* that already is open with init access. See \ref canOpenChannel() for more
|
||||
* information about init access.
|
||||
*/
|
||||
canERR_NO_ACCESS = -31,
|
||||
/**
|
||||
* <b>Not implemented</b>; The requested feature or function is not
|
||||
* implemented in the device you are trying to use it on.
|
||||
*/
|
||||
canERR_NOT_IMPLEMENTED = -32,
|
||||
/**
|
||||
* <b>Device File error</b>; An error has occured when trying to access a
|
||||
* file on the device.
|
||||
*/
|
||||
canERR_DEVICE_FILE = -33,
|
||||
/**
|
||||
* <b>Host File error</b>; An error has occured when trying to access a file on the host.
|
||||
*
|
||||
*/
|
||||
canERR_HOST_FILE = -34,
|
||||
/**
|
||||
* <b>Disk error</b>; A disk error has occurred. Verify that the disk is
|
||||
* initialized.
|
||||
*/
|
||||
canERR_DISK = -35,
|
||||
/**
|
||||
* <b>CRC error</b>; The CRC calculation did not match the expected result.
|
||||
*/
|
||||
canERR_CRC = -36,
|
||||
/**
|
||||
* <b>Configuration Error</b>; The configuration is corrupt.
|
||||
*/
|
||||
canERR_CONFIG = -37,
|
||||
/**
|
||||
* <b>Memo Error</b>; Other configuration error.
|
||||
*/
|
||||
canERR_MEMO_FAIL = -38,
|
||||
/**
|
||||
* <b>Script Fail</b>; A script has failed.
|
||||
*
|
||||
* \note This code represents several different failures, for example:
|
||||
* - Trying to load a corrupt file or not a .txe file
|
||||
* - Trying to start a t script that has not been loaded
|
||||
* - Trying to load a t script compiled with the wrong version of the t compiler
|
||||
* - Trying to unload a t script that has not been stopped
|
||||
* - Trying to use an envvar that does not exist
|
||||
*/
|
||||
canERR_SCRIPT_FAIL = -39,
|
||||
|
||||
/**
|
||||
* <b>The t script version dosen't match the version(s) that the device firmware supports.</b>;
|
||||
*/
|
||||
canERR_SCRIPT_WRONG_VERSION = -40,
|
||||
|
||||
|
||||
// The last entry - a dummy so we know where NOT to place a comma.
|
||||
canERR__RESERVED = -41 ///< Reserved
|
||||
} canStatus;
|
||||
|
||||
|
||||
/**
|
||||
* \name Convenience
|
||||
* @{
|
||||
*/
|
||||
#define CANSTATUS_SUCCESS(X) ((X) == canOK)
|
||||
#define CANSTATUS_FAILURE(X) ((X) != canOK)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name canEVENT_xxx WM__CANLIB notification codes
|
||||
* \anchor canEVENT_xxx
|
||||
* Appears in the notification \c WM__CANLIB message.
|
||||
* @{
|
||||
*/
|
||||
#define canEVENT_RX 32000 ///< when the queue of received CAN messages goes from empty to non-empty
|
||||
#define canEVENT_TX 32001 ///< when a CAN message has been transmitted
|
||||
#define canEVENT_ERROR 32002 ///< when a CAN bus error is reported by the CAN controller
|
||||
#define canEVENT_STATUS 32003 ///< when the CAN controller changes state
|
||||
#define canEVENT_ENVVAR 32004 ///< An envvar changed
|
||||
# define canEVENT_BUSONOFF 32005 ///< Bus on/off status changed
|
||||
# define canEVENT_REMOVED 32006 ///< Device removed
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name canNOTIFY_xxx
|
||||
* \anchor canNOTIFY_xxx
|
||||
*
|
||||
* These are notification codes used in calls to \ref canSetNotify() and \ref kvSetNotifyCallback().
|
||||
*
|
||||
* This can be \ref canNOTIFY_NONE (zero), meaning that no event notification is to
|
||||
* occur, or a combination of any of the following constants
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define canNOTIFY_NONE 0 ///< Turn notifications off.
|
||||
#define canNOTIFY_RX 0x0001 ///< CAN message reception notification
|
||||
#define canNOTIFY_TX 0x0002 ///< CAN message transmission notification
|
||||
#define canNOTIFY_ERROR 0x0004 ///< CAN bus error notification
|
||||
#define canNOTIFY_STATUS 0x0008 ///< CAN chip status change
|
||||
#define canNOTIFY_ENVVAR 0x0010 ///< An environment variable was changed by a script
|
||||
# define canNOTIFY_BUSONOFF 0x0020 ///< Notify on bus on/off status changed
|
||||
# define canNOTIFY_REMOVED 0x0040 ///< Notify on device removed
|
||||
/** @} */
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup InformationServices
|
||||
* \name canSTAT_xxx
|
||||
* \anchor canSTAT_xxx
|
||||
*
|
||||
* The following circuit status flags are returned by \ref canReadStatus(). Note
|
||||
* that more than one flag might be set at any one time.
|
||||
*
|
||||
* \note Usually both \ref canSTAT_HW_OVERRUN and \ref canSTAT_SW_OVERRUN are set
|
||||
* when overrun has occurred. This is because the kernel driver can't see the
|
||||
* difference between a software overrun and a hardware overrun. So the code
|
||||
* should always test for both types of overrun using the \ref canSTAT_OVERRUN
|
||||
* "flag".
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define canSTAT_ERROR_PASSIVE 0x00000001 ///< The circuit is error passive
|
||||
#define canSTAT_BUS_OFF 0x00000002 ///< The circuit is Off Bus
|
||||
#define canSTAT_ERROR_WARNING 0x00000004 ///< At least one error counter > 96
|
||||
#define canSTAT_ERROR_ACTIVE 0x00000008 ///< The circuit is error active.
|
||||
#define canSTAT_TX_PENDING 0x00000010 ///< There are messages pending transmission
|
||||
#define canSTAT_RX_PENDING 0x00000020 ///< There are messages in the receive buffer
|
||||
#define canSTAT_RESERVED_1 0x00000040
|
||||
#define canSTAT_TXERR 0x00000080 ///< There has been at least one TX error
|
||||
#define canSTAT_RXERR 0x00000100 ///< There has been at least one RX error of some sort
|
||||
#define canSTAT_HW_OVERRUN 0x00000200 ///< The has been at least one HW buffer overflow
|
||||
#define canSTAT_SW_OVERRUN 0x00000400 ///< The has been at least one SW buffer overflow
|
||||
#define canSTAT_OVERRUN (canSTAT_HW_OVERRUN | canSTAT_SW_OVERRUN) ///< For convenience.
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Message information flags, < 0x100
|
||||
* \anchor canMSG_xxx
|
||||
*
|
||||
* The following flags can be returned from \ref canRead() et al, or passed to
|
||||
* \ref canWrite().
|
||||
*
|
||||
* All flags and/or combinations of them are meaningful for received messages.
|
||||
*
|
||||
* \ref canMSG_RTR, \ref canMSG_STD, \ref canMSG_EXT, \ref canMSG_WAKEUP and
|
||||
* \ref canMSG_ERROR_FRAME are meaningful also for transmitted messages.
|
||||
* \ref canMSG_SINGLE_SHOT is only for transmission.
|
||||
*
|
||||
* Note that \ref canMSG_RTR cannot be set for CAN FD messages.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define canMSG_MASK 0x00ff ///< Used to mask the non-info bits
|
||||
#define canMSG_RTR 0x0001 ///< Message is a remote request
|
||||
#define canMSG_STD 0x0002 ///< Message has a standard ID
|
||||
#define canMSG_EXT 0x0004 ///< Message has an extended ID
|
||||
#define canMSG_WAKEUP 0x0008 ///< Message to be sent / was received in wakeup mode
|
||||
|
||||
/**
|
||||
* NERR was active during the message
|
||||
*
|
||||
* The NERR flag is set by the CAN transceiver when certain CAN bus wire faults
|
||||
* occur, namely:
|
||||
* \li CANH wire interrupted
|
||||
* \li CANL wire interrupted
|
||||
* \li CANH short-circuited to battery
|
||||
* \li CANH short-circuited to VCC
|
||||
* \li CANL short-circuited to ground
|
||||
* \li CANH short-circuited to ground
|
||||
* \li CANL short-circuited to battery
|
||||
* \li CANL short-circuited to VCC
|
||||
* \li CANL and CANH mutually short-circuited
|
||||
*
|
||||
* See the TJA1054 data sheet (available from Philips) for more detailed
|
||||
* information.
|
||||
*/
|
||||
#define canMSG_NERR 0x0010
|
||||
#define canMSG_ERROR_FRAME 0x0020 ///< Message is an error frame
|
||||
#define canMSG_TXACK 0x0040 ///< Message is a TX ACK (msg is really sent)
|
||||
#define canMSG_TXRQ 0x0080 ///< Message is a TX REQUEST (msg is transfered to the chip)
|
||||
#define canMSG_DELAY_MSG 0x0100 ///< Message is NOT sent on the bus. The transmission of messages are delayed. The dlc specifies the delay in milliseconds (1..1000).
|
||||
|
||||
// single shot flags:
|
||||
#define canMSG_SINGLE_SHOT 0x1000000 ///< Message is Single Shot, try to send once, no retransmission. This flag can only be used with transmitted messages.
|
||||
#define canMSG_TXNACK 0x2000000 ///< Message is a failed Single Shot, message was not sent. This flag is only used with received messages.
|
||||
#define canMSG_ABL 0x4000000 ///< Only together with canMSG_TXNACK, Single shot message was not sent because arbitration was lost. This flag is only used with received messages.
|
||||
|
||||
|
||||
/**
|
||||
* \name canFDMSG_xxx
|
||||
* \anchor canFDMSG_xxx
|
||||
*
|
||||
* Flags used in the CAN FD protocol. Set \ref canOPEN_CAN_FD in \ref
|
||||
* canOpenChannel() to enable the CAN FD protocol.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define canFDMSG_MASK 0xff0000
|
||||
#define canFDMSG_EDL 0x010000 ///< Obsolete, use \ref canFDMSG_FDF instead
|
||||
#define canFDMSG_FDF 0x010000 ///< Message is an FD message (CAN FD)
|
||||
#define canFDMSG_BRS 0x020000 ///< Message is sent/received with bit rate switch (CAN FD)
|
||||
#define canFDMSG_ESI 0x040000 ///< Sender of the message is in error passive mode (CAN FD)
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Message error flags
|
||||
* \anchor canMSGERR_xxx
|
||||
*
|
||||
* \note Not all hardware platforms can detect the difference between hardware
|
||||
* overruns and software overruns, so your application should test for both
|
||||
* conditions. You can use the symbol \ref canMSGERR_OVERRUN for this purpose.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define canMSGERR_MASK 0xff00 ///< Used to mask the non-error bits
|
||||
// 0x0100 reserved
|
||||
#define canMSGERR_HW_OVERRUN 0x0200 ///< HW buffer overrun
|
||||
#define canMSGERR_SW_OVERRUN 0x0400 ///< SW buffer overrun
|
||||
#define canMSGERR_STUFF 0x0800 ///< Stuff error
|
||||
#define canMSGERR_FORM 0x1000 ///< Form error
|
||||
#define canMSGERR_CRC 0x2000 ///< CRC error
|
||||
#define canMSGERR_BIT0 0x4000 ///< Sent dom, read rec
|
||||
#define canMSGERR_BIT1 0x8000 ///< Sent rec, read dom
|
||||
|
||||
// Convenience values for the message error flags.
|
||||
#define canMSGERR_OVERRUN 0x0600 ///< Any overrun condition.
|
||||
#define canMSGERR_BIT 0xC000 ///< Any bit error.
|
||||
#define canMSGERR_BUSERR 0xF800 ///< Any RX error
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name canTRANSCEIVER_LINEMODE_xxx
|
||||
* \anchor canTRANSCEIVER_LINEMODE_xxx
|
||||
*
|
||||
* The following values can be used \win_start with \ref canSetDriverMode() \win_end to set different
|
||||
* driver (i.e. transceiver) modes. \win_start Use \ref canGetDriverMode() to obtain the
|
||||
* current driver mode for a particular CAN channel. \win_end
|
||||
*
|
||||
* \linux_start
|
||||
* Not implemented in Linux.
|
||||
* \linux_end
|
||||
* @{
|
||||
*/
|
||||
#define canTRANSCEIVER_LINEMODE_NA 0 ///< Not Affected/Not available.
|
||||
#define canTRANSCEIVER_LINEMODE_SWC_SLEEP 4 ///< SWC Sleep Mode.
|
||||
#define canTRANSCEIVER_LINEMODE_SWC_NORMAL 5 ///< SWC Normal Mode.
|
||||
#define canTRANSCEIVER_LINEMODE_SWC_FAST 6 ///< SWC High-Speed Mode.
|
||||
#define canTRANSCEIVER_LINEMODE_SWC_WAKEUP 7 ///< SWC Wakeup Mode.
|
||||
#define canTRANSCEIVER_LINEMODE_SLEEP 8 ///< Sleep mode for those supporting it.
|
||||
#define canTRANSCEIVER_LINEMODE_NORMAL 9 ///< Normal mode (the inverse of sleep mode) for those supporting it.
|
||||
#define canTRANSCEIVER_LINEMODE_STDBY 10 ///< Standby for those who support it
|
||||
#define canTRANSCEIVER_LINEMODE_TT_CAN_H 11 ///< Truck & Trailer: operating mode single wire using CAN high
|
||||
#define canTRANSCEIVER_LINEMODE_TT_CAN_L 12 ///< Truck & Trailer: operating mode single wire using CAN low
|
||||
#define canTRANSCEIVER_LINEMODE_OEM1 13 ///< Reserved for OEM apps
|
||||
#define canTRANSCEIVER_LINEMODE_OEM2 14 ///< Reserved for OEM apps
|
||||
#define canTRANSCEIVER_LINEMODE_OEM3 15 ///< Reserved for OEM apps
|
||||
#define canTRANSCEIVER_LINEMODE_OEM4 16 ///< Reserved for OEM apps
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \anchor canTRANSCEIVER_RESNET_xxx
|
||||
*
|
||||
*/
|
||||
#define canTRANSCEIVER_RESNET_NA 0
|
||||
#define canTRANSCEIVER_RESNET_MASTER 1
|
||||
#define canTRANSCEIVER_RESNET_MASTER_STBY 2
|
||||
#define canTRANSCEIVER_RESNET_SLAVE 3
|
||||
|
||||
/**
|
||||
* \name Transceiver (logical) types
|
||||
* \anchor canTRANSCEIVER_TYPE_xxx
|
||||
*
|
||||
* The following constants can be returned from \ref canGetChannelData(), using the
|
||||
* \ref canCHANNELDATA_TRANS_TYPE item code. They identify the bus transceiver
|
||||
* type for the channel specified in the call to \ref canGetChannelData.
|
||||
*
|
||||
* \note They indicate a hardware type, but not necessarily a specific circuit
|
||||
* or product.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
// Also see src\include\hwnames.h and registered document 048.
|
||||
#define canTRANSCEIVER_TYPE_UNKNOWN 0 ///< Unknown or undefined
|
||||
#define canTRANSCEIVER_TYPE_251 1 ///< 82c251
|
||||
#define canTRANSCEIVER_TYPE_252 2 ///< 82c252, TJA1053, TJA1054
|
||||
#define canTRANSCEIVER_TYPE_DNOPTO 3 ///< Optoisolated 82C251
|
||||
#define canTRANSCEIVER_TYPE_W210 4 ///<
|
||||
#define canTRANSCEIVER_TYPE_SWC_PROTO 5 ///< AU5790 prototype
|
||||
#define canTRANSCEIVER_TYPE_SWC 6 ///< AU5790
|
||||
#define canTRANSCEIVER_TYPE_EVA 7 ///<
|
||||
#define canTRANSCEIVER_TYPE_FIBER 8 ///< 82c251 with fibre extension
|
||||
#define canTRANSCEIVER_TYPE_K251 9 ///< K-line + 82c251
|
||||
#define canTRANSCEIVER_TYPE_K 10 ///< K-line, without CAN
|
||||
#define canTRANSCEIVER_TYPE_1054_OPTO 11 ///< TJA1054 with optical isolation
|
||||
#define canTRANSCEIVER_TYPE_SWC_OPTO 12 ///< AU5790 with optical isolation
|
||||
#define canTRANSCEIVER_TYPE_TT 13 ///< B10011S Truck-And-Trailer
|
||||
#define canTRANSCEIVER_TYPE_1050 14 ///< TJA1050
|
||||
#define canTRANSCEIVER_TYPE_1050_OPTO 15 ///< TJA1050 with optical isolation
|
||||
#define canTRANSCEIVER_TYPE_1041 16 ///< TJA1041
|
||||
#define canTRANSCEIVER_TYPE_1041_OPTO 17 ///< TJA1041 with optical isolation
|
||||
#define canTRANSCEIVER_TYPE_RS485 18 ///< RS485 (i.e. J1708)
|
||||
#define canTRANSCEIVER_TYPE_LIN 19 ///< LIN
|
||||
#define canTRANSCEIVER_TYPE_KONE 20 ///< KONE
|
||||
#define canTRANSCEIVER_TYPE_CANFD 22 ///< CAN-FD
|
||||
#define canTRANSCEIVER_TYPE_LINX_LIN 64
|
||||
#define canTRANSCEIVER_TYPE_LINX_J1708 66
|
||||
#define canTRANSCEIVER_TYPE_LINX_K 68
|
||||
#define canTRANSCEIVER_TYPE_LINX_SWC 70
|
||||
#define canTRANSCEIVER_TYPE_LINX_LS 72
|
||||
/** @} */
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,304 @@
|
|||
/**
|
||||
* \section LICENSE
|
||||
* Copyright 1998-2011 by KVASER AB, SWEDEN
|
||||
*
|
||||
* WWW: http://www.kvaser.com
|
||||
*
|
||||
* This software is furnished under a license and may be used and copied
|
||||
* only in accordance with the terms of such license.
|
||||
*
|
||||
* \section DESCRIPTION
|
||||
*
|
||||
* This file contains definitions which are retained for compatibility.
|
||||
*
|
||||
* \file obsolete.h
|
||||
* \author Kvaser AB
|
||||
*/
|
||||
|
||||
#ifndef _OBSOLETE_H_
|
||||
#define _OBSOLETE_H_
|
||||
|
||||
/**
|
||||
* \defgroup Obsolete Obsolete API Reference
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define canCIRCUIT_ANY -1 ///< Any circuit will do \warning Obsolete!
|
||||
#define canCARD_ANY -1 ///< Any card will do \warning Obsolete!
|
||||
#define canCHANNEL_ANY -1 ///< Any channel will do \warning Obsolete!
|
||||
|
||||
#define CANID_METAMSG (-1L) ///< Like msgs containing bus status changes. \warning Obsolete!
|
||||
#define CANID_WILDCARD (-2L) ///< We don't care or don't know. \warning Obsolete!
|
||||
|
||||
/**
|
||||
* Retained for compatibility.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \warning Obsolete!
|
||||
*/
|
||||
typedef void* (*canMemoryAllocator) (size_t size);
|
||||
|
||||
/**
|
||||
* \warning Obsolete!
|
||||
*/
|
||||
typedef void (*canMemoryDeallocator)(void* p);
|
||||
|
||||
/**
|
||||
* \warning Obsolete!
|
||||
*/
|
||||
typedef struct tagCanHWDescr {
|
||||
int circuitType;
|
||||
int cardType;
|
||||
int channel;
|
||||
} canHWDescr;
|
||||
|
||||
/**
|
||||
* \warning Obsolete!
|
||||
*/
|
||||
typedef struct tagCanSWDescr {
|
||||
unsigned int rxBufSize;
|
||||
unsigned int txBufSize;
|
||||
canMemoryAllocator alloc;
|
||||
canMemoryDeallocator deAlloc;
|
||||
} canSWDescr;
|
||||
|
||||
#ifdef __WIN32__
|
||||
/**
|
||||
* \warning Obsolete!
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int size;
|
||||
unsigned int rxBufSize;
|
||||
unsigned int txBufSize;
|
||||
} canSWDescriptorEx;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \warning Obsolete!
|
||||
*/
|
||||
canStatus CANLIBAPI canLocateHardware(void);
|
||||
|
||||
/**
|
||||
* \warning Obsolete!
|
||||
*/
|
||||
int CANLIBAPI canOpen(const canHWDescr * const hwdescr,
|
||||
const canSWDescr * const swdescr,
|
||||
const unsigned int flags);
|
||||
|
||||
/**
|
||||
* \warning Obsolete!
|
||||
*/
|
||||
canStatus CANLIBAPI canGetCircuits(int * context,
|
||||
char * name,
|
||||
char * vendor,
|
||||
char * version,
|
||||
unsigned int * cardtype,
|
||||
unsigned int * circtype,
|
||||
unsigned int * channel);
|
||||
|
||||
/**
|
||||
* \name Some obsolete codes; they are not used nowadays.
|
||||
* \warning Obsolete!
|
||||
* @{
|
||||
*/
|
||||
#define canERR_BUFOFL canERR_RESERVED_3 ///< "Buffer overflow" \warning Obsolete!
|
||||
#define canERR_REINIT canERR_RESERVED_4 ///< "Reinitialization failed" \warning Obsolete!
|
||||
#define canERR_MSGLOST canERR_RESERVED_5 ///< "Message lost by CAN-chip" \warning Obsolete!
|
||||
#define canERR_OVERRUN canERR_RESERVED_6 ///< "Receive buffer overrun" \warning Obsolete!
|
||||
#define canERR_CARDCOMMFAILED canERR_RESERVED_7 ///< "Can't communicate with the card" \warning Obsolete!
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Circuit status flags, retained for compatibility
|
||||
* \warning Obsolete!
|
||||
* @{
|
||||
*/
|
||||
#define canCIRCSTAT_ERROR_PASSIVE 0x0001 ///< Error passive \warning Obsolete!
|
||||
#define canCIRCSTAT_BUS_OFF 0x0002 ///< Bus off \warning Obsolete!
|
||||
#define canCIRCSTAT_ERROR_WARNING 0x0004 ///< Error counter > 96 \warning Obsolete!
|
||||
/** @} */
|
||||
|
||||
|
||||
/**
|
||||
* \name retained for compatibility
|
||||
* \warning Obsolete!
|
||||
* @{
|
||||
*/
|
||||
#define canCHANNEL_CAP_REMOTE canCHANNEL_CAP_RESERVED_1 ///< Obsolete, use \ref canCHANNEL_CAP_REMOTE_ACCESS or \ref canCHANNELDATA_IS_REMOTE
|
||||
|
||||
|
||||
/**
|
||||
* \name Sticky status flags
|
||||
* \warning Obsolete!
|
||||
* @{
|
||||
*/
|
||||
#define canSTICKY_ACK_ERROR 0x80000801 ///< \warning Obsolete!
|
||||
#define canSTICKY_FORM_ERROR 0x80000002 ///< \warning Obsolete!
|
||||
#define canSTICKY_STUFF_ERROR 0x80000004 ///< \warning Obsolete!
|
||||
#define canSTICKY_CRC_ERROR 0x80000008 ///< \warning Obsolete!
|
||||
#define canSTICKY_BIT0_ERROR 0x80000010 ///< \warning Obsolete!
|
||||
#define canSTICKY_BIT1_ERROR 0x80000020 ///< \warning Obsolete!
|
||||
#define canSTICKY_HW_OVERRUN 0x80000040 ///< \warning Obsolete!
|
||||
#define canSTICKY_SW_OVERRUN 0x80000080 ///< \warning Obsolete!
|
||||
/** @} */
|
||||
|
||||
#define canSTAT_INACTIVE canSTAT_RESERVED_1 ///< The circuit is not active (removed from the sw bus) \warning Obsolete!
|
||||
|
||||
|
||||
/*
|
||||
#define canCIRCSTAT_TXERR 0x0001 // TX error has occurred
|
||||
#define canCIRCSTAT_RXERR 0x0002 // Receive error has occurred
|
||||
#define canCIRCSTAT_OVERRUN 0x0004 // Receiver overrun
|
||||
#define canCIRCSTAT_WAKEUP 0x0008 // Wakeup has occurred
|
||||
#define canCIRCSTAT_INT 0x0010 // ??
|
||||
#define canCIRCSTAT_ACK 0x0020 // ACK error
|
||||
#define canCIRCSTAT_BIT 0x0040 // Bit error
|
||||
*/
|
||||
/*
|
||||
More apocryphs.
|
||||
#define canCIRCSTAT_OVERRUN 0x0004 // Receiver overrun
|
||||
#define canCIRCSTAT_WAKEUP 0x0008 // Wakeup has occurred
|
||||
#define canCIRCSTAT_ACK 0x0010 // ACK error
|
||||
#define canCIRCSTAT_BIT0 0x0020 // Bit error
|
||||
#define canCIRCSTAT_BIT1 0x0040 // Bit error
|
||||
#define canCIRCSTAT_BOFF 0x0080 // Chip went Bus Off
|
||||
*/
|
||||
/*
|
||||
Even more.
|
||||
#define canCIRCSTAT_BOFF_HW 0x10000L // Chip is Bus Off
|
||||
#define canCIRCSTAT_BOFF_SW 0x20000L // We are Bus Off
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \name Flags for canOpen
|
||||
* \warning Obsolete! Use \ref canOPEN_xxx instead.
|
||||
* @{
|
||||
*/
|
||||
#define canWANT_ACTIONS 0x01 ///< \warning Obsolete!
|
||||
#define canWANT_OWN_BUFFERS 0x02 ///< \warning Obsolete!
|
||||
#define canWANT_ERROR_COUNTERS 0x04 ///< \warning Obsolete!
|
||||
#define canWANT_EXCLUSIVE 0x08 ///< \warning Obsolete! Use \ref canOPEN_xxx instead.
|
||||
#define canWANT_EXTENDED 0x10 ///< \warning Obsolete! Use \ref canOPEN_xxx instead.
|
||||
#if defined(CANLIB_DECLARE_ALL)
|
||||
# define canWANT_VIRTUAL 0x20 ///< \warning Obsolete! Use \ref canOPEN_xxx instead.
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Circuit types.
|
||||
* \warning Obsolete!
|
||||
* @{
|
||||
*/
|
||||
// No circuit 0
|
||||
#define PCCAN_PHILIPS 1 ///< 82C200 on PCCAN 1.0 \warning Obsolete!
|
||||
#define PCCAN_INTEL526 2 ///< Not supported. \warning Obsolete!
|
||||
#define PCCAN_INTEL527 3 ///< 82527 on PCCAN 1.0 \warning Obsolete!
|
||||
#define CANCARD_NEC72005 4 ///< NEC72005 on CANCard \warning Obsolete!
|
||||
#define CIRC_VIRTUAL 5 ///< \warning Obsolete!
|
||||
#define CIRC_SJA1000 6 ///< \warning Obsolete!
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Card types.
|
||||
* \warning Obsolete!
|
||||
* @{
|
||||
*/
|
||||
#define canCARD_PCCAN 1 ///< PCCAN ver 1.x (KVASER) \warning Obsolete!
|
||||
#define canCARD_CANCARD 2 ///< CANCard (Softing) \warning Obsolete!
|
||||
#define canCARD_AC2 3 ///< CAN-AC2 (Softing) \warning Obsolete!
|
||||
#define canCARD_LAPCAN 4 ///< \warning Obsolete!
|
||||
#define canCARD_ISACAN 5 ///< \warning Obsolete!
|
||||
#define canCARD_PCCAN_OEM 6 ///< Special for OEM PCcan cards. \warning Obsolete!
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name The canFlgXXX are left for compatibility.
|
||||
* \warning Obsolete!
|
||||
* @{
|
||||
*/
|
||||
#define canFlgACCEPT 1 ///< \warning Obsolete!
|
||||
#define canFlgREJECT 2 ///< \warning Obsolete!
|
||||
#define canFlgCODE 3 ///< \warning Obsolete!
|
||||
#define canFlgMASK 4 ///< \warning Obsolete!
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Flags for action routines
|
||||
* \warning Obsolete!
|
||||
* @{
|
||||
*/
|
||||
#define canDISCARD_MESSAGE 3 ///< \warning Obsolete!
|
||||
#define canRETAIN_MESSAGE 4 ///< \warning Obsolete!
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name For busParams - sync on rising edge only or both rising and falling edge
|
||||
* (Not supported)
|
||||
* \warning Obsolete!
|
||||
* @{
|
||||
*/
|
||||
#define canSLOW_MODE 0x01 ///< Sync on rising and falling edge \warning Obsolete!
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name CAN driver types; these constants are retained for compatibility.
|
||||
* (Not supported)
|
||||
* \warning Obsolete!
|
||||
* @{
|
||||
*/
|
||||
#define canOFF 0 ///< \warning Obsolete!
|
||||
#define canTRISTATE 1 ///< \warning Obsolete!
|
||||
#define canPULLUP 2 ///< \warning Obsolete!
|
||||
#define canPULLDOWN 3 ///< \warning Obsolete!
|
||||
#define canPUSHPULL 4 ///< This is the usual setting. \warning Obsolete!
|
||||
#define canINVPULLUP 5 ///< \warning Obsolete!
|
||||
#define canINVPULLDOWN 6 ///< \warning Obsolete!
|
||||
#define canINVPUSHPULL 7 ///< \warning Obsolete!
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name These were never implemented.
|
||||
* (Not supported)
|
||||
* \warning Obsolete!
|
||||
* @{
|
||||
*/
|
||||
#define canIOCTL_LOCAL_ECHO_ON 3 ///< \warning Obsolete!
|
||||
#define canIOCTL_LOCAL_ECHO_OFF 4 ///< \warning Obsolete!
|
||||
|
||||
#define canMSG_STATUS 0x0008
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \warning Obsolete!
|
||||
*/
|
||||
canStatus CANLIBAPI canInstallAction(int handle, long id, int (*fn)());
|
||||
|
||||
/**
|
||||
* \warning Obsolete!
|
||||
*/
|
||||
canStatus CANLIBAPI canUninstallAction(int handle, long id);
|
||||
|
||||
/**
|
||||
* \warning Obsolete!
|
||||
*/
|
||||
canStatus CANLIBAPI canInstallOwnBuffer(int handle, long id, unsigned int len,
|
||||
void * buf);
|
||||
|
||||
/**
|
||||
* \warning Obsolete!
|
||||
*/
|
||||
canStatus CANLIBAPI canUninstallOwnBuffer(int handle, long id);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
** Copyright 2007 by KVASER AB, SWEDEN
|
||||
** WWW: http://www.kvaser.com
|
||||
**
|
||||
** This software is furnished under a license and may be used and copied
|
||||
** only in accordance with the terms of such license.
|
||||
**
|
||||
** Description:
|
||||
** This file removes the differences between BCC and MSC with regards
|
||||
** to some predefined macros. The other differences remain. Sigh.
|
||||
** ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _PREDEF_H_
|
||||
#define _PREDEF_H_
|
||||
|
||||
// 1) Win16: Borland defines _Windows
|
||||
// MSC defines _WINDOWS
|
||||
// We want _WINDOWS (but also _Windows to be sure)
|
||||
#if defined(_Windows) && !defined(_WINDOWS)
|
||||
# define _WINDOWS 1
|
||||
#endif
|
||||
|
||||
#if defined(_WINDOWS) && !defined(_Windows)
|
||||
# define _Windows 1
|
||||
#endif
|
||||
|
||||
|
||||
// 2) Win32: Borland defines _Windows and __WIN32__ and _WIN32
|
||||
// MSC defines _WIN32
|
||||
// We want __WIN32__ and _WINDOWS and _Windows and _WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__)
|
||||
# if !defined(__WIN32__)
|
||||
# define __WIN32__ 1
|
||||
# endif
|
||||
# if !defined(_WINDOWS)
|
||||
# define _WINDOWS 1
|
||||
# endif
|
||||
# if !defined(_Windows)
|
||||
# define _Windows 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
// 3) DLL: Borland defines __DLL__
|
||||
// MSC defines _DLL
|
||||
// We want __DLL__
|
||||
#if defined (_DLL) && !defined(__DLL__)
|
||||
# define __DLL__ 1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
//===========================================================================
|
||||
#ifndef USE_CANLIB39_TYPES
|
||||
// New typedefs for CANLIB 4.0 and beyond, partly to take care about
|
||||
// the 64 bit ints, partly to alleviate pre3.9 mixing of ints and
|
||||
// longs.
|
||||
#if __STDC_VERSION__ >= 199901L
|
||||
#include <stdint.h>
|
||||
#define KVINT32 int32_t
|
||||
#define KVINT64 int64_t
|
||||
#define KVINT32L int32_t
|
||||
#define KVUINT32 uint32_t
|
||||
#define KVUINT64 uint64_t
|
||||
#define KVUINT32L uint32_t
|
||||
#elif defined(__GNUC__)
|
||||
#define KVINT32 int
|
||||
#define KVINT64 long long
|
||||
#define KVINT32L int
|
||||
#define KVUINT32 unsigned int
|
||||
#define KVUINT64 unsigned long long
|
||||
#define KVUINT32L unsigned int
|
||||
#else
|
||||
#define KVINT32 int
|
||||
#define KVINT64 __int64
|
||||
#define KVINT32L int
|
||||
#define KVUINT32 unsigned int
|
||||
#define KVUINT64 unsigned __int64
|
||||
#define KVUINT32L unsigned int
|
||||
#endif
|
||||
#else
|
||||
// Old typedefs for compability with CANLIB 3.9 and older.
|
||||
#ifdef __GNUC__
|
||||
#define KVINT32 int
|
||||
#define KVINT64 long long
|
||||
#define KVINT32L long
|
||||
#define KVUINT32 unsigned int
|
||||
#define KVUINT64 unsigned long long
|
||||
#define KVUINT32L unsigned long
|
||||
#else
|
||||
#define KVINT32 int
|
||||
#define KVINT64 __int64
|
||||
#define KVINT32L long
|
||||
#define KVUINT32 unsigned int
|
||||
#define KVUINT64 unsigned __int64
|
||||
#define KVUINT32L unsigned long
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -46,7 +46,7 @@
|
|||
****************************************************************************************/
|
||||
/* Type definitions of the function in the PCAN-Basic API that this CAN interface uses.*/
|
||||
typedef TPCANStatus (__stdcall * tPCanUsbLibFuncInitialize)(TPCANHandle, TPCANBaudrate, TPCANType, DWORD, WORD);
|
||||
typedef TPCANStatus (__stdcall * tPCanUsbLibFuncpUninitialize)(TPCANHandle);
|
||||
typedef TPCANStatus (__stdcall * tPCanUsbLibFuncUninitialize)(TPCANHandle);
|
||||
typedef TPCANStatus (__stdcall * tPCanUsbLibFuncGetStatus)(TPCANHandle);
|
||||
typedef TPCANStatus (__stdcall * tPCanUsbLibFuncSetValue)(TPCANHandle, TPCANParameter, void*, DWORD);
|
||||
typedef TPCANStatus (__stdcall * tPCanUsbLibFuncRead)(TPCANHandle, TPCANMsg*, TPCANTimestamp*);
|
||||
|
@ -73,7 +73,7 @@ static void PCanUsbLibUnloadDll(void);
|
|||
static TPCANStatus PCanUsbLibFuncInitialize(TPCANHandle Channel, TPCANBaudrate Btr0Btr1,
|
||||
TPCANType HwType, DWORD IOPort,
|
||||
WORD Interrupt);
|
||||
static TPCANStatus PCanUsbLibFuncpUninitialize(TPCANHandle Channel);
|
||||
static TPCANStatus PCanUsbLibFuncUninitialize(TPCANHandle Channel);
|
||||
static TPCANStatus PCanUsbLibFuncGetStatus(TPCANHandle Channel);
|
||||
static TPCANStatus PCanUsbLibFuncSetValue(TPCANHandle Channel, TPCANParameter Parameter,
|
||||
void * Buffer, DWORD BufferLength);
|
||||
|
@ -142,7 +142,7 @@ static HINSTANCE pCanUsbDllHandle;
|
|||
static tPCanUsbLibFuncInitialize pCanUsbLibFuncInitializePtr;
|
||||
|
||||
/** \brief Function pointer to the PCAN-Basic Uninitialize function. */
|
||||
static tPCanUsbLibFuncpUninitialize pCanUsbLibFuncpUninitializePtr;
|
||||
static tPCanUsbLibFuncUninitialize pCanUsbLibFuncUninitializePtr;
|
||||
|
||||
/** \brief Function pointer to the PCAN-Basic GetStatus function. */
|
||||
static tPCanUsbLibFuncGetStatus pCanUsbLibFuncGetStatusPtr;
|
||||
|
@ -199,7 +199,7 @@ static void PCanUsbInit(tCanSettings const * settings)
|
|||
pCanUsbDllHandle = NULL;
|
||||
/* Reset library function pointers. */
|
||||
pCanUsbLibFuncInitializePtr = NULL;
|
||||
pCanUsbLibFuncpUninitializePtr = NULL;
|
||||
pCanUsbLibFuncUninitializePtr = NULL;
|
||||
pCanUsbLibFuncGetStatusPtr = NULL;
|
||||
pCanUsbLibFuncSetValuePtr = NULL;
|
||||
pCanUsbLibFuncReadPtr = NULL;
|
||||
|
@ -329,6 +329,11 @@ static bool PCanUsbConnect(void)
|
|||
assert(baudrateSupported);
|
||||
assert(channelSupported);
|
||||
|
||||
/* Invalidate handles. */
|
||||
pCanUsbTerminateEvent = NULL;
|
||||
pCanUsbCanEvent = NULL;
|
||||
pCanUsbRxThreadHandle = NULL;
|
||||
|
||||
/* Only continue with valid settings. */
|
||||
if ( (baudrateSupported) && (channelSupported) )
|
||||
{
|
||||
|
@ -451,7 +456,7 @@ static bool PCanUsbConnect(void)
|
|||
if (libInitialized)
|
||||
{
|
||||
/* Uninitialize the library. */
|
||||
(void)PCanUsbLibFuncpUninitialize(pCanUsbChannelLookup[pCanUsbSettings.channel]);
|
||||
(void)PCanUsbLibFuncUninitialize(pCanUsbChannelLookup[pCanUsbSettings.channel]);
|
||||
}
|
||||
if (pCanUsbTerminateEvent != NULL)
|
||||
{
|
||||
|
@ -487,6 +492,7 @@ static void PCanUsbDisconnect(void)
|
|||
(void)WaitForSingleObject(pCanUsbRxThreadHandle, INFINITE);
|
||||
/* Close the thread handle. */
|
||||
(void)CloseHandle(pCanUsbRxThreadHandle);
|
||||
pCanUsbRxThreadHandle = NULL;
|
||||
}
|
||||
|
||||
/* Close the terminate event handle. */
|
||||
|
@ -502,7 +508,7 @@ static void PCanUsbDisconnect(void)
|
|||
pCanUsbCanEvent = NULL;
|
||||
}
|
||||
/* Disconnect from the CAN interface. */
|
||||
(void)PCanUsbLibFuncpUninitialize(pCanUsbChannelLookup[pCanUsbSettings.channel]);
|
||||
(void)PCanUsbLibFuncUninitialize(pCanUsbChannelLookup[pCanUsbSettings.channel]);
|
||||
} /*** end of PCanUsbDisconnect ***/
|
||||
|
||||
|
||||
|
@ -725,7 +731,7 @@ static void PCanUsbLibLoadDll(void)
|
|||
{
|
||||
/* Start out by resetting the API function pointers. */
|
||||
pCanUsbLibFuncInitializePtr = NULL;
|
||||
pCanUsbLibFuncpUninitializePtr = NULL;
|
||||
pCanUsbLibFuncUninitializePtr = NULL;
|
||||
pCanUsbLibFuncGetStatusPtr = NULL;
|
||||
pCanUsbLibFuncSetValuePtr = NULL;
|
||||
pCanUsbLibFuncReadPtr = NULL;
|
||||
|
@ -744,7 +750,7 @@ static void PCanUsbLibLoadDll(void)
|
|||
/* Set CAN_Initialize function pointer. */
|
||||
pCanUsbLibFuncInitializePtr = (tPCanUsbLibFuncInitialize)GetProcAddress(pCanUsbDllHandle, "CAN_Initialize");
|
||||
/* Set CAN_Uninitialize function pointer. */
|
||||
pCanUsbLibFuncpUninitializePtr = (tPCanUsbLibFuncpUninitialize)GetProcAddress(pCanUsbDllHandle, "CAN_Uninitialize");
|
||||
pCanUsbLibFuncUninitializePtr = (tPCanUsbLibFuncUninitialize)GetProcAddress(pCanUsbDllHandle, "CAN_Uninitialize");
|
||||
/* Set CAN_GetStatus function pointer. */
|
||||
pCanUsbLibFuncGetStatusPtr = (tPCanUsbLibFuncGetStatus)GetProcAddress(pCanUsbDllHandle, "CAN_GetStatus");
|
||||
/* Set CAN_SetValue function pointer. */
|
||||
|
@ -767,7 +773,7 @@ static void PCanUsbLibUnloadDll(void)
|
|||
{
|
||||
/* Reset the API function pointers. */
|
||||
pCanUsbLibFuncInitializePtr = NULL;
|
||||
pCanUsbLibFuncpUninitializePtr = NULL;
|
||||
pCanUsbLibFuncUninitializePtr = NULL;
|
||||
pCanUsbLibFuncGetStatusPtr = NULL;
|
||||
pCanUsbLibFuncSetValuePtr = NULL;
|
||||
pCanUsbLibFuncReadPtr = NULL;
|
||||
|
@ -825,24 +831,24 @@ static TPCANStatus PCanUsbLibFuncInitialize(TPCANHandle Channel, TPCANBaudrate B
|
|||
** success.
|
||||
**
|
||||
****************************************************************************************/
|
||||
static TPCANStatus PCanUsbLibFuncpUninitialize(TPCANHandle Channel)
|
||||
static TPCANStatus PCanUsbLibFuncUninitialize(TPCANHandle Channel)
|
||||
{
|
||||
/* set result to error. */
|
||||
TPCANStatus result = PCAN_ERROR_INITIALIZE;
|
||||
|
||||
/* Check function pointer and library handle. */
|
||||
assert(pCanUsbLibFuncpUninitializePtr != NULL);
|
||||
assert(pCanUsbLibFuncUninitializePtr != NULL);
|
||||
assert(pCanUsbDllHandle != NULL);
|
||||
|
||||
/* Only continue with valid function pointer and library handle. */
|
||||
if ((pCanUsbLibFuncpUninitializePtr != NULL) && (pCanUsbDllHandle != NULL)) /*lint !e774 */
|
||||
if ((pCanUsbLibFuncUninitializePtr != NULL) && (pCanUsbDllHandle != NULL)) /*lint !e774 */
|
||||
{
|
||||
/* Call library function. */
|
||||
result = pCanUsbLibFuncpUninitializePtr(Channel);
|
||||
result = pCanUsbLibFuncUninitializePtr(Channel);
|
||||
}
|
||||
/* Give the result back to the caller. */
|
||||
return result;
|
||||
} /*** end of PCanUsbLibFuncpUninitialize ***/
|
||||
} /*** end of PCanUsbLibFuncUninitialize ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue