diff --git a/Host/Source/LibOpenBLT/CMakeLists.txt b/Host/Source/LibOpenBLT/CMakeLists.txt
index 7b0a8a8d..da0a62a5 100644
--- a/Host/Source/LibOpenBLT/CMakeLists.txt
+++ b/Host/Source/LibOpenBLT/CMakeLists.txt
@@ -88,8 +88,21 @@ endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
#***************************************************************************************
# Includes
#****************************************************************************************
+# Source: http://www.vtk.org/Wiki/CMake/Examples
+macro (header_directories return_list dir)
+ file(GLOB_RECURSE new_list ${dir}/*.h)
+ set(dir_list "")
+ foreach(file_path ${new_list})
+ get_filename_component(dir_path ${file_path} PATH)
+ set(dir_list ${dir_list} ${dir_path})
+ endforeach()
+ list(REMOVE_DUPLICATES dir_list)
+ set(${return_list} ${dir_list})
+endmacro()
+
# Set include directories
-include_directories("${PROJECT_SOURCE_DIR}" "${PROJECT_PORT_DIR}")
+header_directories(PROJECT_PORT_INC_DIRS "${PROJECT_PORT_DIR}")
+include_directories("${PROJECT_SOURCE_DIR}" "${PROJECT_PORT_INC_DIRS}")
#***************************************************************************************
@@ -97,22 +110,18 @@ include_directories("${PROJECT_SOURCE_DIR}" "${PROJECT_PORT_DIR}")
#****************************************************************************************
# Get header files from the root directory and the port directory.
file(GLOB INCS_ROOT "*.h")
-file(GLOB INCS_PORT "${PROJECT_PORT_DIR}/*.h")
+file(GLOB_RECURSE INCS_PORT "${PROJECT_PORT_DIR}/*.h")
set(INCS ${INCS_ROOT} ${INCS_PORT})
+# Get source files from the root directory and the port directory.
+file(GLOB SRCS_ROOT "*.c")
+file(GLOB_RECURSE SRCS_PORT "${PROJECT_PORT_DIR}/*.c")
+set(SRCS ${SRCS_ROOT} ${SRCS_PORT})
+
# Add sources
set(
LIB_SRCS
- openblt.c
- session.c
- candriver.c
- xcploader.c
- xcptpuart.c
- firmware.c
- srecparser.c
- util.c
- ${PROJECT_PORT_DIR}/timeutil.c
- ${PROJECT_PORT_DIR}/serialport.c
+ ${SRCS}
${INCS}
)
diff --git a/Host/Source/LibOpenBLT/candriver.c b/Host/Source/LibOpenBLT/candriver.c
index b780839f..9b570ae4 100644
--- a/Host/Source/LibOpenBLT/candriver.c
+++ b/Host/Source/LibOpenBLT/candriver.c
@@ -1,7 +1,7 @@
/************************************************************************************//**
* \file candriver.c
* \brief Generic CAN driver source file.
-* \ingroup Session
+* \ingroup CanDriver
* \internal
*----------------------------------------------------------------------------------------
* C O P Y R I G H T
diff --git a/Host/Source/LibOpenBLT/candriver.h b/Host/Source/LibOpenBLT/candriver.h
index 3119ecbf..21d2f69a 100644
--- a/Host/Source/LibOpenBLT/candriver.h
+++ b/Host/Source/LibOpenBLT/candriver.h
@@ -1,7 +1,7 @@
/************************************************************************************//**
* \file candriver.h
* \brief Generic CAN driver header file.
-* \ingroup Session
+* \ingroup CanDriver
* \internal
*----------------------------------------------------------------------------------------
* C O P Y R I G H T
@@ -25,6 +25,11 @@
*
* \endinternal
****************************************************************************************/
+/************************************************************************************//**
+* \defgroup CanDriver CAN driver
+* \brief This module implements a generic CAN driver.
+* \ingroup Session
+****************************************************************************************/
#ifndef CANDRIVER_H
#define CANDRIVER_H
diff --git a/Host/Source/LibOpenBLT/port/linux/serialport.c b/Host/Source/LibOpenBLT/port/linux/serialport.c
index bf99ce6d..005b277f 100644
--- a/Host/Source/LibOpenBLT/port/linux/serialport.c
+++ b/Host/Source/LibOpenBLT/port/linux/serialport.c
@@ -1,7 +1,7 @@
/************************************************************************************//**
* \file port/linux/serialport.c
* \brief Serial port source file.
-* \ingroup Session
+* \ingroup SerialPort
* \internal
*----------------------------------------------------------------------------------------
* C O P Y R I G H T
diff --git a/Host/Source/LibOpenBLT/port/windows/canif/peak/PCANBasic.h b/Host/Source/LibOpenBLT/port/windows/canif/peak/PCANBasic.h
new file mode 100644
index 00000000..c723c21c
--- /dev/null
+++ b/Host/Source/LibOpenBLT/port/windows/canif/peak/PCANBasic.h
@@ -0,0 +1,524 @@
+// PCANBasic.h
+//
+// ~~~~~~~~~~~~
+//
+// PCAN-Basic API
+//
+// ~~~~~~~~~~~~
+//
+// ------------------------------------------------------------------
+// Author : Keneth Wagner
+// Last change: 18.05.2016 Wagner
+//
+// Language: ANSI-C
+// ------------------------------------------------------------------
+//
+// Copyright (C) 1999-2016 PEAK-System Technik GmbH, Darmstadt
+// more Info at http://www.peak-system.com
+//
+#ifndef __PCANBASICH__
+#define __PCANBASICH__
+
+////////////////////////////////////////////////////////////
+// Value definitions
+////////////////////////////////////////////////////////////
+
+// Currently defined and supported PCAN channels
+//
+#define PCAN_NONEBUS 0x00U // Undefined/default value for a PCAN bus
+
+#define PCAN_ISABUS1 0x21U // PCAN-ISA interface, channel 1
+#define PCAN_ISABUS2 0x22U // PCAN-ISA interface, channel 2
+#define PCAN_ISABUS3 0x23U // PCAN-ISA interface, channel 3
+#define PCAN_ISABUS4 0x24U // PCAN-ISA interface, channel 4
+#define PCAN_ISABUS5 0x25U // PCAN-ISA interface, channel 5
+#define PCAN_ISABUS6 0x26U // PCAN-ISA interface, channel 6
+#define PCAN_ISABUS7 0x27U // PCAN-ISA interface, channel 7
+#define PCAN_ISABUS8 0x28U // PCAN-ISA interface, channel 8
+
+#define PCAN_DNGBUS1 0x31U // PCAN-Dongle/LPT interface, channel 1
+
+#define PCAN_PCIBUS1 0x41U // PCAN-PCI interface, channel 1
+#define PCAN_PCIBUS2 0x42U // PCAN-PCI interface, channel 2
+#define PCAN_PCIBUS3 0x43U // PCAN-PCI interface, channel 3
+#define PCAN_PCIBUS4 0x44U // PCAN-PCI interface, channel 4
+#define PCAN_PCIBUS5 0x45U // PCAN-PCI interface, channel 5
+#define PCAN_PCIBUS6 0x46U // PCAN-PCI interface, channel 6
+#define PCAN_PCIBUS7 0x47U // PCAN-PCI interface, channel 7
+#define PCAN_PCIBUS8 0x48U // PCAN-PCI interface, channel 8
+#define PCAN_PCIBUS9 0x409U // PCAN-PCI interface, channel 9
+#define PCAN_PCIBUS10 0x40AU // PCAN-PCI interface, channel 10
+#define PCAN_PCIBUS11 0x40BU // PCAN-PCI interface, channel 11
+#define PCAN_PCIBUS12 0x40CU // PCAN-PCI interface, channel 12
+#define PCAN_PCIBUS13 0x40DU // PCAN-PCI interface, channel 13
+#define PCAN_PCIBUS14 0x40EU // PCAN-PCI interface, channel 14
+#define PCAN_PCIBUS15 0x40FU // PCAN-PCI interface, channel 15
+#define PCAN_PCIBUS16 0x410U // PCAN-PCI interface, channel 16
+
+#define PCAN_USBBUS1 0x51U // PCAN-USB interface, channel 1
+#define PCAN_USBBUS2 0x52U // PCAN-USB interface, channel 2
+#define PCAN_USBBUS3 0x53U // PCAN-USB interface, channel 3
+#define PCAN_USBBUS4 0x54U // PCAN-USB interface, channel 4
+#define PCAN_USBBUS5 0x55U // PCAN-USB interface, channel 5
+#define PCAN_USBBUS6 0x56U // PCAN-USB interface, channel 6
+#define PCAN_USBBUS7 0x57U // PCAN-USB interface, channel 7
+#define PCAN_USBBUS8 0x58U // PCAN-USB interface, channel 8
+#define PCAN_USBBUS9 0x509U // PCAN-USB interface, channel 9
+#define PCAN_USBBUS10 0x50AU // PCAN-USB interface, channel 10
+#define PCAN_USBBUS11 0x50BU // PCAN-USB interface, channel 11
+#define PCAN_USBBUS12 0x50CU // PCAN-USB interface, channel 12
+#define PCAN_USBBUS13 0x50DU // PCAN-USB interface, channel 13
+#define PCAN_USBBUS14 0x50EU // PCAN-USB interface, channel 14
+#define PCAN_USBBUS15 0x50FU // PCAN-USB interface, channel 15
+#define PCAN_USBBUS16 0x510U // PCAN-USB interface, channel 16
+
+#define PCAN_PCCBUS1 0x61U // PCAN-PC Card interface, channel 1
+#define PCAN_PCCBUS2 0x62U // PCAN-PC Card interface, channel 2
+
+#define PCAN_LANBUS1 0x801U // PCAN-LAN interface, channel 1
+#define PCAN_LANBUS2 0x802U // PCAN-LAN interface, channel 2
+#define PCAN_LANBUS3 0x803U // PCAN-LAN interface, channel 3
+#define PCAN_LANBUS4 0x804U // PCAN-LAN interface, channel 4
+#define PCAN_LANBUS5 0x805U // PCAN-LAN interface, channel 5
+#define PCAN_LANBUS6 0x806U // PCAN-LAN interface, channel 6
+#define PCAN_LANBUS7 0x807U // PCAN-LAN interface, channel 7
+#define PCAN_LANBUS8 0x808U // PCAN-LAN interface, channel 8
+#define PCAN_LANBUS9 0x809U // PCAN-LAN interface, channel 9
+#define PCAN_LANBUS10 0x80AU // PCAN-LAN interface, channel 10
+#define PCAN_LANBUS11 0x80BU // PCAN-LAN interface, channel 11
+#define PCAN_LANBUS12 0x80CU // PCAN-LAN interface, channel 12
+#define PCAN_LANBUS13 0x80DU // PCAN-LAN interface, channel 13
+#define PCAN_LANBUS14 0x80EU // PCAN-LAN interface, channel 14
+#define PCAN_LANBUS15 0x80FU // PCAN-LAN interface, channel 15
+#define PCAN_LANBUS16 0x810U // PCAN-LAN interface, channel 16
+
+// Represent the PCAN error and status codes
+//
+#define PCAN_ERROR_OK 0x00000U // No error
+#define PCAN_ERROR_XMTFULL 0x00001U // Transmit buffer in CAN controller is full
+#define PCAN_ERROR_OVERRUN 0x00002U // CAN controller was read too late
+#define PCAN_ERROR_BUSLIGHT 0x00004U // Bus error: an error counter reached the 'light' limit
+#define PCAN_ERROR_BUSHEAVY 0x00008U // Bus error: an error counter reached the 'heavy' limit
+#define PCAN_ERROR_BUSWARNING PCAN_ERROR_BUSHEAVY // Bus error: an error counter reached the 'warning' limit
+#define PCAN_ERROR_BUSPASSIVE 0x40000U // Bus error: the CAN controller is error passive
+#define PCAN_ERROR_BUSOFF 0x00010U // Bus error: the CAN controller is in bus-off state
+#define PCAN_ERROR_ANYBUSERR (PCAN_ERROR_BUSWARNING | PCAN_ERROR_BUSLIGHT | PCAN_ERROR_BUSHEAVY | PCAN_ERROR_BUSOFF | PCAN_ERROR_BUSPASSIVE) // Mask for all bus errors
+#define PCAN_ERROR_QRCVEMPTY 0x00020U // Receive queue is empty
+#define PCAN_ERROR_QOVERRUN 0x00040U // Receive queue was read too late
+#define PCAN_ERROR_QXMTFULL 0x00080U // Transmit queue is full
+#define PCAN_ERROR_REGTEST 0x00100U // Test of the CAN controller hardware registers failed (no hardware found)
+#define PCAN_ERROR_NODRIVER 0x00200U // Driver not loaded
+#define PCAN_ERROR_HWINUSE 0x00400U // Hardware already in use by a Net
+#define PCAN_ERROR_NETINUSE 0x00800U // A Client is already connected to the Net
+#define PCAN_ERROR_ILLHW 0x01400U // Hardware handle is invalid
+#define PCAN_ERROR_ILLNET 0x01800U // Net handle is invalid
+#define PCAN_ERROR_ILLCLIENT 0x01C00U // Client handle is invalid
+#define PCAN_ERROR_ILLHANDLE (PCAN_ERROR_ILLHW | PCAN_ERROR_ILLNET | PCAN_ERROR_ILLCLIENT) // Mask for all handle errors
+#define PCAN_ERROR_RESOURCE 0x02000U // Resource (FIFO, Client, timeout) cannot be created
+#define PCAN_ERROR_ILLPARAMTYPE 0x04000U // Invalid parameter
+#define PCAN_ERROR_ILLPARAMVAL 0x08000U // Invalid parameter value
+#define PCAN_ERROR_UNKNOWN 0x10000U // Unknown error
+#define PCAN_ERROR_ILLDATA 0x20000U // Invalid data, function, or action
+#define PCAN_ERROR_CAUTION 0x2000000U // An operation was successfully carried out, however, irregularities were registered
+#define PCAN_ERROR_INITIALIZE 0x4000000U // Channel is not initialized [Value was changed from 0x40000 to 0x4000000]
+#define PCAN_ERROR_ILLOPERATION 0x8000000U // Invalid operation [Value was changed from 0x80000 to 0x8000000]
+
+// PCAN devices
+//
+#define PCAN_NONE 0x00U // Undefined, unknown or not selected PCAN device value
+#define PCAN_PEAKCAN 0x01U // PCAN Non-Plug&Play devices. NOT USED WITHIN PCAN-Basic API
+#define PCAN_ISA 0x02U // PCAN-ISA, PCAN-PC/104, and PCAN-PC/104-Plus
+#define PCAN_DNG 0x03U // PCAN-Dongle
+#define PCAN_PCI 0x04U // PCAN-PCI, PCAN-cPCI, PCAN-miniPCI, and PCAN-PCI Express
+#define PCAN_USB 0x05U // PCAN-USB and PCAN-USB Pro
+#define PCAN_PCC 0x06U // PCAN-PC Card
+#define PCAN_VIRTUAL 0x07U // PCAN Virtual hardware. NOT USED WITHIN PCAN-Basic API
+#define PCAN_LAN 0x08U // PCAN Gateway devices
+
+// PCAN parameters
+//
+#define PCAN_DEVICE_NUMBER 0x01U // PCAN-USB device number parameter
+#define PCAN_5VOLTS_POWER 0x02U // PCAN-PC Card 5-Volt power parameter
+#define PCAN_RECEIVE_EVENT 0x03U // PCAN receive event handler parameter
+#define PCAN_MESSAGE_FILTER 0x04U // PCAN message filter parameter
+#define PCAN_API_VERSION 0x05U // PCAN-Basic API version parameter
+#define PCAN_CHANNEL_VERSION 0x06U // PCAN device channel version parameter
+#define PCAN_BUSOFF_AUTORESET 0x07U // PCAN Reset-On-Busoff parameter
+#define PCAN_LISTEN_ONLY 0x08U // PCAN Listen-Only parameter
+#define PCAN_LOG_LOCATION 0x09U // Directory path for log files
+#define PCAN_LOG_STATUS 0x0AU // Debug-Log activation status
+#define PCAN_LOG_CONFIGURE 0x0BU // Configuration of the debugged information (LOG_FUNCTION_***)
+#define PCAN_LOG_TEXT 0x0CU // Custom insertion of text into the log file
+#define PCAN_CHANNEL_CONDITION 0x0DU // Availability status of a PCAN-Channel
+#define PCAN_HARDWARE_NAME 0x0EU // PCAN hardware name parameter
+#define PCAN_RECEIVE_STATUS 0x0FU // Message reception status of a PCAN-Channel
+#define PCAN_CONTROLLER_NUMBER 0x10U // CAN-Controller number of a PCAN-Channel
+#define PCAN_TRACE_LOCATION 0x11U // Directory path for PCAN trace files
+#define PCAN_TRACE_STATUS 0x12U // CAN tracing activation status
+#define PCAN_TRACE_SIZE 0x13U // Configuration of the maximum file size of a CAN trace
+#define PCAN_TRACE_CONFIGURE 0x14U // Configuration of the trace file storing mode (TRACE_FILE_***)
+#define PCAN_CHANNEL_IDENTIFYING 0x15U // Physical identification of a USB based PCAN-Channel by blinking its associated LED
+#define PCAN_CHANNEL_FEATURES 0x16U // Capabilities of a PCAN device (FEATURE_***)
+#define PCAN_BITRATE_ADAPTING 0x17U // Using of an existing bit rate (PCAN-View connected to a channel)
+#define PCAN_BITRATE_INFO 0x18U // Configured bit rate as Btr0Btr1 value
+#define PCAN_BITRATE_INFO_FD 0x19U // Configured bit rate as TPCANBitrateFD string
+#define PCAN_BUSSPEED_NOMINAL 0x1AU // Configured nominal CAN Bus speed as Bits per seconds
+#define PCAN_BUSSPEED_DATA 0x1BU // Configured CAN data speed as Bits per seconds
+#define PCAN_IP_ADDRESS 0x1CU // Remote address of a LAN channel as string in IPv4 format
+#define PCAN_LAN_SERVICE_STATUS 0x1DU // Status of the Virtual PCAN-Gateway Service
+
+// PCAN parameter values
+//
+#define PCAN_PARAMETER_OFF 0x00U // The PCAN parameter is not set (inactive)
+#define PCAN_PARAMETER_ON 0x01U // The PCAN parameter is set (active)
+#define PCAN_FILTER_CLOSE 0x00U // The PCAN filter is closed. No messages will be received
+#define PCAN_FILTER_OPEN 0x01U // The PCAN filter is fully opened. All messages will be received
+#define PCAN_FILTER_CUSTOM 0x02U // The PCAN filter is custom configured. Only registered messages will be received
+#define PCAN_CHANNEL_UNAVAILABLE 0x00U // The PCAN-Channel handle is illegal, or its associated hardware is not available
+#define PCAN_CHANNEL_AVAILABLE 0x01U // The PCAN-Channel handle is available to be connected (Plug&Play Hardware: it means furthermore that the hardware is plugged-in)
+#define PCAN_CHANNEL_OCCUPIED 0x02U // The PCAN-Channel handle is valid, and is already being used
+#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
+
+#define LOG_FUNCTION_DEFAULT 0x00U // Logs system exceptions / errors
+#define LOG_FUNCTION_ENTRY 0x01U // Logs the entries to the PCAN-Basic API functions
+#define LOG_FUNCTION_PARAMETERS 0x02U // Logs the parameters passed to the PCAN-Basic API functions
+#define LOG_FUNCTION_LEAVE 0x04U // Logs the exits from the PCAN-Basic API functions
+#define LOG_FUNCTION_WRITE 0x08U // Logs the CAN messages passed to the CAN_Write function
+#define LOG_FUNCTION_READ 0x10U // Logs the CAN messages received within the CAN_Read function
+#define LOG_FUNCTION_ALL 0xFFFFU // Logs all possible information within the PCAN-Basic API functions
+
+#define TRACE_FILE_SINGLE 0x00U // A single file is written until it size reaches PAN_TRACE_SIZE
+#define TRACE_FILE_SEGMENTED 0x01U // Traced data is distributed in several files with size PAN_TRACE_SIZE
+#define TRACE_FILE_DATE 0x02U // Includes the date into the name of the trace file
+#define TRACE_FILE_TIME 0x04U // Includes the start time into the name of the trace file
+#define TRACE_FILE_OVERWRITE 0x80U // Causes the overwriting of available traces (same name)
+
+#define FEATURE_FD_CAPABLE 0x01U // Device supports flexible data-rate (CAN-FD)
+
+#define SERVICE_STATUS_STOPPED 0x01U // The service is not running
+#define SERVICE_STATUS_RUNNING 0x04U // The service is running
+
+// PCAN message types
+//
+#define PCAN_MESSAGE_STANDARD 0x00U // The PCAN message is a CAN Standard Frame (11-bit identifier)
+#define PCAN_MESSAGE_RTR 0x01U // The PCAN message is a CAN Remote-Transfer-Request Frame
+#define PCAN_MESSAGE_EXTENDED 0x02U // The PCAN message is a CAN Extended Frame (29-bit identifier)
+#define PCAN_MESSAGE_FD 0x04U // The PCAN message represents a FD frame in terms of CiA Specs
+#define PCAN_MESSAGE_BRS 0x08U // The PCAN message represents a FD bit rate switch (CAN data at a higher bit rate)
+#define PCAN_MESSAGE_ESI 0x10U // The PCAN message represents a FD error state indicator(CAN FD transmitter was error active)
+#define PCAN_MESSAGE_STATUS 0x80U // The PCAN message represents a PCAN status message
+
+// Frame Type / Initialization Mode
+//
+#define PCAN_MODE_STANDARD PCAN_MESSAGE_STANDARD
+#define PCAN_MODE_EXTENDED PCAN_MESSAGE_EXTENDED
+
+// Baud rate codes = BTR0/BTR1 register values for the CAN controller.
+// You can define your own Baud rate with the BTROBTR1 register.
+// Take a look at www.peak-system.com for our free software "BAUDTOOL"
+// to calculate the BTROBTR1 register for every bit rate and sample point.
+//
+#define PCAN_BAUD_1M 0x0014U // 1 MBit/s
+#define PCAN_BAUD_800K 0x0016U // 800 kBit/s
+#define PCAN_BAUD_500K 0x001CU // 500 kBit/s
+#define PCAN_BAUD_250K 0x011CU // 250 kBit/s
+#define PCAN_BAUD_125K 0x031CU // 125 kBit/s
+#define PCAN_BAUD_100K 0x432FU // 100 kBit/s
+#define PCAN_BAUD_95K 0xC34EU // 95,238 kBit/s
+#define PCAN_BAUD_83K 0x852BU // 83,333 kBit/s
+#define PCAN_BAUD_50K 0x472FU // 50 kBit/s
+#define PCAN_BAUD_47K 0x1414U // 47,619 kBit/s
+#define PCAN_BAUD_33K 0x8B2FU // 33,333 kBit/s
+#define PCAN_BAUD_20K 0x532FU // 20 kBit/s
+#define PCAN_BAUD_10K 0x672FU // 10 kBit/s
+#define PCAN_BAUD_5K 0x7F7FU // 5 kBit/s
+
+// Represents the configuration for a CAN bit rate
+// Note:
+// * Each parameter and its value must be separated with a '='.
+// * Each pair of parameter/value must be separated using ','.
+//
+// Example:
+// f_clock=80000000,nom_brp=0,nom_tseg1=13,nom_tseg2=0,nom_sjw=0,data_brp=0,data_tseg1=13,data_tseg2=0,data_sjw=0
+//
+#define PCAN_BR_CLOCK __T("f_clock")
+#define PCAN_BR_CLOCK_MHZ __T("f_clock_mhz")
+#define PCAN_BR_NOM_BRP __T("nom_brp")
+#define PCAN_BR_NOM_TSEG1 __T("nom_tseg1")
+#define PCAN_BR_NOM_TSEG2 __T("nom_tseg2")
+#define PCAN_BR_NOM_SJW __T("nom_sjw")
+#define PCAN_BR_NOM_SAMPLE __T("nom_sam")
+#define PCAN_BR_DATA_BRP __T("data_brp")
+#define PCAN_BR_DATA_TSEG1 __T("data_tseg1")
+#define PCAN_BR_DATA_TSEG2 __T("data_tseg2")
+#define PCAN_BR_DATA_SJW __T("data_sjw")
+#define PCAN_BR_DATA_SAMPLE __T("data_ssp_offset")
+
+// Type of PCAN (non plug&play) hardware
+//
+#define PCAN_TYPE_ISA 0x01U // PCAN-ISA 82C200
+#define PCAN_TYPE_ISA_SJA 0x09U // PCAN-ISA SJA1000
+#define PCAN_TYPE_ISA_PHYTEC 0x04U // PHYTEC ISA
+#define PCAN_TYPE_DNG 0x02U // PCAN-Dongle 82C200
+#define PCAN_TYPE_DNG_EPP 0x03U // PCAN-Dongle EPP 82C200
+#define PCAN_TYPE_DNG_SJA 0x05U // PCAN-Dongle SJA1000
+#define PCAN_TYPE_DNG_SJA_EPP 0x06U // PCAN-Dongle EPP SJA1000
+
+////////////////////////////////////////////////////////////
+// Type definitions
+////////////////////////////////////////////////////////////
+
+#define TPCANHandle WORD // Represents a PCAN hardware channel handle
+#define TPCANStatus DWORD // Represents a PCAN status/error code
+#define TPCANParameter BYTE // Represents a PCAN parameter to be read or set
+#define TPCANDevice BYTE // Represents a PCAN device
+#define TPCANMessageType BYTE // Represents the type of a PCAN message
+#define TPCANType BYTE // Represents the type of PCAN hardware to be initialized
+#define TPCANMode BYTE // Represents a PCAN filter mode
+#define TPCANBaudrate WORD // Represents a PCAN Baud rate register value
+#define TPCANBitrateFD LPSTR // Represents a PCAN-FD bit rate string
+#define TPCANTimestampFD UINT64 // Represents a timestamp of a received PCAN FD message
+
+////////////////////////////////////////////////////////////
+// Structure definitions
+////////////////////////////////////////////////////////////
+
+// Represents a PCAN message
+//
+typedef struct tagTPCANMsg
+{
+ DWORD ID; // 11/29-bit message identifier
+ TPCANMessageType MSGTYPE; // Type of the message
+ BYTE LEN; // Data Length Code of the message (0..8)
+ BYTE DATA[8]; // Data of the message (DATA[0]..DATA[7])
+} TPCANMsg;
+
+// Represents a timestamp of a received PCAN message
+// Total Microseconds = micros + 1000 * millis + 0x100000000 * 1000 * millis_overflow
+//
+typedef struct tagTPCANTimestamp
+{
+ DWORD millis; // Base-value: milliseconds: 0.. 2^32-1
+ WORD millis_overflow; // Roll-arounds of millis
+ WORD micros; // Microseconds: 0..999
+} TPCANTimestamp;
+
+// Represents a PCAN message from a FD capable hardware
+//
+typedef struct tagTPCANMsgFD
+{
+ DWORD ID; // 11/29-bit message identifier
+ TPCANMessageType MSGTYPE; // Type of the message
+ BYTE DLC; // Data Length Code of the message (0..15)
+ BYTE DATA[64]; // Data of the message (DATA[0]..DATA[63])
+} TPCANMsgFD;
+
+#ifdef __cplusplus
+extern "C" {
+#define _DEF_ARG =0
+#else
+#define _DEF_ARG
+#endif
+
+////////////////////////////////////////////////////////////
+// PCAN-Basic API function declarations
+////////////////////////////////////////////////////////////
+
+
+///
+/// Initializes a PCAN Channel
+///
+/// "The handle of a PCAN Channel"
+/// "The speed for the communication (BTR0BTR1 code)"
+/// "NON PLUG&PLAY: The type of hardware and operation mode"
+/// "NON PLUG&PLAY: The I/O address for the parallel port"
+/// "NON PLUG&PLAY: Interrupt number of the parallel port"
+/// "A TPCANStatus error code"
+TPCANStatus __stdcall CAN_Initialize(
+ TPCANHandle Channel,
+ TPCANBaudrate Btr0Btr1,
+ TPCANType HwType _DEF_ARG,
+ DWORD IOPort _DEF_ARG,
+ WORD Interrupt _DEF_ARG);
+
+
+///
+/// Initializes a FD capable PCAN Channel
+///
+/// "The handle of a FD capable PCAN Channel"
+/// "The speed for the communication (FD bit rate string)"
+/// See PCAN_BR_* values
+/// * Parameter and values must be separated by '='
+/// * Couples of Parameter/value must be separated by ','
+/// * Following Parameter must be filled out: f_clock, data_brp, data_sjw, data_tseg1, data_tseg2,
+/// nom_brp, nom_sjw, nom_tseg1, nom_tseg2.
+/// * Following Parameters are optional (not used yet): data_ssp_offset, nom_samp
+///
+/// f_clock_mhz=80,nom_brp=0,nom_tseg1=13,nom_tseg2=0,nom_sjw=0,data_brp=0,
+/// data_tseg1=13,data_tseg2=0,data_sjw=0
+/// "A TPCANStatus error code"
+TPCANStatus __stdcall CAN_InitializeFD(
+ TPCANHandle Channel,
+ TPCANBitrateFD BitrateFD);
+
+
+///
+/// Uninitializes one or all PCAN Channels initialized by CAN_Initialize
+///
+/// Giving the TPCANHandle value "PCAN_NONEBUS",
+/// uninitialize all initialized channels
+/// "The handle of a PCAN Channel"
+/// "A TPCANStatus error code"
+TPCANStatus __stdcall CAN_Uninitialize(
+ TPCANHandle Channel);
+
+
+///
+/// Resets the receive and transmit queues of the PCAN Channel
+///
+///
+/// A reset of the CAN controller is not performed.
+///
+/// "The handle of a PCAN Channel"
+/// "A TPCANStatus error code"
+TPCANStatus __stdcall CAN_Reset(
+ TPCANHandle Channel);
+
+
+///
+/// Gets the current status of a PCAN Channel
+///
+/// "The handle of a PCAN Channel"
+/// "A TPCANStatus error code"
+TPCANStatus __stdcall CAN_GetStatus(
+ TPCANHandle Channel);
+
+
+///
+/// Reads a CAN message from the receive queue of a PCAN Channel
+///
+/// "The handle of a PCAN Channel"
+/// "A TPCANMsg structure buffer to store the CAN message"
+/// "A TPCANTimestamp structure buffer to get
+/// the reception time of the message. If this value is not desired, this parameter
+/// should be passed as NULL"
+/// "A TPCANStatus error code"
+TPCANStatus __stdcall CAN_Read(
+ TPCANHandle Channel,
+ TPCANMsg* MessageBuffer,
+ TPCANTimestamp* TimestampBuffer);
+
+
+///
+/// Reads a CAN message from the receive queue of a FD capable PCAN Channel
+///
+/// "The handle of a FD capable PCAN Channel"
+/// "A TPCANMsgFD structure buffer to store the CAN message"
+/// "A TPCANTimestampFD buffer to get
+/// the reception time of the message. If this value is not desired, this parameter
+/// should be passed as NULL"
+/// "A TPCANStatus error code"
+TPCANStatus __stdcall CAN_ReadFD(
+ TPCANHandle Channel,
+ TPCANMsgFD* MessageBuffer,
+ TPCANTimestampFD *TimestampBuffer);
+
+
+///
+/// Transmits a CAN message
+///
+/// "The handle of a PCAN Channel"
+/// "A TPCANMsg buffer with the message to be sent"
+/// "A TPCANStatus error code"
+TPCANStatus __stdcall CAN_Write(
+ TPCANHandle Channel,
+ TPCANMsg* MessageBuffer);
+
+
+///
+/// Transmits a CAN message over a FD capable PCAN Channel
+///
+/// "The handle of a FD capable PCAN Channel"
+/// "A TPCANMsgFD buffer with the message to be sent"
+/// "A TPCANStatus error code"
+TPCANStatus __stdcall CAN_WriteFD(
+ TPCANHandle Channel,
+ TPCANMsgFD* MessageBuffer);
+
+
+///
+/// Configures the reception filter.
+///
+/// The message filter will be expanded with every call to
+/// this function. If it is desired to reset the filter, please use
+/// the CAN_SetValue function
+/// "The handle of a PCAN Channel"
+/// "The lowest CAN ID to be received"
+/// "The highest CAN ID to be received"
+/// "Message type, Standard (11-bit identifier) or
+/// Extended (29-bit identifier)"
+/// "A TPCANStatus error code"
+TPCANStatus __stdcall CAN_FilterMessages(
+ TPCANHandle Channel,
+ DWORD FromID,
+ DWORD ToID,
+ TPCANMode Mode);
+
+
+///
+/// Retrieves a PCAN Channel value
+///
+/// Parameters can be present or not according with the kind
+/// of Hardware (PCAN Channel) being used. If a parameter is not available,
+/// a PCAN_ERROR_ILLPARAMTYPE error will be returned
+/// "The handle of a PCAN Channel"
+/// "The TPCANParameter parameter to get"
+/// "Buffer for the parameter value"
+/// "Size in bytes of the buffer"
+/// "A TPCANStatus error code"
+TPCANStatus __stdcall CAN_GetValue(
+ TPCANHandle Channel,
+ TPCANParameter Parameter,
+ void* Buffer,
+ DWORD BufferLength);
+
+
+///
+/// Configures or sets a PCAN Channel value
+///
+/// Parameters can be present or not according with the kind
+/// of Hardware (PCAN Channel) being used. If a parameter is not available,
+/// a PCAN_ERROR_ILLPARAMTYPE error will be returned
+/// "The handle of a PCAN Channel"
+/// "The TPCANParameter parameter to set"
+/// "Buffer with the value to be set"
+/// "Size in bytes of the buffer"
+/// "A TPCANStatus error code"
+TPCANStatus __stdcall CAN_SetValue(
+ TPCANHandle Channel,
+ TPCANParameter Parameter,
+ void* Buffer,
+ DWORD BufferLength);
+
+
+///
+/// Returns a descriptive text of a given TPCANStatus error
+/// code, in any desired language
+///
+/// The current languages available for translation are:
+/// Neutral (0x00), German (0x07), English (0x09), Spanish (0x0A),
+/// Italian (0x10) and French (0x0C)
+/// "A TPCANStatus error code"
+/// "Indicates a 'Primary language ID'"
+/// "Buffer for a null terminated char array"
+/// "A TPCANStatus error code"
+TPCANStatus __stdcall CAN_GetErrorText(
+ TPCANStatus Error,
+ WORD Language,
+ LPSTR Buffer);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/Host/Source/LibOpenBLT/port/windows/canif/peak/pcanusb.c b/Host/Source/LibOpenBLT/port/windows/canif/peak/pcanusb.c
new file mode 100644
index 00000000..baba99ee
--- /dev/null
+++ b/Host/Source/LibOpenBLT/port/windows/canif/peak/pcanusb.c
@@ -0,0 +1,263 @@
+/************************************************************************************//**
+* \file pcanusb.c
+* \brief Peak PCAN-USB interface source file.
+* \ingroup PCanUsb
+* \internal
+*----------------------------------------------------------------------------------------
+* C O P Y R I G H T
+*----------------------------------------------------------------------------------------
+* Copyright (c) 2017 by Feaser http://www.feaser.com All rights reserved
+*
+*----------------------------------------------------------------------------------------
+* L I C E N S E
+*----------------------------------------------------------------------------------------
+* This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as published by the Free
+* Software Foundation, either version 3 of the License, or (at your option) any later
+* version.
+*
+* OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+* PURPOSE. See the GNU General Public License for more details.
+*
+* You have received a copy of the GNU General Public License along with OpenBLT. It
+* should be located in ".\Doc\license.html". If not, contact Feaser to obtain a copy.
+*
+* \endinternal
+****************************************************************************************/
+
+/****************************************************************************************
+* Include files
+****************************************************************************************/
+#include /* for assertions */
+#include /* for standard integer types */
+#include /* for NULL declaration */
+#include /* for boolean type */
+#include /* for standard library */
+#include /* for string library */
+#include "candriver.h" /* Generic CAN driver module */
+#include "pcanusb.h" /* Peak PCAN-USB interface */
+#include /* for Windows API */
+#include "PCANBasic.h" /* for PCAN-Basic API */
+
+
+/***************************************************************************************
+* Function prototypes
+****************************************************************************************/
+static void PCanUsbInit(tCanSettings const * settings);
+static void PCanUsbTerminate(void);
+static bool PCanUsbConnect(void);
+static void PCanUsbDisconnect(void);
+static bool PCanUsbTransmit(tCanMsg const * msg);
+static void PCanUsbRegisterEvents(tCanEvents const * events);
+
+
+/****************************************************************************************
+* Local constant declarations
+****************************************************************************************/
+/** \brief CAN interface structure filled with Peak PCAN-USB specifics. */
+static const tCanInterface pCanUsbInterface =
+{
+ PCanUsbInit,
+ PCanUsbTerminate,
+ PCanUsbConnect,
+ PCanUsbDisconnect,
+ PCanUsbTransmit,
+ PCanUsbRegisterEvents
+};
+
+
+/****************************************************************************************
+* Local data declarations
+****************************************************************************************/
+/** \brief The settings to use in this CAN interface. */
+static tCanSettings pCanUsbSettings;
+
+/** \brief List with callback functions that this driver should use. */
+static tCanEvents * pCanUsbEventsList;
+
+/** \brief Total number of event entries into the \ref pCanUsbEventsList list. */
+static uint32_t pCanUsbEventsEntries;
+
+
+/***********************************************************************************//**
+** \brief Obtains a pointer to the CAN interface structure, so that it can be linked
+** to the generic CAN driver module.
+** \return Pointer to CAN interface structure.
+**
+****************************************************************************************/
+tCanInterface const * PCanUsbGetInterface(void)
+{
+ return &pCanUsbInterface;
+} /*** end of PCanUsbGetInterface ***/
+
+
+/************************************************************************************//**
+** \brief Initializes the CAN interface.
+** \param settings Pointer to the CAN interface settings.
+**
+****************************************************************************************/
+static void PCanUsbInit(tCanSettings const * settings)
+{
+ char * canDeviceName;
+
+ /* Initialize locals. */
+ pCanUsbEventsList = NULL;
+ pCanUsbEventsEntries = 0;
+ /* Reset CAN interface settings. */
+ pCanUsbSettings.devicename = "";
+ pCanUsbSettings.channel = 0;
+ pCanUsbSettings.baudrate = CAN_BR500K;
+ pCanUsbSettings.code = 0x00000000u;
+ pCanUsbSettings.mask = 0x00000000u;
+
+ /* Check parameters. */
+ assert(settings != NULL);
+
+ /* Only continue with valid parameters. */
+ if (settings != NULL) /*lint !e774 */
+ {
+ /* Shallow copy the CAN interface settings for later usage. */
+ pCanUsbSettings = *settings;
+ /* The devicename is a pointer and it is not gauranteed that it stays valid so we need
+ * to deep copy this one. note the +1 for '\0' in malloc.
+ */
+ assert(settings->devicename != NULL);
+ if (settings->devicename != NULL) /*lint !e774 */
+ {
+ canDeviceName = malloc(strlen(settings->devicename) + 1);
+ assert(canDeviceName != NULL);
+ if (canDeviceName != NULL) /*lint !e774 */
+ {
+ strcpy(canDeviceName, settings->devicename);
+ pCanUsbSettings.devicename = canDeviceName;
+ }
+ }
+ }
+ /* ##Vg TODO Perform initialization of PCAN-Basic API. */
+} /*** end of PCanUsbInit ***/
+
+
+/************************************************************************************//**
+** \brief Terminates the CAN interface.
+**
+****************************************************************************************/
+static void PCanUsbTerminate(void)
+{
+ /* ##Vg TODO Perform termination of PCAN-Basic API. */
+ /* Release memory that was allocated for storing the device name. */
+ if (pCanUsbSettings.devicename != NULL)
+ {
+ free((char *)pCanUsbSettings.devicename);
+ }
+ /* Reset CAN interface settings. */
+ pCanUsbSettings.devicename = "";
+ pCanUsbSettings.channel = 0;
+ pCanUsbSettings.baudrate = CAN_BR500K;
+ pCanUsbSettings.code = 0x00000000u;
+ pCanUsbSettings.mask = 0x00000000u;
+ /* Release memory that was allocated for CAN events and reset the entry count. */
+ if ( (pCanUsbEventsList != NULL) && (pCanUsbEventsEntries != 0) )
+ {
+ free(pCanUsbEventsList);
+ pCanUsbEventsEntries = 0;
+ }
+} /*** end of PCanUsbTerminate ***/
+
+
+/************************************************************************************//**
+** \brief Connects the CAN interface.
+** \return True if connected, false otherwise.
+**
+****************************************************************************************/
+static bool PCanUsbConnect(void)
+{
+ bool result = false;
+
+ /* ##Vg TODO Check CAN interface settings. */
+
+ /* ##Vg TODO Connect to CAN interface, if settings are valid. */
+
+ /* Give the result back to the caller. */
+ return result;
+} /*** end of PCanUsbConnect ***/
+
+
+/************************************************************************************//**
+** \brief Disconnects the CAN interface.
+**
+****************************************************************************************/
+static void PCanUsbDisconnect(void)
+{
+ /* ##Vg TODO Disconnect from the CAN interface. */
+} /*** end of PCanUsbDisconnect ***/
+
+
+/************************************************************************************//**
+** \brief Submits a message for transmission on the CAN bus.
+** \param msg Pointer to CAN message structure.
+** \return True if successful, false otherwise.
+**
+****************************************************************************************/
+static bool PCanUsbTransmit(tCanMsg const * msg)
+{
+ bool result = false;
+
+ /* Check parameters. */
+ assert(msg != NULL);
+
+ /* Only continue with valid parameters. */
+ if (msg != NULL) /*lint !e774 */
+ {
+ /* ##Vg TODO Submit CAN message for transmission */
+ }
+
+ /* Give the result back to the caller. */
+ return result;
+} /*** end of PCanUsbTransmit ***/
+
+
+/************************************************************************************//**
+** \brief Registers the event callback functions that should be called by the CAN
+** interface.
+** \param events Pointer to structure with event callback function pointers.
+**
+****************************************************************************************/
+static void PCanUsbRegisterEvents(tCanEvents const * events)
+{
+ /* Check parameters. */
+ assert(events != NULL);
+
+ /* ##Vg TODO Test with multiple event entries to check that realloc approach works. */
+
+ /* Only continue with valid parameters. */
+ if (events != NULL) /*lint !e774 */
+ {
+ /* Increase length of the list to make space for one more event entry. Note that
+ * it is okay to call realloc with a NULL pointer. In this case it simply behaves
+ * as malloc.
+ */
+ pCanUsbEventsList = realloc(pCanUsbEventsList,
+ (sizeof(tCanEvents) * (pCanUsbEventsEntries + 1)));
+ /* Assert reallocation. */
+ assert(pCanUsbEventsList != NULL);
+ /* Only continue if reallocation was successful. */
+ if (pCanUsbEventsList != NULL)
+ {
+ /* Increment events entry count. */
+ pCanUsbEventsEntries++;
+ /* Store the events in the new entry. */
+ pCanUsbEventsList[pCanUsbEventsEntries - 1] = *events;
+ }
+ /* Reallocation failed. */
+ else
+ {
+ /* Reset events entry count. */
+ pCanUsbEventsEntries = 0;
+ }
+ }
+} /*** end of PCanUsbRegisterEvents ***/
+
+
+/*********************************** end of pcanusb.c **********************************/
+
diff --git a/Host/Source/LibOpenBLT/port/windows/canif/peak/pcanusb.h b/Host/Source/LibOpenBLT/port/windows/canif/peak/pcanusb.h
new file mode 100644
index 00000000..652c31d5
--- /dev/null
+++ b/Host/Source/LibOpenBLT/port/windows/canif/peak/pcanusb.h
@@ -0,0 +1,50 @@
+/************************************************************************************//**
+* \file pcanusb.h
+* \brief Peak PCAN-USB interface header file.
+* \ingroup PCanUsb
+* \internal
+*----------------------------------------------------------------------------------------
+* C O P Y R I G H T
+*----------------------------------------------------------------------------------------
+* Copyright (c) 2017 by Feaser http://www.feaser.com All rights reserved
+*
+*----------------------------------------------------------------------------------------
+* L I C E N S E
+*----------------------------------------------------------------------------------------
+* This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as published by the Free
+* Software Foundation, either version 3 of the License, or (at your option) any later
+* version.
+*
+* OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+* PURPOSE. See the GNU General Public License for more details.
+*
+* You have received a copy of the GNU General Public License along with OpenBLT. It
+* should be located in ".\Doc\license.html". If not, contact Feaser to obtain a copy.
+*
+* \endinternal
+****************************************************************************************/
+/************************************************************************************//**
+* \defgroup PCanUsb Peak PCAN-USB interface
+* \brief This module implements the CAN interface for the Peak PCAN-USB.
+* \ingroup CanDriver
+****************************************************************************************/
+#ifndef PCANUSB_H
+#define PCANUSB_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/***************************************************************************************
+* Function prototypes
+****************************************************************************************/
+tCanInterface const * PCanUsbGetInterface(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PCANUSB_H */
+/*********************************** end of pcanusb.h **********************************/
diff --git a/Host/Source/LibOpenBLT/port/windows/serialport.c b/Host/Source/LibOpenBLT/port/windows/serialport.c
index 3280bde7..a1efe417 100644
--- a/Host/Source/LibOpenBLT/port/windows/serialport.c
+++ b/Host/Source/LibOpenBLT/port/windows/serialport.c
@@ -1,7 +1,7 @@
/************************************************************************************//**
* \file port/windows/serialport.c
* \brief Serial port source file.
-* \ingroup Session
+* \ingroup SerialPort
* \internal
*----------------------------------------------------------------------------------------
* C O P Y R I G H T
diff --git a/Host/Source/LibOpenBLT/serialport.h b/Host/Source/LibOpenBLT/serialport.h
index ea3156f2..496778ca 100644
--- a/Host/Source/LibOpenBLT/serialport.h
+++ b/Host/Source/LibOpenBLT/serialport.h
@@ -1,7 +1,7 @@
/************************************************************************************//**
* \file serialport.h
* \brief Serial port header file.
-* \ingroup Session
+* \ingroup SerialPort
* \internal
*----------------------------------------------------------------------------------------
* C O P Y R I G H T
@@ -25,6 +25,11 @@
*
* \endinternal
****************************************************************************************/
+/************************************************************************************//**
+* \defgroup SerialPort Serial port driver
+* \brief This module implements a generic serial port driver.
+* \ingroup Session
+****************************************************************************************/
#ifndef SERIALPORT_H
#define SERIALPORT_H
diff --git a/Host/Source/LibOpenBLT/xcptpuart.c b/Host/Source/LibOpenBLT/xcptpuart.c
index e4ea4d6a..2806a8cb 100644
--- a/Host/Source/LibOpenBLT/xcptpuart.c
+++ b/Host/Source/LibOpenBLT/xcptpuart.c
@@ -1,7 +1,7 @@
/************************************************************************************//**
* \file xcptpuart.c
* \brief XCP UART transport layer source file.
-* \ingroup XcpLoader
+* \ingroup XcpTpUart
* \internal
*----------------------------------------------------------------------------------------
* C O P Y R I G H T
diff --git a/Host/Source/LibOpenBLT/xcptpuart.h b/Host/Source/LibOpenBLT/xcptpuart.h
index 5f59907b..aad202e5 100644
--- a/Host/Source/LibOpenBLT/xcptpuart.h
+++ b/Host/Source/LibOpenBLT/xcptpuart.h
@@ -1,7 +1,7 @@
/************************************************************************************//**
* \file xcptpuart.h
* \brief XCP UART transport layer header file.
-* \ingroup XcpLoader
+* \ingroup XcpTpUart
* \internal
*----------------------------------------------------------------------------------------
* C O P Y R I G H T
@@ -25,6 +25,11 @@
*
* \endinternal
****************************************************************************************/
+/************************************************************************************//**
+* \defgroup XcpTpUart XCP UART transport layer
+* \brief This module implements the XCP transport layer for UART.
+* \ingroup XcpLoader
+****************************************************************************************/
#ifndef XCPTPUART_H
#define XCPTPUART_H