amiro-blt / Target / Source / xcp.h @ a3508d90
History | View | Annotate | Download (9.425 KB)
1 | 69661903 | Thomas Schöpping | /************************************************************************************//** |
---|---|---|---|
2 | * \file Source\xcp.h
|
||
3 | * \brief XCP 1.0 protocol core header file.
|
||
4 | * \ingroup Core
|
||
5 | * \internal
|
||
6 | *----------------------------------------------------------------------------------------
|
||
7 | * C O P Y R I G H T
|
||
8 | *----------------------------------------------------------------------------------------
|
||
9 | * Copyright (c) 2011 by Feaser http://www.feaser.com All rights reserved
|
||
10 | *
|
||
11 | *----------------------------------------------------------------------------------------
|
||
12 | * L I C E N S E
|
||
13 | *----------------------------------------------------------------------------------------
|
||
14 | * This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
|
||
15 | * modify it under the terms of the GNU General Public License as published by the Free
|
||
16 | * Software Foundation, either version 3 of the License, or (at your option) any later
|
||
17 | * version.
|
||
18 | *
|
||
19 | * OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||
20 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
21 | * PURPOSE. See the GNU General Public License for more details.
|
||
22 | *
|
||
23 | * You should have received a copy of the GNU General Public License along with OpenBLT.
|
||
24 | * If not, see <http://www.gnu.org/licenses/>.
|
||
25 | *
|
||
26 | * A special exception to the GPL is included to allow you to distribute a combined work
|
||
27 | * that includes OpenBLT without being obliged to provide the source code for any
|
||
28 | * proprietary components. The exception text is included at the bottom of the license
|
||
29 | * file <license.html>.
|
||
30 | *
|
||
31 | * \endinternal
|
||
32 | ****************************************************************************************/
|
||
33 | #ifndef XCP_H
|
||
34 | #define XCP_H
|
||
35 | |||
36 | /****************************************************************************************
|
||
37 | * Configuration
|
||
38 | ****************************************************************************************/
|
||
39 | /** \brief Maximum length of the transport layer's command transmit object packet. */
|
||
40 | #if defined(BOOT_XCP_CUSTOM_RX_MAX_DATA)
|
||
41 | #define XCP_CTO_PACKET_LEN (BOOT_XCP_CUSTOM_RX_MAX_DATA)
|
||
42 | #else
|
||
43 | #define XCP_CTO_PACKET_LEN (ComGetActiveInterfaceMaxRxLen())
|
||
44 | #endif
|
||
45 | |||
46 | /** \brief Maximum length of the transport layer's data transmit object packet. */
|
||
47 | #if defined(BOOT_XCP_CUSTOM_TX_MAX_DATA)
|
||
48 | #define XCP_DTO_PACKET_LEN (BOOT_XCP_CUSTOM_TX_MAX_DATA)
|
||
49 | #else
|
||
50 | #define XCP_DTO_PACKET_LEN (ComGetActiveInterfaceMaxTxLen())
|
||
51 | #endif
|
||
52 | |||
53 | /** \brief Name in string format that is used to identify the ECU to the XCP master
|
||
54 | * using the GET_ID command.
|
||
55 | */
|
||
56 | #define XCP_STATION_ID_STRING "OpenBLT" |
||
57 | |||
58 | #if (BOOT_CPU_BYTE_ORDER_MOTOROLA > 0) |
||
59 | /** \brief XCP byte ordering according to the Motorola (little-endian). */
|
||
60 | #define XCP_MOTOROLA_FORMAT (0x01) |
||
61 | #else
|
||
62 | /** \brief XCP byte ordering according to the Intel (big-endian). */
|
||
63 | #define XCP_MOTOROLA_FORMAT (0x00) |
||
64 | #endif
|
||
65 | |||
66 | /** \brief Enable (=1) or disable (=0) support for the calibration resource. This is
|
||
67 | * required when data is written to RAM during the XCP session.
|
||
68 | */
|
||
69 | #define XCP_RES_CALIBRATION_EN (0) |
||
70 | |||
71 | /** \brief Enable (=1) or disable (=0) support for the paging resource. This is
|
||
72 | * required when switching between application specific calibration pages
|
||
73 | * should be supported. In this case the application specific external
|
||
74 | * functions AppCalSetPage and AppCalGetPage must be provided.
|
||
75 | */
|
||
76 | #define XCP_RES_PAGING_EN (0) |
||
77 | |||
78 | /** \brief Enable (=1) or disable (=0) support for the programming resource. This is
|
||
79 | * required when non-volatile memory will be erased or programmed during an
|
||
80 | * XCP session. In this case the following external hardware specific
|
||
81 | * functions must be provided: HwNvmWriteMemory, HwNvmEraseMemory and
|
||
82 | * HwCpuReset.
|
||
83 | */
|
||
84 | #define XCP_RES_PROGRAMMING_EN (1) |
||
85 | |||
86 | /** \brief Enable (=1) or disable (=0) support for the data acquisition resource. This
|
||
87 | * note that this feature is currently not supported by the XCP driver.
|
||
88 | */
|
||
89 | #define XCP_RES_DATA_ACQUISITION_EN (0) |
||
90 | |||
91 | /** \brief Enable (=1) or disable (=0) support for the data stimulation resource. This
|
||
92 | * note that this feature is currently not supported by the XCP driver.
|
||
93 | */
|
||
94 | #define XCP_RES_DATA_STIMULATION_EN (0) |
||
95 | |||
96 | /** \brief Enable (=1) or disable (=0) support for the seed/key protection feature.
|
||
97 | * If enabled, the XCP master has to perform a GET_SEED/UNLOCK sequence to
|
||
98 | * obtain access to a resource. The protection algorithm is implemented in
|
||
99 | * XcpGetSeed and XcpVerifyKey.
|
||
100 | */
|
||
101 | #if (BOOT_XCP_SEED_KEY_ENABLE > 0) |
||
102 | #define XCP_SEED_KEY_PROTECTION_EN (1) |
||
103 | #else
|
||
104 | #define XCP_SEED_KEY_PROTECTION_EN (0) |
||
105 | #endif
|
||
106 | |||
107 | |||
108 | /****************************************************************************************
|
||
109 | * Defines
|
||
110 | ****************************************************************************************/
|
||
111 | /* xcp supported resources */
|
||
112 | /** \brief ProGraMming resource. */
|
||
113 | #define XCP_RES_PGM (0x10) |
||
114 | /** \brief data STIMulation resource. */
|
||
115 | #define XCP_RES_STIM (0x08) |
||
116 | /** \brief Data AcQuisition resource. */
|
||
117 | #define XCP_RES_DAQ (0x04) |
||
118 | /** \brief CALibration and PAGing resource. */
|
||
119 | #define XCP_RES_CALPAG (0x01) |
||
120 | |||
121 | /* xcp checksum types */
|
||
122 | /** \brief Add byte into byte checksum. */
|
||
123 | #define XCP_CS_ADD11 (0x01) |
||
124 | /** \brief Add byte into word checksum. */
|
||
125 | #define XCP_CS_ADD12 (0x02) |
||
126 | /** \brief Add byte into dword checksum. */
|
||
127 | #define XCP_CS_ADD14 (0x03) |
||
128 | /** \brief Add word into word checksum. */
|
||
129 | #define XCP_CS_ADD22 (0x04) |
||
130 | /** \brief Add word into dword checksum. */
|
||
131 | #define XCP_CS_ADD24 (0x05) |
||
132 | /** \brief Add dword into dword checksum. */
|
||
133 | #define XCP_CS_ADD44 (0x06) |
||
134 | /** \brief Use 16-bit CRC algorithm. */
|
||
135 | #define XCP_CS_CRC16 (0x07) |
||
136 | /** \brief Use 16-bit CRC CITT algorithm. */
|
||
137 | #define XCP_CS_CRC16CITT (0x08) |
||
138 | /** \brief Use 32-bit CRC algorithm. */
|
||
139 | #define XCP_CS_CRC32 (0x09) |
||
140 | /** \brief Use user defined algorithm. */
|
||
141 | #define XCP_CS_USER (0xff) |
||
142 | |||
143 | |||
144 | /****************************************************************************************
|
||
145 | * Function prototypes
|
||
146 | ****************************************************************************************/
|
||
147 | void XcpInit(void); |
||
148 | blt_bool XcpIsConnected(void);
|
||
149 | #if (BOOTLOADER_OF_MAIN_DEVICE > 0) |
||
150 | blt_bool XcpWasConnectedToMain(void);
|
||
151 | #endif
|
||
152 | void XcpPacketTransmitted(void); |
||
153 | #if (BOOT_GATE_ENABLE > 0) |
||
154 | void XcpPacketReceived(blt_int8u *data, blt_int16s dataLength, blt_bool fromGate);
|
||
155 | #else
|
||
156 | void XcpPacketReceived(blt_int8u *data, blt_int16s dataLength);
|
||
157 | #endif /* BOOT_GATE_ENABLE > 0 */ |
||
158 | #if (BOOT_GATE_ENABLE > 0) |
||
159 | void XcpPacketReceivedForwarding(blt_int8u *data, blt_int16s dataLength);
|
||
160 | void XcpGatewayPacketReceived(blt_int8u *data, blt_int16s dataLength);
|
||
161 | #endif
|
||
162 | |||
163 | |||
164 | /****************************************************************************************
|
||
165 | * Configuration check
|
||
166 | ****************************************************************************************/
|
||
167 | #if (XCP_RES_DATA_ACQUISITION_EN == 1) |
||
168 | #error "XCP.H, Current XCP driver does not support Data AcQuisition resource." |
||
169 | #endif
|
||
170 | |||
171 | |||
172 | #if (XCP_RES_DATA_STIMULATION_EN == 1) |
||
173 | #error "XCP.H, Current XCP driver does not support Data StIMulation resource." |
||
174 | #endif
|
||
175 | |||
176 | |||
177 | #ifndef XCP_CTO_PACKET_LEN
|
||
178 | #error "XCP.H, Configuration macro XCP_CTO_PACKET_LEN is missing." |
||
179 | #endif
|
||
180 | |||
181 | |||
182 | #ifndef XCP_DTO_PACKET_LEN
|
||
183 | #error "XCP.H, Configuration macro XCP_DTO_PACKET_LEN is missing." |
||
184 | #endif
|
||
185 | |||
186 | |||
187 | #ifndef XCP_STATION_ID_STRING
|
||
188 | #error "XCP.H, Configuration macro XCP_STATION_ID_STRING is missing." |
||
189 | #endif
|
||
190 | |||
191 | |||
192 | #ifndef XCP_RES_CALIBRATION_EN
|
||
193 | #error "XCP.H, Configuration macro XCP_RES_CALIBRATION_EN is missing." |
||
194 | #endif
|
||
195 | |||
196 | #if (XCP_RES_CALIBRATION_EN < 0) || (XCP_RES_CALIBRATION_EN > 1) |
||
197 | #error "XCP.H, XCP_RES_CALIBRATION_EN must be 0 or 1." |
||
198 | #endif
|
||
199 | |||
200 | |||
201 | #ifndef XCP_RES_PAGING_EN
|
||
202 | #error "XCP.H, Configuration macro XCP_RES_PAGING_EN is missing." |
||
203 | #endif
|
||
204 | |||
205 | #if (XCP_RES_PAGING_EN < 0) || (XCP_RES_PAGING_EN > 1) |
||
206 | #error "XCP.H, XCP_RES_PAGING_EN must be 0 or 1." |
||
207 | #endif
|
||
208 | |||
209 | |||
210 | #ifndef XCP_RES_PROGRAMMING_EN
|
||
211 | #error "XCP.H, Configuration macro XCP_RES_PAGING_EN is missing." |
||
212 | #endif
|
||
213 | |||
214 | #if (XCP_RES_PROGRAMMING_EN < 0) || (XCP_RES_PROGRAMMING_EN > 1) |
||
215 | #error "XCP.H, XCP_RES_PROGRAMMING_EN must be 0 or 1." |
||
216 | #endif
|
||
217 | |||
218 | |||
219 | #ifndef XCP_RES_DATA_ACQUISITION_EN
|
||
220 | #error "XCP.H, Configuration macro XCP_RES_DATA_ACQUISITION_EN is missing." |
||
221 | #endif
|
||
222 | |||
223 | #if (XCP_RES_DATA_ACQUISITION_EN < 0) || (XCP_RES_DATA_ACQUISITION_EN > 1) |
||
224 | #error "XCP.H, XCP_RES_DATA_ACQUISITION_EN must be 0 or 1." |
||
225 | #endif
|
||
226 | |||
227 | |||
228 | #ifndef XCP_RES_DATA_STIMULATION_EN
|
||
229 | #error "XCP.H, Configuration macro XCP_RES_DATA_STIMULATION_EN is missing." |
||
230 | #endif
|
||
231 | |||
232 | #if (XCP_RES_DATA_STIMULATION_EN < 0) || (XCP_RES_DATA_STIMULATION_EN > 1) |
||
233 | #error "XCP.H, XCP_RES_DATA_STIMULATION_EN must be 0 or 1." |
||
234 | #endif
|
||
235 | |||
236 | |||
237 | #ifndef XCP_SEED_KEY_PROTECTION_EN
|
||
238 | #error "XCP.H, Configuration macro XCP_SEED_KEY_PROTECTION_EN is missing." |
||
239 | #endif
|
||
240 | |||
241 | #if (XCP_SEED_KEY_PROTECTION_EN < 0) || (XCP_SEED_KEY_PROTECTION_EN > 1) |
||
242 | #error "XCP.H, XCP_SEED_KEY_PROTECTION_EN must be 0 or 1." |
||
243 | #endif
|
||
244 | |||
245 | |||
246 | #endif /* XCP_H */ |
||
247 | /******************************** end of xcp.h *~~~~~***********************************/
|