![]() |
libPCBUSB
Version 0.12, Build 1668 of January 31, 2023
macOS Library for PCAN-USB Interfaces
|
00001 /* -- $HeadURL: https://uv-software.net/MacCAN/PCANUSB/Library/trunk/drv/pcan_api.h $ -- 00002 * 00003 * project : CAN - Controller Area Network 00004 * 00005 * purpose : PCAN Application Programming Interface 00006 * 00007 * copyright : (C) 2012-2023 by UV Software, Berlin 00008 * 00009 * compiler : Apple clang version 14.0.0 (clang-1400.0.29.202) 00010 * 00011 * export : TPCANStatus CAN_Initialize(TPCANHandle Channel, TPCANBaudrate Btr0Btr1, TPCANType HwType, DWORD IOPort, WORD Interrupt); 00012 * TPCANStatus CAN_Uninitialize(TPCANHandle Channel); 00013 * TPCANStatus CAN_Reset(TPCANHandle Channel); 00014 * TPCANStatus CAN_GetStatus(TPCANHandle Channel); 00015 * TPCANStatus CAN_Read(TPCANHandle Channel, TPCANMsg* MessageBuffer, TPCANTimestamp* TimestampBuffer); 00016 * TPCANStatus CAN_Write(TPCANHandle Channel, TPCANMsg* MessageBuffer); 00017 * TPCANStatus CAN_FilterMessages(TPCANHandle Channel, DWORD FromID, DWORD ToID, TPCANMode Mode); 00018 * TPCANStatus CAN_GetValue(TPCANHandle Channel, TPCANParameter Parameter, void* Buffer, DWORD BufferLength); 00019 * TPCANStatus CAN_SetValue(TPCANHandle Channel, TPCANParameter Parameter, void* Buffer, DWORD BufferLength); 00020 * TPCANStatus CAN_GetErrorText(TPCANStatus Error, WORD Language, LPSTR Buffer); 00021 * *** CAN FD capable devices *** 00022 * TPCANStatus CAN_InitializeFD(TPCANHandle Channel, TPCANBitrateFD BitrateFD); 00023 * TPCANStatus CAN_ReadFD(TPCANHandle Channel, TPCANMsgFD* MessageBuffer, TPCANTimestampFD* TimestampBuffer); 00024 * TPCANStatus CAN_WriteFD(TPCANHandle Channel, TPCANMsgFD* MessageBuffer); 00025 * 00026 * includes : (none) 00027 * 00028 * author : Uwe Vogt, UV Software 00029 * 00030 * e-mail : uwe.vogt@uv-software.de 00031 * 00032 * 00033 * ----------- description -------------------------------------------- 00034 * 00035 * PCAN API - PEAK CAN Application Programming Interface 00036 * 00037 * This Application Programming Interface (API) is an almost compatible 00038 * implementation of the PEAK PCANBasic DLL on macOS (x86_64 and arm64). 00039 * 00040 * Supported CAN Interfaces: 00041 * - PCAN-USB 00042 * - PCAN-USB FD 00043 * Up to 8 devices are supported. 00044 * 00045 * Version of PCAN API: 00046 * - Based on PEAK's version of 2022-07-06 00047 */ 00048 00049 #ifndef PCAN_API_H_INCLUDED 00050 #define PCAN_API_H_INCLUDED 00051 00052 /* ----------- includes ----------------------------------------------- 00053 */ 00054 00055 #ifdef __APPLE__ 00056 #include <MacTypes.h> // To map Windows integer types 00057 #endif 00058 00059 /* ----------- defines ------------------------------------------------ 00060 */ 00061 00062 #ifdef __APPLE__ 00063 #ifndef BYTE 00064 #define BYTE UInt8 00065 #endif 00066 #ifndef WORD 00067 #define WORD UInt16 00068 #endif 00069 #ifndef DWORD 00070 #define DWORD UInt32 00071 #endif 00072 #ifndef UINT64 00073 #define UINT64 UInt64 00074 #endif 00075 #ifndef LPSTR 00076 #define LPSTR char* 00077 #endif 00078 #define __T(s) s 00079 #endif 00080 00081 /* Defined and supported PCAN channels 00082 */ 00083 #define PCAN_NONEBUS 0x00U //!< Undefined/default value for a PCAN bus 00084 00085 #define PCAN_USBBUS1 0x51U //!< PCAN-USB interface, channel 1 00086 #define PCAN_USBBUS2 0x52U //!< PCAN-USB interface, channel 2 00087 #define PCAN_USBBUS3 0x53U //!< PCAN-USB interface, channel 3 00088 #define PCAN_USBBUS4 0x54U //!< PCAN-USB interface, channel 4 00089 #define PCAN_USBBUS5 0x55U //!< PCAN-USB interface, channel 5 00090 #define PCAN_USBBUS6 0x56U //!< PCAN-USB interface, channel 6 00091 #define PCAN_USBBUS7 0x57U //!< PCAN-USB interface, channel 7 00092 #define PCAN_USBBUS8 0x58U //!< PCAN-USB interface, channel 8 00093 #ifndef __APPLE__ 00094 #define PCAN_USBBUS9 0x509U //!< PCAN-USB interface, channel 9 00095 #define PCAN_USBBUS10 0x50AU //!< PCAN-USB interface, channel 10 00096 #define PCAN_USBBUS11 0x50BU //!< PCAN-USB interface, channel 11 00097 #define PCAN_USBBUS12 0x50CU //!< PCAN-USB interface, channel 12 00098 #define PCAN_USBBUS13 0x50DU //!< PCAN-USB interface, channel 13 00099 #define PCAN_USBBUS14 0x50EU //!< PCAN-USB interface, channel 14 00100 #define PCAN_USBBUS15 0x50FU //!< PCAN-USB interface, channel 15 00101 #define PCAN_USBBUS16 0x510U //!< PCAN-USB interface, channel 16 00102 #endif 00103 00104 00105 /* PCAN error and status codes 00106 */ 00107 #define PCAN_ERROR_OK 0x00000U //!< No error 00108 #define PCAN_ERROR_XMTFULL 0x00001U //!< Transmit buffer in CAN controller is full 00109 #define PCAN_ERROR_OVERRUN 0x00002U //!< CAN controller was read too late 00110 #define PCAN_ERROR_BUSLIGHT 0x00004U //!< Bus error: an error counter reached the 'light' limit 00111 #define PCAN_ERROR_BUSHEAVY 0x00008U //!< Bus error: an error counter reached the 'heavy' limit 00112 #define PCAN_ERROR_BUSWARNING PCAN_ERROR_BUSHEAVY //!< Bus error: an error counter reached the 'warning' limit 00113 #define PCAN_ERROR_BUSPASSIVE 0x40000U //!< Bus error: the CAN controller is error passive 00114 #define PCAN_ERROR_BUSOFF 0x00010U //!< Bus error: the CAN controller is in bus-off state 00115 #define PCAN_ERROR_ANYBUSERR (PCAN_ERROR_BUSWARNING | PCAN_ERROR_BUSLIGHT | PCAN_ERROR_BUSHEAVY | PCAN_ERROR_BUSOFF | PCAN_ERROR_BUSPASSIVE) //!< Mask for all bus errors 00116 #define PCAN_ERROR_QRCVEMPTY 0x00020U //!< Receive queue is empty 00117 #define PCAN_ERROR_QOVERRUN 0x00040U //!< Receive queue was read too late 00118 #define PCAN_ERROR_QXMTFULL 0x00080U //!< Transmit queue is full 00119 #define PCAN_ERROR_REGTEST 0x00100U //!< Test of the CAN controller hardware registers failed (no hardware found) 00120 #define PCAN_ERROR_NODRIVER 0x00200U //!< Driver not loaded 00121 #define PCAN_ERROR_HWINUSE 0x00400U //!< Hardware already in use by a Net 00122 #define PCAN_ERROR_NETINUSE 0x00800U //!< A Client is already connected to the Net 00123 #define PCAN_ERROR_ILLHW 0x01400U //!< Hardware handle is invalid 00124 #define PCAN_ERROR_ILLNET 0x01800U //!< Net handle is invalid 00125 #define PCAN_ERROR_ILLCLIENT 0x01C00U //!< Client handle is invalid 00126 #define PCAN_ERROR_ILLHANDLE (PCAN_ERROR_ILLHW | PCAN_ERROR_ILLNET | PCAN_ERROR_ILLCLIENT) //!< Mask for all handle errors 00127 #define PCAN_ERROR_RESOURCE 0x02000U //!< Resource (FIFO, Client, timeout) cannot be created 00128 #define PCAN_ERROR_ILLPARAMTYPE 0x04000U //!< Invalid parameter 00129 #define PCAN_ERROR_ILLPARAMVAL 0x08000U //!< Invalid parameter value 00130 #define PCAN_ERROR_UNKNOWN 0x10000U //!< Unknown error 00131 #define PCAN_ERROR_ILLDATA 0x20000U //!< Invalid data, function, or action 00132 #define PCAN_ERROR_ILLMODE 0x80000U //!< Driver object state is wrong for the attempted operation 00133 #define PCAN_ERROR_CAUTION 0x2000000U //!< An operation was successfully carried out, however, irregularities were registered 00134 #define PCAN_ERROR_INITIALIZE 0x4000000U //!< Channel is not initialized [Value was changed from 0x40000 to 0x4000000] 00135 #define PCAN_ERROR_ILLOPERATION 0x8000000U //!< Invalid operation [Value was changed from 0x80000 to 0x8000000] 00136 00137 /* PCAN devices 00138 */ 00139 #define PCAN_NONE 0x00U //!< Undefined, unknown or not selected PCAN device value 00140 #define PCAN_PEAKCAN 0x01U //!< PCAN Non-PnP devices. NOT USED WITHIN PCAN-Basic API 00141 #define PCAN_ISA 0x02U //!< PCAN-ISA, PCAN-PC/104, and PCAN-PC/104-Plus 00142 #define PCAN_DNG 0x03U //!< PCAN-Dongle 00143 #define PCAN_PCI 0x04U //!< PCAN-PCI, PCAN-cPCI, PCAN-miniPCI, and PCAN-PCI Express 00144 #define PCAN_USB 0x05U //!< PCAN-USB and PCAN-USB Pro 00145 #define PCAN_PCC 0x06U //!< PCAN-PC Card 00146 #define PCAN_VIRTUAL 0x07U //!< PCAN Virtual hardware. NOT USED WITHIN PCAN-Basic API 00147 #define PCAN_LAN 0x08U //!< PCAN Gateway devices 00148 00149 /* PCAN parameters 00150 */ 00151 #define PCAN_DEVICE_ID 0x01U //!< Device identifier parameter 00152 #define PCAN_5VOLTS_POWER 0x02U //!< 5-Volt power parameter 00153 #define PCAN_RECEIVE_EVENT 0x03U //!< PCAN receive event handler parameter 00154 #define PCAN_MESSAGE_FILTER 0x04U //!< PCAN message filter parameter 00155 #define PCAN_API_VERSION 0x05U //!< PCAN-Basic API version parameter 00156 #define PCAN_CHANNEL_VERSION 0x06U //!< PCAN device channel version parameter 00157 #define PCAN_BUSOFF_AUTORESET 0x07U //!< PCAN Reset-On-Busoff parameter 00158 #define PCAN_LISTEN_ONLY 0x08U //!< PCAN Listen-Only parameter 00159 #define PCAN_LOG_LOCATION 0x09U //!< Directory path for log files 00160 #define PCAN_LOG_STATUS 0x0AU //!< Debug-Log activation status 00161 #define PCAN_LOG_CONFIGURE 0x0BU //!< Configuration of the debugged information (LOG_FUNCTION_***) 00162 #define PCAN_LOG_TEXT 0x0CU //!< Custom insertion of text into the log file 00163 #define PCAN_CHANNEL_CONDITION 0x0DU //!< Availability status of a PCAN-Channel 00164 #define PCAN_HARDWARE_NAME 0x0EU //!< PCAN hardware name parameter 00165 #define PCAN_RECEIVE_STATUS 0x0FU //!< Message reception status of a PCAN-Channel 00166 #define PCAN_CONTROLLER_NUMBER 0x10U //!< CAN-Controller number of a PCAN-Channel 00167 #define PCAN_TRACE_LOCATION 0x11U //!< Directory path for PCAN trace files 00168 #define PCAN_TRACE_STATUS 0x12U //!< CAN tracing activation status 00169 #define PCAN_TRACE_SIZE 0x13U //!< Configuration of the maximum file size of a CAN trace 00170 #define PCAN_TRACE_CONFIGURE 0x14U //!< Configuration of the trace file storing mode (TRACE_FILE_***) 00171 #define PCAN_CHANNEL_IDENTIFYING 0x15U //!< Physical identification of a USB based PCAN-Channel by blinking its associated LED 00172 #define PCAN_CHANNEL_FEATURES 0x16U //!< Capabilities of a PCAN device (FEATURE_***) 00173 #define PCAN_BITRATE_ADAPTING 0x17U //!< Using of an existing bit rate (PCAN-View connected to a channel) 00174 #define PCAN_BITRATE_INFO 0x18U //!< Configured bit rate as Btr0Btr1 value 00175 #define PCAN_BITRATE_INFO_FD 0x19U //!< Configured bit rate as TPCANBitrateFD string 00176 #define PCAN_BUSSPEED_NOMINAL 0x1AU //!< Configured nominal CAN Bus speed as Bits per seconds 00177 #define PCAN_BUSSPEED_DATA 0x1BU //!< Configured CAN data speed as Bits per seconds 00178 #define PCAN_IP_ADDRESS 0x1CU //!< Remote address of a LAN channel as string in IPv4 format 00179 #define PCAN_LAN_SERVICE_STATUS 0x1DU //!< Status of the Virtual PCAN-Gateway Service 00180 #define PCAN_ALLOW_STATUS_FRAMES 0x1EU //!< Status messages reception status within a PCAN-Channel 00181 #define PCAN_ALLOW_RTR_FRAMES 0x1FU //!< RTR messages reception status within a PCAN-Channel 00182 #define PCAN_ALLOW_ERROR_FRAMES 0x20U //!< Error messages reception status within a PCAN-Channel 00183 #define PCAN_INTERFRAME_DELAY 0x21U //!< Delay, in microseconds, between sending frames 00184 #define PCAN_ACCEPTANCE_FILTER_11BIT 0x22U //!< Filter over code and mask patterns for 11-Bit messages 00185 #define PCAN_ACCEPTANCE_FILTER_29BIT 0x23U //!< Filter over code and mask patterns for 29-Bit messages 00186 #define PCAN_IO_DIGITAL_CONFIGURATION 0x24U //!< Output mode of 32 digital I/O pin of a PCAN-USB Chip. 1: Output-Active 0 : Output Inactive 00187 #define PCAN_IO_DIGITAL_VALUE 0x25U //!< Value assigned to a 32 digital I/O pins of a PCAN-USB Chip 00188 #define PCAN_IO_DIGITAL_SET 0x26U //!< Value assigned to a 32 digital I/O pins of a PCAN-USB Chip - Multiple digital I/O pins to 1 = High 00189 #define PCAN_IO_DIGITAL_CLEAR 0x27U //!< Clear multiple digital I/O pins to 0 00190 #define PCAN_IO_ANALOG_VALUE 0x28U //!< Get value of a single analog input pin 00191 #define PCAN_FIRMWARE_VERSION 0x29U //!< Get the version of the firmware used by the device associated with a PCAN-Channel 00192 #define PCAN_ATTACHED_CHANNELS_COUNT 0x2AU //!< Get the amount of PCAN channels attached to a system 00193 #define PCAN_ATTACHED_CHANNELS 0x2BU //!< Get information about PCAN channels attached to a system 00194 #define PCAN_ALLOW_ECHO_FRAMES 0x2CU //!< Echo messages reception status within a PCAN-Channel 00195 #define PCAN_DEVICE_PART_NUMBER 0x2DU //!< Get the part number associated to a device 00196 #define PCAN_EXT_BTR0BTR1 0x80U //!< UVS: bit-timing register 00197 #define PCAN_EXT_TX_COUNTER 0x81U //!< UVS: number of transmitted frames 00198 #define PCAN_EXT_RX_COUNTER 0x82U //!< UVS: number of received frames 00199 #define PCAN_EXT_ERR_COUNTER 0x83U //!< UVS: number of error frames 00200 #define PCAN_EXT_RX_QUE_OVERRUN 0x84U //!< UVS: receive queue overrun counter 00201 #define PCAN_EXT_HARDWARE_VERSION 0x85U //!< UVS: version number of the interface firmware 00202 #define PCAN_EXT_SOFTWARE_VERSION 0x86U //!< UVS: version number of the driver respectively library 00203 #define PCAN_EXT_RECEIVE_CALLBACK 0x87U //!< UVS: callback function called on the reception of an URB 00204 #define PCAN_EXT_LOG_USB 0x8FU //!< UVS: Log USB communication (URB buffer <==> CAN messages) 00205 00206 /* DEPRECATED parameters 00207 */ 00208 #define PCAN_DEVICE_NUMBER PCAN_DEVICE_ID //!< Deprecated parameter. Use PCAN_DEVICE_ID instead 00209 00210 /* PCAN parameter values 00211 */ 00212 #define PCAN_PARAMETER_OFF 0x00U //!< The PCAN parameter is not set (inactive) 00213 #define PCAN_PARAMETER_ON 0x01U //!< The PCAN parameter is set (active) 00214 #define PCAN_FILTER_CLOSE 0x00U //!< The PCAN filter is closed. No messages will be received 00215 #define PCAN_FILTER_OPEN 0x01U //!< The PCAN filter is fully opened. All messages will be received 00216 #define PCAN_FILTER_CUSTOM 0x02U //!< The PCAN filter is custom configured. Only registered messages will be received 00217 #define PCAN_CHANNEL_UNAVAILABLE 0x00U //!< The PCAN-Channel handle is illegal, or its associated hardware is not available 00218 #define PCAN_CHANNEL_AVAILABLE 0x01U //!< The PCAN-Channel handle is available to be connected (PnP Hardware: it means furthermore that the hardware is plugged-in) 00219 #define PCAN_CHANNEL_OCCUPIED 0x02U //!< The PCAN-Channel handle is valid, and is already being used 00220 #define PCAN_CHANNEL_PCANVIEW (PCAN_CHANNEL_AVAILABLE | PCAN_CHANNEL_OCCUPIED) //!< The PCAN-Channel handle is already being used by a PCAN-View application, but is available to connect 00221 00222 #define LOG_FUNCTION_DEFAULT 0x00U //!< Logs system exceptions / errors 00223 #define LOG_FUNCTION_ENTRY 0x01U //!< Logs the entries to the PCAN-Basic API functions 00224 #define LOG_FUNCTION_PARAMETERS 0x02U //!< Logs the parameters passed to the PCAN-Basic API functions 00225 #define LOG_FUNCTION_LEAVE 0x04U //!< Logs the exits from the PCAN-Basic API functions 00226 #define LOG_FUNCTION_WRITE 0x08U //!< Logs the CAN messages passed to the CAN_Write function 00227 #define LOG_FUNCTION_READ 0x10U //!< Logs the CAN messages received within the CAN_Read function 00228 #define LOG_FUNCTION_ALL 0xFFFFU //!< Logs all possible information within the PCAN-Basic API functions 00229 00230 #define TRACE_FILE_SINGLE 0x00U //!< A single file is written until it size reaches PAN_TRACE_SIZE 00231 #define TRACE_FILE_SEGMENTED 0x01U //!< Traced data is distributed in several files with size PAN_TRACE_SIZE 00232 #define TRACE_FILE_DATE 0x02U //!< Includes the date into the name of the trace file 00233 #define TRACE_FILE_TIME 0x04U //!< Includes the start time into the name of the trace file 00234 #define TRACE_FILE_OVERWRITE 0x80U //!< Causes the overwriting of available traces (same name) 00235 00236 #define FEATURE_FD_CAPABLE 0x01U //!< Device supports flexible data-rate (CAN-FD) 00237 #define FEATURE_DELAY_CAPABLE 0x02U //!< Device supports a delay between sending frames (FPGA based USB devices) 00238 #define FEATURE_IO_CAPABLE 0x04U //!< Device supports I/O functionality for electronic circuits (USB-Chip devices) 00239 00240 #define SERVICE_STATUS_STOPPED 0x01U //!< The service is not running 00241 #define SERVICE_STATUS_RUNNING 0x04U //!< The service is running 00242 00243 /* Other constants 00244 */ 00245 #define MAX_LENGTH_HARDWARE_NAME 33 //!< Maximum length of the name of a device: 32 characters + terminator 00246 #define MAX_LENGTH_VERSION_STRING 256 //!< Maximum length of a version string: 17 characters + terminator 00247 00248 /* PCAN message types 00249 */ 00250 #define PCAN_MESSAGE_STANDARD 0x00U //!< The PCAN message is a CAN Standard Frame (11-bit identifier) 00251 #define PCAN_MESSAGE_RTR 0x01U //!< The PCAN message is a CAN Remote-Transfer-Request Frame 00252 #define PCAN_MESSAGE_EXTENDED 0x02U //!< The PCAN message is a CAN Extended Frame (29-bit identifier) 00253 #define PCAN_MESSAGE_FD 0x04U //!< The PCAN message represents a FD frame in terms of CiA Specs 00254 #define PCAN_MESSAGE_BRS 0x08U //!< The PCAN message represents a FD bit rate switch (CAN data at a higher bit rate) 00255 #define PCAN_MESSAGE_ESI 0x10U //!< The PCAN message represents a FD error state indicator(CAN FD transmitter was error active) 00256 #define PCAN_MESSAGE_ECHO 0x20U //!< The PCAN message represents an echo CAN Frame 00257 #define PCAN_MESSAGE_ERRFRAME 0x40U //!< The PCAN message represents an error frame 00258 #define PCAN_MESSAGE_STATUS 0x80U //!< The PCAN message represents a PCAN status message 00259 00260 /* LookUp Parameters 00261 */ 00262 #define LOOKUP_DEVICE_TYPE __T("devicetype") //!< Lookup channel by Device type (see PCAN devices e.g. PCAN_USB) 00263 #define LOOKUP_DEVICE_ID __T("deviceid") //!< Lookup channel by device id 00264 #define LOOKUP_CONTROLLER_NUMBER __T("controllernumber") //!< Lookup channel by CAN controller 0-based index 00265 #define LOOKUP_IP_ADDRESS __T("ipaddress") //!< Lookup channel by IP address (LAN channels only) 00266 00267 /* Frame Type / Initialization Mode 00268 */ 00269 #define PCAN_MODE_STANDARD PCAN_MESSAGE_STANDARD 00270 #define PCAN_MODE_EXTENDED PCAN_MESSAGE_EXTENDED 00271 00272 /* Baud rate codes = BTR0/BTR1 register values for the CAN controller. 00273 * You can define your own Baud rate with the BTROBTR1 register. 00274 * Take a look at www.peak-system.com for their free software "BAUDTOOL" 00275 * to calculate the BTROBTR1 register for every bit rate and sample point. 00276 */ 00277 #define PCAN_BAUD_1M 0x0014U //!< 1 MBit/s 00278 #define PCAN_BAUD_800K 0x0016U //!< 800 kBit/s 00279 #define PCAN_BAUD_500K 0x001CU //!< 500 kBit/s 00280 #define PCAN_BAUD_250K 0x011CU //!< 250 kBit/s 00281 #define PCAN_BAUD_125K 0x031CU //!< 125 kBit/s 00282 #define PCAN_BAUD_100K 0x432FU //!< 100 kBit/s 00283 #define PCAN_BAUD_95K 0xC34EU //!< 95,238 kBit/s 00284 #define PCAN_BAUD_83K 0x852BU //!< 83,333 kBit/s 00285 #define PCAN_BAUD_50K 0x472FU //!< 50 kBit/s 00286 #define PCAN_BAUD_47K 0x1414U //!< 47,619 kBit/s 00287 #define PCAN_BAUD_33K 0x8B2FU //!< 33,333 kBit/s 00288 #define PCAN_BAUD_20K 0x532FU //!< 20 kBit/s 00289 #define PCAN_BAUD_10K 0x672FU //!< 10 kBit/s 00290 #define PCAN_BAUD_5K 0x7F7FU //!< 5 kBit/s 00291 00292 /* Represents the configuration for a CAN bit rate 00293 * Note: 00294 * * Each parameter and its value must be separated with a '='. 00295 * * Each pair of parameter/value must be separated using ','. 00296 * 00297 * Example: 00298 * f_clock=80000000,nom_brp=10,nom_tseg1=5,nom_tseg2=2,nom_sjw=1,data_brp=4,data_tseg1=7,data_tseg2=2,data_sjw=1 00299 */ 00300 #define PCAN_BR_CLOCK __T("f_clock") 00301 #define PCAN_BR_CLOCK_MHZ __T("f_clock_mhz") 00302 #define PCAN_BR_NOM_BRP __T("nom_brp") 00303 #define PCAN_BR_NOM_TSEG1 __T("nom_tseg1") 00304 #define PCAN_BR_NOM_TSEG2 __T("nom_tseg2") 00305 #define PCAN_BR_NOM_SJW __T("nom_sjw") 00306 #define PCAN_BR_NOM_SAMPLE __T("nom_sam") 00307 #define PCAN_BR_DATA_BRP __T("data_brp") 00308 #define PCAN_BR_DATA_TSEG1 __T("data_tseg1") 00309 #define PCAN_BR_DATA_TSEG2 __T("data_tseg2") 00310 #define PCAN_BR_DATA_SJW __T("data_sjw") 00311 #define PCAN_BR_DATA_SAMPLE __T("data_ssp_offset") 00312 00313 /* ----------- types -------------------------------------------------- 00314 */ 00315 00316 #define TPCANHandle WORD //!< PCAN hardware channel handle 00317 #define TPCANStatus DWORD //!< PCAN status/error code (ATTENTION: changed from 64-bit to 32-bit) 00318 #define TPCANParameter BYTE //!< PCAN parameter to be read or set 00319 #define TPCANDevice BYTE //!< PCAN device 00320 #define TPCANMessageType BYTE //!< The type of a PCAN message 00321 #define TPCANType BYTE //!< The type of PCAN hardware to be initialized 00322 #define TPCANMode BYTE //!< PCAN filter mode 00323 #define TPCANBaudrate WORD //!< PCAN Baud rate register value 00324 #define TPCANBitrateFD LPSTR //!< PCAN-FD bit rate string 00325 #define TPCANTimestampFD UINT64//!< timestamp of a received PCAN FD message 00326 00329 typedef struct tagTPCANMsg 00330 { 00331 DWORD ID; 00332 TPCANMessageType MSGTYPE; 00333 BYTE LEN; 00334 BYTE DATA[8]; 00335 } TPCANMsg; 00336 00340 typedef struct tagTPCANTimestamp 00341 { 00342 DWORD millis; 00343 WORD millis_overflow; 00344 WORD micros; 00345 } TPCANTimestamp; 00346 00349 typedef struct tagTPCANMsgFD 00350 { 00351 DWORD ID; 00352 TPCANMessageType MSGTYPE; 00353 BYTE DLC; 00354 BYTE DATA[64]; 00355 } TPCANMsgFD; 00356 00359 typedef struct tagTPCANChannelInformation 00360 { 00361 TPCANHandle channel_handle; 00362 TPCANDevice device_type; 00363 BYTE controller_number; 00364 DWORD device_features; 00365 char device_name[MAX_LENGTH_HARDWARE_NAME]; 00366 DWORD device_id; 00367 DWORD channel_condition; 00368 }TPCANChannelInformation; 00369 00370 00371 /* ----------- variables ---------------------------------------------- 00372 */ 00373 00374 00375 /* ----------- prototypes --------------------------------------------- 00376 */ 00377 00378 #ifdef __cplusplus 00379 extern "C" { 00380 #define _DEF_ARG =0 00381 #else 00382 #define _DEF_ARG 00383 #endif 00384 00395 TPCANStatus CAN_Initialize( 00396 TPCANHandle Channel, 00397 TPCANBaudrate Btr0Btr1, 00398 TPCANType HwType _DEF_ARG, 00399 DWORD IOPort _DEF_ARG, 00400 WORD Interrupt _DEF_ARG); 00401 00421 TPCANStatus CAN_InitializeFD( 00422 TPCANHandle Channel, 00423 TPCANBitrateFD BitrateFD); 00424 00433 TPCANStatus CAN_Uninitialize( 00434 TPCANHandle Channel); 00435 00444 TPCANStatus CAN_Reset( 00445 TPCANHandle Channel); 00446 00453 TPCANStatus CAN_GetStatus( 00454 TPCANHandle Channel); 00455 00465 TPCANStatus CAN_Read( 00466 TPCANHandle Channel, 00467 TPCANMsg* MessageBuffer, 00468 TPCANTimestamp* TimestampBuffer); 00469 00479 TPCANStatus CAN_ReadFD( 00480 TPCANHandle Channel, 00481 TPCANMsgFD* MessageBuffer, 00482 TPCANTimestampFD* TimestampBuffer); 00483 00491 TPCANStatus CAN_Write( 00492 TPCANHandle Channel, 00493 TPCANMsg* MessageBuffer); 00494 00502 TPCANStatus CAN_WriteFD( 00503 TPCANHandle Channel, 00504 TPCANMsgFD* MessageBuffer); 00505 00518 TPCANStatus CAN_FilterMessages( 00519 TPCANHandle Channel, 00520 DWORD FromID, 00521 DWORD ToID, 00522 TPCANMode Mode); 00523 00536 TPCANStatus CAN_GetValue( 00537 TPCANHandle Channel, 00538 TPCANParameter Parameter, 00539 void* Buffer, 00540 DWORD BufferLength); 00541 00542 00555 TPCANStatus CAN_SetValue( 00556 TPCANHandle Channel, 00557 TPCANParameter Parameter, 00558 void* Buffer, 00559 DWORD BufferLength); 00560 00572 TPCANStatus CAN_GetErrorText( 00573 TPCANStatus Error, 00574 WORD Language, 00575 LPSTR Buffer); 00576 00585 TPCANStatus CAN_LookUpChannel( 00586 LPSTR Parameters, 00587 TPCANHandle* FoundChannel); 00588 00589 #ifdef __cplusplus 00590 } 00591 #endif 00592 #endif /* PCAN_API_H_INCLUDED */ 00593 00594 /* ---------------------------------------------------------------------- 00595 * Uwe Vogt, UV Software, Chausseestrasse 33 A, 10115 Berlin, Germany 00596 * Tel.: +49-30-46799872, Fax: +49-30-46799873, Mobile: +49-170-3801903 00597 * E-Mail: uwe.vogt@uv-software.de, Homepage: http://www.uv-software.de/ 00598 */