00001
00002
00003 #define DWORD unsigned long
00004 #define WORD unsigned short
00005 #define BYTE unsigned char \
00006
00007
00008
00009 #define HW_ISA 1 // not supported with LINUX, 82C200 chip
00010 #define HW_DONGLE_SJA 5
00011 #define HW_DONGLE_SJA_EPP 6
00012 #define HW_DONGLE_PRO 7 // not yet supported with LINUX
00013 #define HW_DONGLE_PRO_EPP 8 // not yet supported with LINUX
00014 #define HW_ISA_SJA 9 // use this also for PC/104
00015 #define HW_PCI 10 // PCI carries always SJA1000 chips
00016 #define HW_USB 11 // don't know if this is common over peak products
00017
00018
00019
00020 #define CAN_MAX_STANDARD_ID 0x7ff
00021 #define CAN_MAX_EXTENDED_ID 0x1fffffff
00022
00023
00024
00025 #define CAN_ERR_OK 0x0000 // no error
00026 #define CAN_ERR_XMTFULL 0x0001 // transmit buffer full
00027 #define CAN_ERR_OVERRUN 0x0002 // overrun in receive buffer
00028 #define CAN_ERR_BUSLIGHT 0x0004 // bus error, errorcounter limit reached
00029 #define CAN_ERR_BUSHEAVY 0x0008 // bus error, errorcounter limit reached
00030 #define CAN_ERR_BUSOFF 0x0010 // bus error, 'bus off' state entered
00031 #define CAN_ERR_QRCVEMPTY 0x0020 // receive queue is empty
00032 #define CAN_ERR_QOVERRUN 0x0040 // receive queue overrun
00033 #define CAN_ERR_QXMTFULL 0x0080 // transmit queue full
00034 #define CAN_ERR_REGTEST 0x0100 // test of controller registers failed
00035 #define CAN_ERR_NOVXD 0x0200 // Win95/98/ME only
00036 #define CAN_ERR_RESOURCE 0x2000 // can't create resource
00037 #define CAN_ERR_ILLPARAMTYPE 0x4000 // illegal parameter
00038 #define CAN_ERR_ILLPARAMVAL 0x8000 // value out of range
00039 #define CAN_ERRMASK_ILLHANDLE 0x1C00 // wrong handle, handle error
00040
00041
00042
00043 #define MSGTYPE_STATUS 0x80 // used to mark pending status
00044 #define MSGTYPE_EXTENDED 0x02 // declares a extended frame
00045 #define MSGTYPE_RTR 0x01 // marks a remote frame
00046 #define MSGTYPE_STANDARD 0x00 // marks a standard frame
00047
00048
00049
00050 #define VERSIONSTRING_LEN 64
00051
00052
00053
00054 #define CAN_INIT_TYPE_EX 0x01 //Extended Frame
00055 #define CAN_INIT_TYPE_ST 0x00 //Standart Frame
00056
00057
00058
00059 typedef struct
00060 {
00061 WORD wBTR0BTR1;
00062 BYTE ucCANMsgType;
00063 BYTE ucListenOnly;
00064 } TPCANInit;
00065
00066 typedef struct
00067 {
00068 DWORD ID;
00069 BYTE MSGTYPE;
00070 BYTE LEN;
00071 BYTE DATA[8];
00072 } TPCANMsg;
00073
00074 typedef struct
00075 {
00076 TPCANMsg Msg;
00077 DWORD dwTime;
00078 } TPCANRdMsg;
00079
00080 typedef struct
00081 {
00082 WORD wErrorFlag;
00083 int nLastError;
00084 } TPSTATUS;
00085
00086 typedef struct
00087 {
00088 WORD wType;
00089 DWORD dwBase;
00090 WORD wIrqLevel;
00091 DWORD dwReadCounter;
00092 DWORD dwWriteCounter;
00093 DWORD dwIRQcounter;
00094 DWORD dwErrorCounter;
00095 WORD wErrorFlag;
00096 int nLastError;
00097 int nOpenPaths;
00098 char szVersionString[VERSIONSTRING_LEN];
00099 } TPDIAG;
00100
00101 typedef struct
00102 {
00103 DWORD dwBitRate;
00104 WORD wBTR0BTR1;
00105 } TPBTR0BTR1;
00106
00107 typedef struct
00108 {
00109 WORD wErrorFlag;
00110 int nLastError;
00111 int nPendingReads;
00112 int nPendingWrites;
00113 } TPEXTENDEDSTATUS;
00114
00115
00116
00117 #define PCAN_MAGIC_NUMBER 'z'
00118 #define MYSEQ_START 0x80
00119
00120
00121
00122 #define PCAN_INIT _IOWR(PCAN_MAGIC_NUMBER, MYSEQ_START, TPCANInit)
00123 #define PCAN_WRITE_MSG _IOW (PCAN_MAGIC_NUMBER, MYSEQ_START + 1, TPCANMsg)
00124 #define PCAN_READ_MSG _IOR (PCAN_MAGIC_NUMBER, MYSEQ_START + 2, TPCANRdMsg)
00125 #define PCAN_GET_STATUS _IOR (PCAN_MAGIC_NUMBER, MYSEQ_START + 3, TPSTATUS)
00126 #define PCAN_DIAG _IOR (PCAN_MAGIC_NUMBER, MYSEQ_START + 4, TPDIAG)
00127 #define PCAN_BTR0BTR1 _IOWR(PCAN_MAGIC_NUMBER, MYSEQ_START + 5, TPBTR0BTR1)
00128 #define PCAN_GET_EXT_STATUS _IOR (PCAN_MAGIC_NUMBER, MYSEQ_START + 6, TPEXTENDEDSTATUS)
00129