Go to the documentation of this file.00001 #ifndef __PCAN_H__
00002 #define __PCAN_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <linux/types.h>
00039 #include <linux/ioctl.h>
00040
00041
00042
00043
00044
00045
00046 #if defined(DWORD) || defined(WORD) || defined(BYTE)
00047 #error "double define for DWORD, WORD, BYTE found"
00048 #endif
00049
00050 #ifdef __KERNEL__
00051 #define DWORD u32
00052 #define WORD u16
00053 #define BYTE u8
00054 #else
00055 #define DWORD __u32
00056 #define WORD __u16
00057 #define BYTE __u8
00058 #endif
00059
00060
00061
00062 #define HW_ISA 1 // not supported with LINUX, 82C200 chip
00063 #define HW_DONGLE_SJA 5
00064 #define HW_DONGLE_SJA_EPP 6
00065 #define HW_DONGLE_PRO 7 // not yet supported with LINUX
00066 #define HW_DONGLE_PRO_EPP 8 // not yet supported with LINUX
00067 #define HW_ISA_SJA 9 // use this also for PC/104
00068 #define HW_PCI 10 // PCI carries always SJA1000 chips
00069 #define HW_USB 11 // don't know if this is common over peak products
00070 #define HW_PCCARD 12 // not aligned to other OS
00071 #define HW_USB_PRO 13
00072
00073
00074
00075 #define CAN_MAX_STANDARD_ID 0x7ff
00076 #define CAN_MAX_EXTENDED_ID 0x1fffffff
00077
00078
00079
00080 #define CAN_ERR_OK 0x0000 // no error
00081 #define CAN_ERR_XMTFULL 0x0001 // transmit buffer full
00082 #define CAN_ERR_OVERRUN 0x0002 // overrun in receive buffer
00083 #define CAN_ERR_BUSLIGHT 0x0004 // bus error, errorcounter limit reached
00084 #define CAN_ERR_BUSHEAVY 0x0008 // bus error, errorcounter limit reached
00085 #define CAN_ERR_BUSOFF 0x0010 // bus error, 'bus off' state entered
00086 #define CAN_ERR_QRCVEMPTY 0x0020 // receive queue is empty
00087 #define CAN_ERR_QOVERRUN 0x0040 // receive queue overrun
00088 #define CAN_ERR_QXMTFULL 0x0080 // transmit queue full
00089 #define CAN_ERR_REGTEST 0x0100 // test of controller registers failed
00090 #define CAN_ERR_NOVXD 0x0200 // Win95/98/ME only
00091 #define CAN_ERR_RESOURCE 0x2000 // can't create resource
00092 #define CAN_ERR_ILLPARAMTYPE 0x4000 // illegal parameter
00093 #define CAN_ERR_ILLPARAMVAL 0x8000 // value out of range
00094 #define CAN_ERRMASK_ILLHANDLE 0x1C00 // wrong handle, handle error
00095
00096
00097
00098 #define MSGTYPE_STATUS 0x80 // used to mark a status TPCANMsg
00099 #define MSGTYPE_EXTENDED 0x02 // declares a extended frame
00100 #define MSGTYPE_RTR 0x01 // marks a remote frame
00101 #define MSGTYPE_STANDARD 0x00 // marks a standard frame
00102
00103
00104
00105 #define VERSIONSTRING_LEN 64
00106
00107
00108
00109 typedef struct
00110 {
00111 WORD wBTR0BTR1;
00112 BYTE ucCANMsgType;
00113 BYTE ucListenOnly;
00114 } TPCANInit;
00115
00116 typedef struct
00117 {
00118 DWORD ID;
00119 BYTE MSGTYPE;
00120 BYTE LEN;
00121 BYTE DATA[8];
00122 } TPCANMsg;
00123
00124 typedef struct
00125 {
00126 TPCANMsg Msg;
00127 DWORD dwTime;
00128 WORD wUsec;
00129 } TPCANRdMsg;
00130
00131 typedef struct
00132 {
00133 WORD wErrorFlag;
00134 int nLastError;
00135 } TPSTATUS;
00136
00137 typedef struct
00138 {
00139 WORD wType;
00140 DWORD dwBase;
00141 WORD wIrqLevel;
00142 DWORD dwReadCounter;
00143 DWORD dwWriteCounter;
00144 DWORD dwIRQcounter;
00145 DWORD dwErrorCounter;
00146 WORD wErrorFlag;
00147 int nLastError;
00148 int nOpenPaths;
00149 char szVersionString[VERSIONSTRING_LEN];
00150 } TPDIAG;
00151
00152 typedef struct
00153 {
00154 DWORD dwBitRate;
00155 WORD wBTR0BTR1;
00156 } TPBTR0BTR1;
00157
00158 typedef struct
00159 {
00160 WORD wErrorFlag;
00161 int nLastError;
00162 int nPendingReads;
00163 int nPendingWrites;
00164 } TPEXTENDEDSTATUS;
00165
00166 typedef struct
00167 {
00168 DWORD FromID;
00169 DWORD ToID;
00170 BYTE MSGTYPE;
00171 } TPMSGFILTER;
00172
00173
00174
00175 #define SF_GET_SERIALNUMBER 1 // to get the serial number (currently only pcan-usb)
00176 #define SF_SET_SERIALNUMBER 2 // to set the serial number (currently only pcan-usb)
00177 #define SF_GET_HCDEVICENO 3 // request hardcoded device number (currently only pcan-usb)
00178 #define SF_SET_HCDEVICENO 4 // to set hardcoded device number (currently only pcan-usb)
00179
00180 typedef struct
00181 {
00182 int nSubFunction;
00183 union
00184 {
00185 DWORD dwSerialNumber;
00186 BYTE ucHCDeviceNo;
00187 } func;
00188 } TPEXTRAPARAMS;
00189
00190
00191
00192 #define PCAN_MAGIC_NUMBER 'z'
00193 #define MYSEQ_START 0x80
00194
00195
00196
00197 #define PCAN_INIT _IOWR(PCAN_MAGIC_NUMBER, MYSEQ_START, TPCANInit)
00198 #define PCAN_WRITE_MSG _IOW (PCAN_MAGIC_NUMBER, MYSEQ_START + 1, TPCANMsg)
00199 #define PCAN_READ_MSG _IOR (PCAN_MAGIC_NUMBER, MYSEQ_START + 2, TPCANRdMsg)
00200 #define PCAN_GET_STATUS _IOR (PCAN_MAGIC_NUMBER, MYSEQ_START + 3, TPSTATUS)
00201 #define PCAN_DIAG _IOR (PCAN_MAGIC_NUMBER, MYSEQ_START + 4, TPDIAG)
00202 #define PCAN_BTR0BTR1 _IOWR(PCAN_MAGIC_NUMBER, MYSEQ_START + 5, TPBTR0BTR1)
00203 #define PCAN_GET_EXT_STATUS _IOR (PCAN_MAGIC_NUMBER, MYSEQ_START + 6, TPEXTENDEDSTATUS)
00204 #define PCAN_MSG_FILTER _IOW (PCAN_MAGIC_NUMBER, MYSEQ_START + 7, TPMSGFILTER)
00205 #define PCAN_EXTRA_PARAMS _IOWR(PCAN_MAGIC_NUMBER, MYSEQ_START + 8, TPEXTRAPARAMS)
00206
00207 #endif // __PCAN_H__