51#ifndef PCAN_API_H_INCLUDED
52#define PCAN_API_H_INCLUDED
85#define PCAN_NONEBUS 0x00U
87#define PCAN_USBBUS1 0x51U
88#define PCAN_USBBUS2 0x52U
89#define PCAN_USBBUS3 0x53U
90#define PCAN_USBBUS4 0x54U
91#define PCAN_USBBUS5 0x55U
92#define PCAN_USBBUS6 0x56U
93#define PCAN_USBBUS7 0x57U
94#define PCAN_USBBUS8 0x58U
96#define PCAN_USBBUS9 0x509U
97#define PCAN_USBBUS10 0x50AU
98#define PCAN_USBBUS11 0x50BU
99#define PCAN_USBBUS12 0x50CU
100#define PCAN_USBBUS13 0x50DU
101#define PCAN_USBBUS14 0x50EU
102#define PCAN_USBBUS15 0x50FU
103#define PCAN_USBBUS16 0x510U
109#define PCAN_ERROR_OK 0x00000U
110#define PCAN_ERROR_XMTFULL 0x00001U
111#define PCAN_ERROR_OVERRUN 0x00002U
112#define PCAN_ERROR_BUSLIGHT 0x00004U
113#define PCAN_ERROR_BUSHEAVY 0x00008U
114#define PCAN_ERROR_BUSWARNING PCAN_ERROR_BUSHEAVY
115#define PCAN_ERROR_BUSPASSIVE 0x40000U
116#define PCAN_ERROR_BUSOFF 0x00010U
117#define PCAN_ERROR_ANYBUSERR (PCAN_ERROR_BUSWARNING | PCAN_ERROR_BUSLIGHT | PCAN_ERROR_BUSHEAVY | PCAN_ERROR_BUSOFF | PCAN_ERROR_BUSPASSIVE)
118#define PCAN_ERROR_QRCVEMPTY 0x00020U
119#define PCAN_ERROR_QOVERRUN 0x00040U
120#define PCAN_ERROR_QXMTFULL 0x00080U
121#define PCAN_ERROR_REGTEST 0x00100U
122#define PCAN_ERROR_NODRIVER 0x00200U
123#define PCAN_ERROR_HWINUSE 0x00400U
124#define PCAN_ERROR_NETINUSE 0x00800U
125#define PCAN_ERROR_ILLHW 0x01400U
126#define PCAN_ERROR_ILLNET 0x01800U
127#define PCAN_ERROR_ILLCLIENT 0x01C00U
128#define PCAN_ERROR_ILLHANDLE (PCAN_ERROR_ILLHW | PCAN_ERROR_ILLNET | PCAN_ERROR_ILLCLIENT)
129#define PCAN_ERROR_RESOURCE 0x02000U
130#define PCAN_ERROR_ILLPARAMTYPE 0x04000U
131#define PCAN_ERROR_ILLPARAMVAL 0x08000U
132#define PCAN_ERROR_UNKNOWN 0x10000U
133#define PCAN_ERROR_ILLDATA 0x20000U
134#define PCAN_ERROR_ILLMODE 0x80000U
135#define PCAN_ERROR_CAUTION 0x2000000U
136#define PCAN_ERROR_INITIALIZE 0x4000000U
137#define PCAN_ERROR_ILLOPERATION 0x8000000U
141#define PCAN_NONE 0x00U
142#define PCAN_PEAKCAN 0x01U
143#define PCAN_ISA 0x02U
144#define PCAN_DNG 0x03U
145#define PCAN_PCI 0x04U
146#define PCAN_USB 0x05U
147#define PCAN_PCC 0x06U
148#define PCAN_VIRTUAL 0x07U
149#define PCAN_LAN 0x08U
153#define PCAN_DEVICE_ID 0x01U
154#define PCAN_5VOLTS_POWER 0x02U
155#define PCAN_RECEIVE_EVENT 0x03U
156#define PCAN_MESSAGE_FILTER 0x04U
157#define PCAN_API_VERSION 0x05U
158#define PCAN_CHANNEL_VERSION 0x06U
159#define PCAN_BUSOFF_AUTORESET 0x07U
160#define PCAN_LISTEN_ONLY 0x08U
161#define PCAN_LOG_LOCATION 0x09U
162#define PCAN_LOG_STATUS 0x0AU
163#define PCAN_LOG_CONFIGURE 0x0BU
164#define PCAN_LOG_TEXT 0x0CU
165#define PCAN_CHANNEL_CONDITION 0x0DU
166#define PCAN_HARDWARE_NAME 0x0EU
167#define PCAN_RECEIVE_STATUS 0x0FU
168#define PCAN_CONTROLLER_NUMBER 0x10U
169#define PCAN_TRACE_LOCATION 0x11U
170#define PCAN_TRACE_STATUS 0x12U
171#define PCAN_TRACE_SIZE 0x13U
172#define PCAN_TRACE_CONFIGURE 0x14U
173#define PCAN_CHANNEL_IDENTIFYING 0x15U
174#define PCAN_CHANNEL_FEATURES 0x16U
175#define PCAN_BITRATE_ADAPTING 0x17U
176#define PCAN_BITRATE_INFO 0x18U
177#define PCAN_BITRATE_INFO_FD 0x19U
178#define PCAN_BUSSPEED_NOMINAL 0x1AU
179#define PCAN_BUSSPEED_DATA 0x1BU
180#define PCAN_IP_ADDRESS 0x1CU
181#define PCAN_LAN_SERVICE_STATUS 0x1DU
182#define PCAN_ALLOW_STATUS_FRAMES 0x1EU
183#define PCAN_ALLOW_RTR_FRAMES 0x1FU
184#define PCAN_ALLOW_ERROR_FRAMES 0x20U
185#define PCAN_INTERFRAME_DELAY 0x21U
186#define PCAN_ACCEPTANCE_FILTER_11BIT 0x22U
187#define PCAN_ACCEPTANCE_FILTER_29BIT 0x23U
188#define PCAN_IO_DIGITAL_CONFIGURATION 0x24U
189#define PCAN_IO_DIGITAL_VALUE 0x25U
190#define PCAN_IO_DIGITAL_SET 0x26U
191#define PCAN_IO_DIGITAL_CLEAR 0x27U
192#define PCAN_IO_ANALOG_VALUE 0x28U
193#define PCAN_FIRMWARE_VERSION 0x29U
194#define PCAN_ATTACHED_CHANNELS_COUNT 0x2AU
195#define PCAN_ATTACHED_CHANNELS 0x2BU
196#define PCAN_ALLOW_ECHO_FRAMES 0x2CU
197#define PCAN_DEVICE_PART_NUMBER 0x2DU
198#define PCAN_EXT_BTR0BTR1 0x80U
199#define PCAN_EXT_TX_COUNTER 0x81U
200#define PCAN_EXT_RX_COUNTER 0x82U
201#define PCAN_EXT_ERR_COUNTER 0x83U
202#define PCAN_EXT_RX_QUE_OVERRUN 0x84U
203#define PCAN_EXT_HARDWARE_VERSION 0x85U
204#define PCAN_EXT_SOFTWARE_VERSION 0x86U
205#define PCAN_EXT_RECEIVE_CALLBACK 0x87U
206#define PCAN_EXT_LOG_USB 0x8FU
210#define PCAN_DEVICE_NUMBER PCAN_DEVICE_ID
214#define PCAN_PARAMETER_OFF 0x00U
215#define PCAN_PARAMETER_ON 0x01U
216#define PCAN_FILTER_CLOSE 0x00U
217#define PCAN_FILTER_OPEN 0x01U
218#define PCAN_FILTER_CUSTOM 0x02U
219#define PCAN_CHANNEL_UNAVAILABLE 0x00U
220#define PCAN_CHANNEL_AVAILABLE 0x01U
221#define PCAN_CHANNEL_OCCUPIED 0x02U
222#define PCAN_CHANNEL_PCANVIEW (PCAN_CHANNEL_AVAILABLE | PCAN_CHANNEL_OCCUPIED)
224#define LOG_FUNCTION_DEFAULT 0x00U
225#define LOG_FUNCTION_ENTRY 0x01U
226#define LOG_FUNCTION_PARAMETERS 0x02U
227#define LOG_FUNCTION_LEAVE 0x04U
228#define LOG_FUNCTION_WRITE 0x08U
229#define LOG_FUNCTION_READ 0x10U
230#define LOG_FUNCTION_ALL 0xFFFFU
232#define TRACE_FILE_SINGLE 0x00U
233#define TRACE_FILE_SEGMENTED 0x01U
234#define TRACE_FILE_DATE 0x02U
235#define TRACE_FILE_TIME 0x04U
236#define TRACE_FILE_OVERWRITE 0x80U
238#define FEATURE_FD_CAPABLE 0x01U
239#define FEATURE_DELAY_CAPABLE 0x02U
240#define FEATURE_IO_CAPABLE 0x04U
242#define SERVICE_STATUS_STOPPED 0x01U
243#define SERVICE_STATUS_RUNNING 0x04U
247#define MAX_LENGTH_HARDWARE_NAME 33
248#define MAX_LENGTH_VERSION_STRING 256
252#define PCAN_MESSAGE_STANDARD 0x00U
253#define PCAN_MESSAGE_RTR 0x01U
254#define PCAN_MESSAGE_EXTENDED 0x02U
255#define PCAN_MESSAGE_FD 0x04U
256#define PCAN_MESSAGE_BRS 0x08U
257#define PCAN_MESSAGE_ESI 0x10U
258#define PCAN_MESSAGE_ECHO 0x20U
259#define PCAN_MESSAGE_ERRFRAME 0x40U
260#define PCAN_MESSAGE_STATUS 0x80U
264#define LOOKUP_DEVICE_TYPE __T("devicetype")
265#define LOOKUP_DEVICE_ID __T("deviceid")
266#define LOOKUP_CONTROLLER_NUMBER __T("controllernumber")
267#define LOOKUP_IP_ADDRESS __T("ipaddress")
271#define PCAN_MODE_STANDARD PCAN_MESSAGE_STANDARD
272#define PCAN_MODE_EXTENDED PCAN_MESSAGE_EXTENDED
279#define PCAN_BAUD_1M 0x0014U
280#define PCAN_BAUD_800K 0x0016U
281#define PCAN_BAUD_500K 0x001CU
282#define PCAN_BAUD_250K 0x011CU
283#define PCAN_BAUD_125K 0x031CU
284#define PCAN_BAUD_100K 0x432FU
285#define PCAN_BAUD_95K 0xC34EU
286#define PCAN_BAUD_83K 0x852BU
287#define PCAN_BAUD_50K 0x472FU
288#define PCAN_BAUD_47K 0x1414U
289#define PCAN_BAUD_33K 0x8B2FU
290#define PCAN_BAUD_20K 0x532FU
291#define PCAN_BAUD_10K 0x672FU
292#define PCAN_BAUD_5K 0x7F7FU
302#define PCAN_BR_CLOCK __T("f_clock")
303#define PCAN_BR_CLOCK_MHZ __T("f_clock_mhz")
304#define PCAN_BR_NOM_BRP __T("nom_brp")
305#define PCAN_BR_NOM_TSEG1 __T("nom_tseg1")
306#define PCAN_BR_NOM_TSEG2 __T("nom_tseg2")
307#define PCAN_BR_NOM_SJW __T("nom_sjw")
308#define PCAN_BR_NOM_SAMPLE __T("nom_sam")
309#define PCAN_BR_DATA_BRP __T("data_brp")
310#define PCAN_BR_DATA_TSEG1 __T("data_tseg1")
311#define PCAN_BR_DATA_TSEG2 __T("data_tseg2")
312#define PCAN_BR_DATA_SJW __T("data_sjw")
313#define PCAN_BR_DATA_SAMPLE __T("data_ssp_offset")
318#define TPCANHandle WORD
319#define TPCANStatus DWORD
320#define TPCANParameter BYTE
321#define TPCANDevice BYTE
322#define TPCANMessageType BYTE
323#define TPCANType BYTE
324#define TPCANMode BYTE
325#define TPCANBaudrate WORD
326#define TPCANBitrateFD LPSTR
327#define TPCANTimestampFD UINT64
331typedef struct tagTPCANMsg
334 TPCANMessageType MSGTYPE;
342typedef struct tagTPCANTimestamp
345 WORD millis_overflow;
351typedef struct tagTPCANMsgFD
354 TPCANMessageType MSGTYPE;
361typedef struct tagTPCANChannelInformation
363 TPCANHandle channel_handle;
364 TPCANDevice device_type;
365 BYTE controller_number;
366 DWORD device_features;
367 char device_name[MAX_LENGTH_HARDWARE_NAME];
369 DWORD channel_condition;
370}TPCANChannelInformation;
397TPCANStatus CAN_Initialize(
399 TPCANBaudrate Btr0Btr1,
400 TPCANType HwType _DEF_ARG,
401 DWORD IOPort _DEF_ARG,
402 WORD Interrupt _DEF_ARG);
423TPCANStatus CAN_InitializeFD(
425 TPCANBitrateFD BitrateFD);
435TPCANStatus CAN_Uninitialize(
436 TPCANHandle Channel);
446TPCANStatus CAN_Reset(
447 TPCANHandle Channel);
455TPCANStatus CAN_GetStatus(
456 TPCANHandle Channel);
469 TPCANMsg* MessageBuffer,
470 TPCANTimestamp* TimestampBuffer);
481TPCANStatus CAN_ReadFD(
483 TPCANMsgFD* MessageBuffer,
484 TPCANTimestampFD* TimestampBuffer);
493TPCANStatus CAN_Write(
495 TPCANMsg* MessageBuffer);
504TPCANStatus CAN_WriteFD(
506 TPCANMsgFD* MessageBuffer);
520TPCANStatus CAN_FilterMessages(
538TPCANStatus CAN_GetValue(
540 TPCANParameter Parameter,
557TPCANStatus CAN_SetValue(
559 TPCANParameter Parameter,
574TPCANStatus CAN_GetErrorText(
587TPCANStatus CAN_LookUpChannel(
589 TPCANHandle* FoundChannel);