00001 /* 00002 * can.h - can4linux CAN driver module 00003 * 00004 * Copyright (c) 2001 port GmbH Halle/Saale 00005 *------------------------------------------------------------------ 00006 * $Header: /z2/cvsroot/products/0530/software/can4linux/src/can4linux.h,v 1.3 2002/08/20 05:57:22 oe Exp $ 00007 * 00008 *-------------------------------------------------------------------------- 00009 * 00010 * 00011 * modification history 00012 * -------------------- 00013 * $Log: can4linux.h,v $ 00014 * Revision 1.3 2002/08/20 05:57:22 oe 00015 * - new write() handling, now not ovrwriting buffer content if buffer fill 00016 * - ioctl() get status returns buffer information 00017 * 00018 * Revision 1.2 2002/08/08 17:50:46 oe 00019 * - MSG_ERR_MASK extended 00020 * 00021 * Revision 1.1 2002/01/10 19:13:19 oe 00022 * - application header file changed name can.h -> can4linux.h 00023 * 00024 * Revision 1.2 2001/09/14 14:58:09 oe 00025 * first free release 00026 * 00027 * Revision 1.1.1.1 2001/06/11 18:30:54 oe 00028 * minimal version can4linux embedded, compile time Konfigurierbar 00029 * 00030 * 00031 * 00032 * 00033 *-------------------------------------------------------------------------- 00034 */ 00035 00036 00050 #ifndef __CAN_H 00051 #define __CAN_H 00052 00053 00054 #ifndef __KERNEL__ 00055 #include <sys/time.h> 00056 #endif 00057 /*---------- the can message structure */ 00058 00059 #define CAN_MSG_LENGTH 8 00062 #define MSG_RTR (1<<0) 00063 #define MSG_OVR (1<<1) 00064 #define MSG_EXT (1<<2) 00065 #define MSG_PASSIVE (1<<4) 00066 #define MSG_BUSOFF (1<<5) 00067 #define MSG_ (1<<6) 00068 #define MSG_BOVR (1<<7) 00072 #define MSG_ERR_MASK (MSG_OVR + MSG_PASSIVE + MSG_BUSOFF + MSG_BOVR) 00073 00079 typedef struct { 00081 int flags; 00082 int cob; 00083 unsigned long id; 00084 struct timeval timestamp; 00085 short int length; 00086 unsigned char data[CAN_MSG_LENGTH]; 00087 } canmsg_t; 00088 00089 00090 00094 #define COMMAND 0 00095 #define CONFIG 1 00096 #define SEND 2 00097 #define RECEIVE 3 00098 #define CONFIGURERTR 4 00099 #define STATUS 5 00101 /*---------- CAN ioctl parameter types */ 00102 00105 typedef struct Command_par { 00106 int cmd; 00107 int error; 00108 unsigned long retval; 00109 } Command_par_t ; 00110 00111 00114 typedef struct Config_par { 00115 int target; 00116 unsigned long val1; 00117 unsigned long val2; 00118 int error; 00119 unsigned long retval; 00120 } Config_par_t ; 00121 00124 typedef struct CanSja1000Status_par { 00125 unsigned int baud; 00126 unsigned char status; 00127 unsigned int error_warning_limit; 00128 unsigned int rx_errors; 00129 unsigned int tx_errors; 00130 unsigned int error_code; 00131 unsigned int rx_buffer_size; 00132 unsigned int rx_buffer_used; 00133 unsigned int tx_buffer_size; 00134 unsigned int tx_buffer_used; 00135 unsigned long retval; 00136 } CanSja1000Status_par_t; 00137 00140 typedef struct Send_par { 00141 canmsg_t *Tx; 00142 int error; 00143 unsigned long retval; 00144 } Send_par_t ; 00145 00148 typedef struct Receive_par { 00149 canmsg_t *Rx; 00150 int error; 00151 unsigned long retval; 00152 } Receive_par_t ; 00153 00156 typedef struct ConfigureRTR_par { 00157 unsigned message; 00158 canmsg_t *Tx; 00159 int error; 00160 unsigned long retval; 00161 } ConfigureRTR_par_t ; 00162 00166 # define CMD_START 1 00167 # define CMD_STOP 2 00168 # define CMD_RESET 3 00169 00170 00174 # define CONF_ACC 0 /* mask and code */ 00175 # define CONF_ACCM 1 /* mask only */ 00176 # define CONF_ACCC 2 /* code only */ 00177 # define CONF_TIMING 3 /* bit timing */ 00178 # define CONF_OMODE 4 /* output control register */ 00179 # define CONF_FILTER 5 00180 # define CONF_FENABLE 6 00181 # define CONF_FDISABLE 7 00182 00183 #endif /* __CAN_H */