00001 #ifndef __CAN_DRV_EX_H__
00002 #define __CAN_DRV_EX_H__
00003
00004 #include "can_types.h"
00005
00006 #ifdef __cplusplus
00007 extern "C" {
00008 #endif
00009
00010 #define ERR_NO_CAN_DRIVER_LOAD -1000000
00011
00012
00013 #define DEV_LIST_SHOW_TCAN_ONLY 0x01
00014 #define DEV_LIST_SHOW_UNCONNECT 0x02
00015
00016
00017
00018
00019 #define CAN_FEATURE_LOM 0x0001 // Silent Mode (LOM = Listen only Mode)
00020 #define CAN_FEATURE_ARD 0x0002 // Automatic Retransmission disable
00021 #define CAN_FEATURE_TX_ACK 0x0004 // TX ACK (Gesendete Nachrichten bestätigen)
00022 #define CAN_FEATURE_HW_TIMESTAMP 0x8000 // Hardware Time Stamp
00023
00024
00025 #define VT_BYTE 0x01
00026 #define VT_UBYTE 0x02
00027 #define VT_WORD 0x03
00028 #define VT_UWORD 0x04
00029 #define VT_LONG 0x05
00030 #define VT_ULONG 0x06
00031
00032 #define VT_BYTE_ARRAY 0x07
00033 #define VT_UBYTE_ARRAY 0x08
00034 #define VT_WORD_ARRAY 0x09
00035 #define VT_UWORD_ARRAY 0x0A
00036 #define VT_LONG_ARRAY 0x0B
00037 #define VT_ULONG_ARRAY 0x0C
00038
00039 #define VT_BYTE_RANGE_ARRAY 0x0D
00040 #define VT_UBYTE_RANGE_ARRAY 0x0E
00041 #define VT_WORD_RANGE_ARRAY 0x0F
00042 #define VT_UWORD_RANGE_ARRAY 0x10
00043 #define VT_LONG_RANGE_ARRAY 0x11
00044 #define VT_ULONG_RANGE_ARRAY 0x12
00045
00046 #define VT_HBYTE 0x40
00047 #define VT_HWORD 0x41
00048 #define VT_HLONG 0x42
00049
00050 #define VT_STREAM 0x80
00051 #define VT_STRING 0x81
00052 #define VT_POINTER 0x82
00053
00054
00055 #define MHS_EVS_STATUS 1
00056 #define MHS_EVS_PNP 2
00057 #define MHS_EVS_OBJECT 3
00058
00059 #define MHS_TERMINATE 0x80000000
00060
00061
00062
00063
00064 struct TModulFeatures
00065 {
00066 uint32_t CanClock;
00067
00068 uint32_t Flags;
00069
00070
00071
00072
00073 uint32_t CanChannelsCount;
00074
00075 uint32_t HwRxFilterCount;
00076 uint32_t HwTxPufferCount;
00077 };
00078
00079 struct TCanDevicesList
00080 {
00081 uint32_t TCanIdx;
00082
00083 uint32_t HwId;
00084
00085
00086 char DeviceName[255];
00087
00088 char SerialNumber[16];
00089 char Description[64];
00090
00091
00092
00093 struct TModulFeatures ModulFeatures;
00094
00095 };
00096
00097
00098 struct TCanDeviceInfo
00099 {
00100 uint32_t HwId;
00101 uint32_t FirmwareVersion;
00102 uint32_t FirmwareInfo;
00103
00104
00105
00106
00107
00108
00109 char SerialNumber[16];
00110 char Description[64];
00111 struct TModulFeatures ModulFeatures;
00112 };
00113
00114
00115 struct TCanInfoVar
00116 {
00117 uint32_t Key;
00118 uint32_t Type;
00119 uint32_t Size;
00120 char Data[255];
00121 };
00122
00123
00124 typedef struct _TMhsEvent TMhsEvent;
00125
00126 struct _TMhsEvent
00127 {
00128 volatile uint32_t Events;
00129 volatile uint32_t EventsMask;
00130 volatile int32_t Waiting;
00131 #ifdef __WIN32__
00132
00133 HANDLE Event;
00134 CRITICAL_SECTION EventLock;
00135 #else
00136
00137
00138 #endif
00139 };
00140
00141
00142 #ifdef CAN_API_TRUE_FUNC
00143
00144 int32_t CanExGetDeviceCount(int flags);
00145 int32_t CanExGetDeviceList(struct TCanDevicesList **devices_list, int flags);
00146 int32_t CanExGetDeviceInfo(uint32_t index, struct TCanDeviceInfo *device_info,
00147 struct TCanInfoVar **hw_info, uint32_t *hw_info_size);
00148 void CanExDataFree(void **data);
00149 int32_t CanExCreateDevice(uint32_t *index, char *options);
00150 int32_t CanExDestroyDevice(uint32_t *index);
00151 int32_t CanExCreateFifo(uint32_t index, uint32_t size, TMhsEvent *event_obj, uint32_t event, uint32_t channels);
00152 int32_t CanExBindFifo(uint32_t fifo_index, uint32_t device_index, uint32_t bind);
00153 TMhsEvent *CanExCreateEvent(void);
00154 int32_t CanExSetObjEvent(uint32_t index, uint32_t source, TMhsEvent *event_obj, uint32_t event);
00155 void CanExSetEvent(TMhsEvent *event_obj, uint32_t event);
00156 void CanExResetEvent(TMhsEvent *event_obj, uint32_t event);
00157 uint32_t CanExWaitForEvent(TMhsEvent *event_obj, uint32_t timeout);
00158 int32_t CanExInitDriver(char *options);
00159 int32_t CanExSetOptions(uint32_t index, char *options);
00160 int32_t CanExSetAsByte(uint32_t index, char *name, char value);
00161 int32_t CanExSetAsWord(uint32_t index, char *name, int16_t value);
00162 int32_t CanExSetAsLong(uint32_t index, char *name, int32_t value);
00163 int32_t CanExSetAsUByte(uint32_t index, char *name, unsigned char value);
00164 int32_t CanExSetAsUWord(uint32_t index, char *name, uint16_t value);
00165 int32_t CanExSetAsULong(uint32_t index, char *name, uint32_t value);
00166 int32_t CanExSetAsString(uint32_t index, char *name, char *value);
00167 int32_t CanExGetAsByte(uint32_t index, char *name, char *value);
00168 int32_t CanExGetAsWord(uint32_t index, char *name, int16_t *value);
00169 int32_t CanExGetAsLong(uint32_t index, char *name, int32_t *value);
00170 int32_t CanExGetAsUByte(uint32_t index, char *name, unsigned char *value);
00171 int32_t CanExGetAsUWord(uint32_t index, char *name, uint16_t *value);
00172 int32_t CanExGetAsULong(uint32_t index, char *name, uint32_t *value);
00173 int32_t CanExGetAsString(uint32_t index, char *name, char **str);
00174
00175 #endif
00176
00177 #if !(defined(CAN_API_TRUE_FUNC)) || defined(CAN_DRV_INCLUDE)
00178
00179
00180
00181
00182 typedef int32_t (DRV_CALLBACK_TYPE *TCanExGetDeviceCount)(int flags);
00183 typedef int32_t (DRV_CALLBACK_TYPE *TCanExGetDeviceList)(struct TCanDevicesList **devices_list, int flags);
00184 typedef int32_t (DRV_CALLBACK_TYPE *TCanExGetDeviceInfo)(uint32_t index, struct TCanDeviceInfo *device_info,
00185 struct TCanInfoVar **hw_info, uint32_t *hw_info_size);
00186 typedef void (DRV_CALLBACK_TYPE *TCanExDataFree)(void **data);
00187 typedef int32_t (DRV_CALLBACK_TYPE *TCanExCreateDevice)(uint32_t *index, char *options);
00188 typedef int32_t (DRV_CALLBACK_TYPE *TCanExDestroyDevice)(uint32_t *index);
00189 typedef int32_t (DRV_CALLBACK_TYPE *TCanExCreateFifo)(uint32_t index, uint32_t size, TMhsEvent *event_obj,
00190 uint32_t event, uint32_t channels);
00191 typedef int32_t (DRV_CALLBACK_TYPE *TCanExBindFifo)(uint32_t fifo_index, uint32_t device_index,
00192 uint32_t bind);
00193 typedef TMhsEvent * (DRV_CALLBACK_TYPE *TCanExCreateEvent)(void);
00194 typedef int32_t (DRV_CALLBACK_TYPE *TCanExSetObjEvent)(uint32_t index, uint32_t source, TMhsEvent *event_obj, uint32_t event);
00195 typedef void (DRV_CALLBACK_TYPE *TCanExSetEvent)(TMhsEvent *event_obj, uint32_t event);
00196 typedef void (DRV_CALLBACK_TYPE *TCanExResetEvent)(TMhsEvent *event_obj, uint32_t event);
00197 typedef uint32_t (DRV_CALLBACK_TYPE *TCanExWaitForEvent)(TMhsEvent *event_obj, uint32_t timeout);
00198 typedef int32_t (DRV_CALLBACK_TYPE *TCanExInitDriver)(char *options);
00199 typedef int32_t (DRV_CALLBACK_TYPE *TCanExSetOptions)(uint32_t index, char *options);
00200 typedef int32_t (DRV_CALLBACK_TYPE *TCanExSetAsByte)(uint32_t index, char *name, char value);
00201 typedef int32_t (DRV_CALLBACK_TYPE *TCanExSetAsWord)(uint32_t index, char *name, int16_t value);
00202 typedef int32_t (DRV_CALLBACK_TYPE *TCanExSetAsLong)(uint32_t index, char *name, int32_t value);
00203 typedef int32_t (DRV_CALLBACK_TYPE *TCanExSetAsUByte)(uint32_t index, char *name, unsigned char value);
00204 typedef int32_t (DRV_CALLBACK_TYPE *TCanExSetAsUWord)(uint32_t index, char *name, uint16_t value);
00205 typedef int32_t (DRV_CALLBACK_TYPE *TCanExSetAsULong)(uint32_t index, char *name, uint32_t value);
00206 typedef int32_t (DRV_CALLBACK_TYPE *TCanExSetAsString)(uint32_t index, char *name, char *value);
00207 typedef int32_t (DRV_CALLBACK_TYPE *TCanExGetAsByte)(uint32_t index, char *name, char *value);
00208 typedef int32_t (DRV_CALLBACK_TYPE *TCanExGetAsWord)(uint32_t index, char *name, int16_t *value);
00209 typedef int32_t (DRV_CALLBACK_TYPE *TCanExGetAsLong)(uint32_t index, char *name, int32_t *value);
00210 typedef int32_t (DRV_CALLBACK_TYPE *TCanExGetAsUByte)(uint32_t index, char *name, unsigned char *value);
00211 typedef int32_t (DRV_CALLBACK_TYPE *TCanExGetAsUWord)(uint32_t index, char *name, uint16_t *value);
00212 typedef int32_t (DRV_CALLBACK_TYPE *TCanExGetAsULong)(uint32_t index, char *name, uint32_t *value);
00213 typedef int32_t (DRV_CALLBACK_TYPE *TCanExGetAsString)(uint32_t index, char *name, char **str);
00214
00215 #endif
00216
00217
00218 #ifndef CAN_API_TRUE_FUNC
00219
00220
00221
00222 extern TCanExGetDeviceCount CanExGetDeviceCount;
00223 extern TCanExGetDeviceList CanExGetDeviceList;
00224 extern TCanExGetDeviceInfo CanExGetDeviceInfo;
00225 extern TCanExDataFree CanExDataFree;
00226 extern TCanExCreateDevice CanExCreateDevice;
00227 extern TCanExDestroyDevice CanExDestroyDevice;
00228 extern TCanExCreateFifo CanExCreateFifo;
00229 extern TCanExBindFifo CanExBindFifo;
00230 extern TCanExCreateEvent CanExCreateEvent;
00231 extern TCanExSetObjEvent CanExSetObjEvent;
00232 extern TCanExSetEvent CanExSetEvent;
00233 extern TCanExResetEvent CanExResetEvent;
00234 extern TCanExWaitForEvent CanExWaitForEvent;
00235 extern TCanExInitDriver CanExInitDriver;
00236 extern TCanExSetOptions CanExSetOptions;
00237 extern TCanExSetAsByte CanExSetAsByte;
00238 extern TCanExSetAsWord CanExSetAsWord;
00239 extern TCanExSetAsLong CanExSetAsLong;
00240 extern TCanExSetAsUByte CanExSetAsUByte;
00241 extern TCanExSetAsUWord CanExSetAsUWord;
00242 extern TCanExSetAsULong CanExSetAsULong;
00243 extern TCanExSetAsString CanExSetAsString;
00244 extern TCanExGetAsByte CanExGetAsByte;
00245 extern TCanExGetAsWord CanExGetAsWord;
00246 extern TCanExGetAsLong CanExGetAsLong;
00247 extern TCanExGetAsUByte CanExGetAsUByte;
00248 extern TCanExGetAsUWord CanExGetAsUWord;
00249 extern TCanExGetAsULong CanExGetAsULong;
00250 extern TCanExGetAsString CanExGetAsString;
00251
00252 #endif
00253
00254 #ifdef __cplusplus
00255 }
00256 #endif
00257
00258 #endif