forked from vectorgrp/XCPlite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xcp_cfg.h
137 lines (94 loc) · 3.99 KB
/
xcp_cfg.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*----------------------------------------------------------------------------
| File:
| XCP_CFG.H
|
| Description:
| Konfiguration file for XCP lite protocol and transport layer
| Linux (Raspberry Pi) Version
----------------------------------------------------------------------------*/
#ifndef __XCP_CFG_H_
#define __XCP_CFG_H_
// General includes
#define _POSIX_C_SOURCE 200809L
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/time.h>
#include <time.h>
#include <pthread.h> // link with -lpthread
#include <assert.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <linux/ip.h>
#include <linux/udp.h>
#include <arpa/inet.h>
/*----------------------------------------------------------------------------*/
/* Platform specific definitions */
/* 8-Bit */
typedef unsigned char vuint8;
typedef signed char vsint8;
/* 16-Bit */
typedef unsigned short vuint16;
typedef signed short vsint16;
/* 32-Bit */
typedef unsigned long vuint32;
typedef signed long vsint32;
/* Byte order */
//#define XCP_CPUTYPE_BIGENDIAN /* Motorola */
#define XCP_CPUTYPE_LITTLEENDIAN /* Intel */
/* Memory qualifiers */
#define MEMORY_CONST const
#define MEMORY_ROM const
/*----------------------------------------------------------------------------*/
/* XCP Driver Callbacks as macros */
extern int udpServerSendCrmPacket(const unsigned char* data, unsigned int n);
extern unsigned char* udpServerGetPacketBuffer(void** par, unsigned int size);
extern void udpServerCommitPacketBuffer(void* par);
// Convert a XCP (BYTE addrExt, DWORD addr from A2L) address to a C pointer to unsigned byte
// extern BYTEPTR ApplXcpGetPointer(vuint8 addr_ext, vuint32 addr)
#define ApplXcpGetPointer(e,a) ((BYTEPTR)((a)))
// Get and commit buffer space for a DTO message
#define ApplXcpGetDtoBuffer udpServerGetPacketBuffer
#define ApplXcpCommitDtoBuffer udpServerCommitPacketBuffer
// Send a CRM message
#define ApplXcpSendCrm udpServerSendCrmPacket
/*----------------------------------------------------------------------------*/
/* Test instrumentation */
/* Turn on screen logging, assertions and parameter checks */
#define XCP_ENABLE_TESTMODE
#ifdef XCP_ENABLE_TESTMODE
#define ApplXcpPrint printf
#define XCP_ENABLE_PARAMETER_CHECK
#endif
/*----------------------------------------------------------------------------*/
/* XCP protocol and transport layer parameters */
/* Transport layer */
#define XCP_UDP_MTU (1400) // IPv4 1500 ETH - 28 IP - 8 UDP ???
#define XCP_TRANSPORT_LAYER_VERSION 0x0100
/* XCP slave device identification (optional) */
#define kXcpStationIdLength 5 /* Slave device identification length */
#define kXcpStationIdString "xcpPi" /* Slave device identification for auto detection of A2L file */
extern vuint8 MEMORY_ROM gXcpStationId[];
/* XCP protocol message sizes */
#define kXcpMaxCTO 250 /* Maximum CTO and CRM Message Lenght */
#define kXcpMaxDTO (XCP_UDP_MTU-4) /* Maximum DTO Message Lenght UDP_MTU - Transport Layer Header */
/* Transmit queue (DAQ) */
#define DTO_SEND_QUEUE /* Enable DTO packet queue, decouples xcpEvent from sendto, results in almost deterministic runtime of xcpEvent */
#define DTO_QUEUE_SIZE 32 /* Transmit queue size in DAQ UDP packets, should at least be able to hold all data produced by the largest event */
//#define DTO_SEND_RAW /* Activate UDP on RAW socket for DAQ transmission */
/* DAQ table size */
#define kXcpDaqMemSize 60000u // Memory space reserved for DAQ tables (XCP needs 5 bytes (addr+len) per memory region (odt entry)
/* DAQ timestamp settings */
#define kApplXcpDaqTimestampTicksPerMs 1000
extern vuint32 ApplXcpTimer(void);
#define kXcpDaqTimestampUnit DAQ_TIMESTAMP_UNIT_1US
#define kXcpDaqTimestampTicksPerUnit 1
#define ApplXcpGetTimestamp() ApplXcpTimer()
/*----------------------------------------------------------------------------*/
/* XCP protocol features */
#define XCP_ENABLE_CALIBRATION
#endif