Commit b8519540 authored by 李延凯's avatar 李延凯

feat: 修改Git忽略文件列表, 添加诊断基础文件

parent 96ee6f9d
/Firmware/Project/Cmsemicon/BAT32A239/MDK_ARM/Objects /Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/Objects
/Firmware/Project/Cmsemicon/BAT32A239/MDK_ARM/Listings /Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/Listings
/Firmware/Project/Cmsemicon/BAT32A239/MDK_ARM/JLinkLog.txt /Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/JLinkLog.txt
/Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/*.tyw05
/Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/*.uvoptx
/Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/*.VMW10
/.vscode /.vscode
*.zip *.zip
*.7z *.7z
/Firmware/Project/Cmsemicon/BAT32A239/MDK_ARM/*.tyw05
/Firmware/Project/Cmsemicon/BAT32A239/MDK_ARM/*.tyw05
/Firmware/Project/Cmsemicon/BAT32A239/MDK_ARM/*.tyw05
Firmware/Project/Cmsemicon/BAT32A239/MDK_ARM/RunTong.uvoptx
/Firmware/Project/Cmsemicon/BAT32A239/MDK_ARM/*.uvoptx
/Firmware/Project/Cmsemicon/BAT32A239/MDK_ARM/*.VMW10
Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/Listings/HaoJin.map
/Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/Objects
Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/HaoJin750TFT.uvguix.tyw05
Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/HaoJin750TFT.uvguix.tyw05
Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/HaoJin750TFT.uvoptx
Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/Listings/HaoJin750TFT.map
/Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/HaoJin750TFT.uvguix.tyw05
/Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/Listings/HaoJin750TFT.map
/Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/*.uvoptx
/Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/JLinkLog.txt
/Firmware/Project/Cmsemicon/BAT32A279/MDK_ARM/JLinkLog.txt
ARM Macro Assembler Page 1
1 00000000 ;/******************************************************
********************//**
2 00000000 ; * @file startup_BAT32A239.s
3 00000000 ; * @brief CMSIS Cortex-M ARMv6-M based Core Device S
tartup File for
4 00000000 ; * Device BAT32A239
5 00000000 ; * @version V1.00
6 00000000 ; * @date 2019/04/24
7 00000000 ; ******************************************************
************************/
8 00000000 ;/*
9 00000000 ; * Copyright (c) 2009-2016 ARM Limited. All rights rese
rved.
10 00000000 ; *
11 00000000 ; * SPDX-License-Identifier: Apache-2.0
12 00000000 ; *
13 00000000 ; * Licensed under the Apache License, Version 2.0 (the
License); you may
14 00000000 ; * not use this file except in compliance with the Lice
nse.
15 00000000 ; * You may obtain a copy of the License at
16 00000000 ; *
17 00000000 ; * www.apache.org/licenses/LICENSE-2.0
18 00000000 ; *
19 00000000 ; * Unless required by applicable law or agreed to in wr
iting, software
20 00000000 ; * distributed under the License is distributed on an A
S IS BASIS, WITHOUT
21 00000000 ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied.
22 00000000 ; * See the License for the specific language governing
permissions and
23 00000000 ; * limitations under the License.
24 00000000 ; */
25 00000000 ;/*
26 00000000
27 00000000 ;//-------- <<< Use Configuration Wizard in Context Menu
>>> ------------------
28 00000000 ;*/
29 00000000
30 00000000
31 00000000 ; <h> Stack Configuration
32 00000000 ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
33 00000000 ; </h>
34 00000000
35 00000000 00000600
Stack_Size
EQU 0x00000600
36 00000000
37 00000000 AREA STACK, NOINIT, READWRITE, ALIGN
=3
38 00000000 Stack_Mem
SPACE Stack_Size
39 00000600 __initial_sp
40 00000600
41 00000600
42 00000600 ; <h> Heap Configuration
43 00000600 ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
44 00000600 ; </h>
ARM Macro Assembler Page 2
45 00000600
46 00000600 00000100
Heap_Size
EQU 0x00000100
47 00000600
48 00000600 AREA HEAP, NOINIT, READWRITE, ALIGN=
3
49 00000000 __heap_base
50 00000000 Heap_Mem
SPACE Heap_Size
51 00000100 __heap_limit
52 00000100
53 00000100
54 00000100 PRESERVE8
55 00000100 THUMB
56 00000100
57 00000100
58 00000100 ; Vector Table Mapped to Address 0 at Reset
59 00000100
60 00000100 AREA RESET, DATA, READONLY
61 00000000 EXPORT __Vectors
62 00000000 EXPORT __Vectors_End
63 00000000 EXPORT __Vectors_Size
64 00000000
65 00000000 00000000
__Vectors
DCD __initial_sp ; Top of Stack
66 00000004 00000000 DCD Reset_Handler ; Reset Handler
67 00000008 00000000 DCD NMI_Handler ; NMI Handler
68 0000000C 00000000 DCD HardFault_Handler ; Hard Fault
Handler
69 00000010 00000000 DCD 0 ; Reserved
70 00000014 00000000 DCD 0 ; Reserved
71 00000018 00000000 DCD 0 ; Reserved
72 0000001C 00000000 DCD 0 ; Reserved
73 00000020 00000000 DCD 0 ; Reserved
74 00000024 00000000 DCD 0 ; Reserved
75 00000028 00000000 DCD 0 ; Reserved
76 0000002C 00000000 DCD SVC_Handler ; SVCall Handler
77 00000030 00000000 DCD 0 ; Reserved
78 00000034 00000000 DCD 0 ; Reserved
79 00000038 00000000 DCD PendSV_Handler ; PendSV Handler
80 0000003C 00000000 DCD SysTick_Handler
; SysTick Handler
81 00000040
82 00000040 ; External Interrupts
83 00000040 ; ToDo: Add here the vectors for the device specific ex
ternal interrupts handler
84 00000040 00000000 DCD IRQ00_Handler ; LVI IRQ
85 00000044 00000000 DCD IRQ01_Handler ; INTP0 or INTP6
IRQ
86 00000048 00000000 DCD IRQ02_Handler ; INTP1 or INTP7
IRQ
87 0000004C 00000000 DCD IRQ03_Handler ; INTP2 or INTP8
IRQ
88 00000050 00000000 DCD IRQ04_Handler ; INTP3 or INTP9
IRQ
89 00000054 00000000 DCD IRQ05_Handler ; INTP4 or INTP1
ARM Macro Assembler Page 3
0 IRQ
90 00000058 00000000 DCD IRQ06_Handler ; INTP5 or INTP1
1 IRQ
91 0000005C 00000000 DCD IRQ07_Handler ; ST2/SPI20/IIC2
0 IRQ
92 00000060 00000000 DCD IRQ08_Handler ; SR2/SPI21/IIC2
1 IRQ
93 00000064 00000000 DCD IRQ09_Handler ; SRE2 IRQ
94 00000068 00000000 DCD IRQ10_Handler ; ST0/SPI00/IIC0
0 IRQ
95 0000006C 00000000 DCD IRQ11_Handler ; SR0/SPI01/IIC0
1 IRQ
96 00000070 00000000 DCD IRQ12_Handler ; SRE0 or TM01H
IRQ
97 00000074 00000000 DCD IRQ13_Handler ; ST1/SPI10/IIC1
0 IRQ
98 00000078 00000000 DCD IRQ14_Handler ; SR1/SPI11/IIC1
1 IRQ
99 0000007C 00000000 DCD IRQ15_Handler ; SRE1 or TM03H
IRQ
100 00000080 00000000 DCD IRQ16_Handler
; IICA or DIV IRQ
101 00000084 00000000 DCD IRQ17_Handler ; TM00 IRQ
102 00000088 00000000 DCD IRQ18_Handler ; TM01 IRQ
103 0000008C 00000000 DCD IRQ19_Handler ; TM02 IRQ
104 00000090 00000000 DCD IRQ20_Handler ; TM03 IRQ
105 00000094 00000000 DCD IRQ21_Handler ; ADC IRQ
106 00000098 00000000 DCD IRQ22_Handler ; RTC or IT IRQ
107 0000009C 00000000 DCD IRQ23_Handler ; KEY IRQ
108 000000A0 00000000 DCD IRQ24_Handler ; CMP0 IRQ
109 000000A4 00000000 DCD IRQ25_Handler ; CMP1 IRQ
110 000000A8 00000000 DCD IRQ26_Handler ; TMA IRQ
111 000000AC 00000000 DCD IRQ27_Handler ; TMM0 IRQ
112 000000B0 00000000 DCD IRQ28_Handler ; TMM1 IRQ
113 000000B4 00000000 DCD IRQ29_Handler ; TMB IRQ
114 000000B8 00000000 DCD IRQ30_Handler ; TMC IRQ
115 000000BC 00000000 DCD IRQ31_Handler ; FMC IRQ
116 000000C0 __Vectors_End
117 000000C0
118 000000C0 000000C0
__Vectors_Size
EQU __Vectors_End - __Vectors
119 000000C0
120 000000C0 AREA |.text|, CODE, READONLY
121 00000000
122 00000000
123 00000000 ; Reset Handler
124 00000000
125 00000000 Reset_Handler
PROC
126 00000000 EXPORT Reset_Handler [WEAK
]
127 00000000 IMPORT SystemInit
128 00000000 IMPORT __main
129 00000000 4816 LDR R0, =SystemInit
130 00000002 4780 BLX R0
131 00000004 4816 LDR R0, =__main
132 00000006 4700 BX R0
133 00000008 ENDP
ARM Macro Assembler Page 4
134 00000008
135 00000008
136 00000008 ; Dummy Exception Handlers (infinite loops which can be
modified)
137 00000008
139 00000008 NMI_Handler
PROC
140 00000008 EXPORT NMI_Handler [WEAK
]
141 00000008 E7FE B .
142 0000000A ENDP
144 0000000A HardFault_Handler
PROC
145 0000000A EXPORT HardFault_Handler [WEAK
]
146 0000000A E7FE B .
147 0000000C ENDP
149 0000000C MemManage_Handler
PROC
150 0000000C EXPORT MemManage_Handler [WEAK
]
151 0000000C E7FE B .
152 0000000E ENDP
154 0000000E BusFault_Handler
PROC
155 0000000E EXPORT BusFault_Handler [WEAK
]
156 0000000E E7FE B .
157 00000010 ENDP
159 00000010 UsageFault_Handler
PROC
160 00000010 EXPORT UsageFault_Handler [WEAK
]
161 00000010 E7FE B .
162 00000012 ENDP
164 00000012 SVC_Handler
PROC
165 00000012 EXPORT SVC_Handler [WEAK
]
166 00000012 E7FE B .
167 00000014 ENDP
169 00000014 DebugMon_Handler
PROC
170 00000014 EXPORT DebugMon_Handler [WEAK
]
171 00000014 E7FE B .
172 00000016 ENDP
174 00000016 PendSV_Handler
PROC
175 00000016 EXPORT PendSV_Handler [WEAK
]
176 00000016 E7FE B .
177 00000018 ENDP
179 00000018 SysTick_Handler
PROC
180 00000018 EXPORT SysTick_Handler [WEAK
]
181 00000018 E7FE B .
182 0000001A ENDP
ARM Macro Assembler Page 5
184 0000001A IRQ00_Handler
PROC
185 0000001A EXPORT IRQ00_Handler [WEAK]
186 0000001A E7FE B .
187 0000001C ENDP
189 0000001C IRQ01_Handler
PROC
190 0000001C EXPORT IRQ01_Handler [WEAK]
191 0000001C E7FE B .
192 0000001E ENDP
194 0000001E IRQ02_Handler
PROC
195 0000001E EXPORT IRQ02_Handler [WEAK]
196 0000001E E7FE B .
197 00000020 ENDP
199 00000020 IRQ03_Handler
PROC
200 00000020 EXPORT IRQ03_Handler [WEAK]
201 00000020 E7FE B .
202 00000022 ENDP
204 00000022 IRQ04_Handler
PROC
205 00000022 EXPORT IRQ04_Handler [WEAK]
206 00000022 E7FE B .
207 00000024 ENDP
209 00000024 IRQ05_Handler
PROC
210 00000024 EXPORT IRQ05_Handler [WEAK]
211 00000024 E7FE B .
212 00000026 ENDP
214 00000026 IRQ06_Handler
PROC
215 00000026 EXPORT IRQ06_Handler [WEAK]
216 00000026 E7FE B .
217 00000028 ENDP
219 00000028 IRQ07_Handler
PROC
220 00000028 EXPORT IRQ07_Handler [WEAK]
221 00000028 E7FE B .
222 0000002A ENDP
224 0000002A IRQ08_Handler
PROC
225 0000002A EXPORT IRQ08_Handler [WEAK]
226 0000002A E7FE B .
227 0000002C ENDP
229 0000002C IRQ09_Handler
PROC
230 0000002C EXPORT IRQ09_Handler [WEAK]
231 0000002C E7FE B .
232 0000002E ENDP
234 0000002E IRQ10_Handler
PROC
235 0000002E EXPORT IRQ10_Handler [WEAK]
236 0000002E E7FE B .
237 00000030 ENDP
239 00000030 IRQ11_Handler
PROC
240 00000030 EXPORT IRQ11_Handler [WEAK]
241 00000030 E7FE B .
ARM Macro Assembler Page 6
242 00000032 ENDP
244 00000032 IRQ12_Handler
PROC
245 00000032 EXPORT IRQ12_Handler [WEAK]
246 00000032 E7FE B .
247 00000034 ENDP
249 00000034 IRQ13_Handler
PROC
250 00000034 EXPORT IRQ13_Handler [WEAK]
251 00000034 E7FE B .
252 00000036 ENDP
254 00000036 IRQ14_Handler
PROC
255 00000036 EXPORT IRQ14_Handler [WEAK]
256 00000036 E7FE B .
257 00000038 ENDP
259 00000038 IRQ15_Handler
PROC
260 00000038 EXPORT IRQ15_Handler [WEAK]
261 00000038 E7FE B .
262 0000003A ENDP
264 0000003A IRQ16_Handler
PROC
265 0000003A EXPORT IRQ16_Handler [WEAK]
266 0000003A E7FE B .
267 0000003C ENDP
269 0000003C IRQ17_Handler
PROC
270 0000003C EXPORT IRQ17_Handler [WEAK]
271 0000003C E7FE B .
272 0000003E ENDP
274 0000003E IRQ18_Handler
PROC
275 0000003E EXPORT IRQ18_Handler [WEAK]
276 0000003E E7FE B .
277 00000040 ENDP
279 00000040 IRQ19_Handler
PROC
280 00000040 EXPORT IRQ19_Handler [WEAK]
281 00000040 E7FE B .
282 00000042 ENDP
284 00000042 IRQ20_Handler
PROC
285 00000042 EXPORT IRQ20_Handler [WEAK]
286 00000042 E7FE B .
287 00000044 ENDP
289 00000044 IRQ21_Handler
PROC
290 00000044 EXPORT IRQ21_Handler [WEAK]
291 00000044 E7FE B .
292 00000046 ENDP
294 00000046 IRQ22_Handler
PROC
295 00000046 EXPORT IRQ22_Handler [WEAK]
296 00000046 E7FE B .
297 00000048 ENDP
299 00000048 IRQ23_Handler
PROC
300 00000048 EXPORT IRQ23_Handler [WEAK]
ARM Macro Assembler Page 7
301 00000048 E7FE B .
302 0000004A ENDP
304 0000004A IRQ24_Handler
PROC
305 0000004A EXPORT IRQ24_Handler [WEAK]
306 0000004A E7FE B .
307 0000004C ENDP
309 0000004C IRQ25_Handler
PROC
310 0000004C EXPORT IRQ25_Handler [WEAK]
311 0000004C E7FE B .
312 0000004E ENDP
314 0000004E IRQ26_Handler
PROC
315 0000004E EXPORT IRQ26_Handler [WEAK]
316 0000004E E7FE B .
317 00000050 ENDP
319 00000050 IRQ27_Handler
PROC
320 00000050 EXPORT IRQ27_Handler [WEAK]
321 00000050 E7FE B .
322 00000052 ENDP
324 00000052 IRQ28_Handler
PROC
325 00000052 EXPORT IRQ28_Handler [WEAK]
326 00000052 E7FE B .
327 00000054 ENDP
329 00000054 IRQ29_Handler
PROC
330 00000054 EXPORT IRQ29_Handler [WEAK]
331 00000054 E7FE B .
332 00000056 ENDP
334 00000056 IRQ30_Handler
PROC
335 00000056 EXPORT IRQ30_Handler [WEAK]
336 00000056 E7FE B .
337 00000058 ENDP
339 00000058 IRQ31_Handler
PROC
340 00000058 EXPORT IRQ31_Handler [WEAK]
341 00000058 E7FE B .
342 0000005A ENDP
343 0000005A
344 0000005A
345 0000005A 00 00 ALIGN
346 0000005C
347 0000005C
348 0000005C ; User Initial Stack & Heap
349 0000005C
350 0000005C IF :DEF:__MICROLIB
351 0000005C
352 0000005C EXPORT __initial_sp
353 0000005C EXPORT __heap_base
354 0000005C EXPORT __heap_limit
355 0000005C
356 0000005C ELSE
371 ENDIF
372 0000005C
373 0000005C
ARM Macro Assembler Page 8
374 0000005C END
00000000
00000000
Command Line: --debug --xref --diag_suppress=9931 --cpu=Cortex-M0+ --apcs=inter
work --depend=.\objects\startup_bat32a239.d -o.\objects\startup_bat32a239.o -I.
\RTE\Device\BAT32A239KK64FB -I.\RTE\_HaoJin232 -IC:\Users\tyw05\AppData\Local\A
rm\Packs\ARM\CMSIS\5.8.0\CMSIS\Core\Include -IC:\Users\tyw05\AppData\Local\Arm\
Packs\Cmsemicon\BAT32A239\1.0.5\Device\Include --predefine="__MICROLIB SETA 1"
--predefine="__UVISION_VERSION SETA 535" --predefine="_RTE_ SETA 1" --predefine
="_RTE_ SETA 1" --list=.\listings\startup_bat32a239.lst RTE\Device\BAT32A239KK6
4FB\startup_BAT32A239.s
ARM Macro Assembler Page 1 Alphabetic symbol ordering
Relocatable symbols
STACK 00000000
Symbol: STACK
Definitions
At line 37 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
None
Comment: STACK unused
Stack_Mem 00000000
Symbol: Stack_Mem
Definitions
At line 38 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
None
Comment: Stack_Mem unused
__initial_sp 00000600
Symbol: __initial_sp
Definitions
At line 39 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 65 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 352 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
3 symbols
ARM Macro Assembler Page 1 Alphabetic symbol ordering
Relocatable symbols
HEAP 00000000
Symbol: HEAP
Definitions
At line 48 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
None
Comment: HEAP unused
Heap_Mem 00000000
Symbol: Heap_Mem
Definitions
At line 50 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
None
Comment: Heap_Mem unused
__heap_base 00000000
Symbol: __heap_base
Definitions
At line 49 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 353 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Comment: __heap_base used once
__heap_limit 00000100
Symbol: __heap_limit
Definitions
At line 51 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 354 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Comment: __heap_limit used once
4 symbols
ARM Macro Assembler Page 1 Alphabetic symbol ordering
Relocatable symbols
RESET 00000000
Symbol: RESET
Definitions
At line 60 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
None
Comment: RESET unused
__Vectors 00000000
Symbol: __Vectors
Definitions
At line 65 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 61 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 118 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
__Vectors_End 000000C0
Symbol: __Vectors_End
Definitions
At line 116 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 62 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 118 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
3 symbols
ARM Macro Assembler Page 1 Alphabetic symbol ordering
Relocatable symbols
.text 00000000
Symbol: .text
Definitions
At line 120 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
None
Comment: .text unused
BusFault_Handler 0000000E
Symbol: BusFault_Handler
Definitions
At line 154 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 155 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Comment: BusFault_Handler used once
DebugMon_Handler 00000014
Symbol: DebugMon_Handler
Definitions
At line 169 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 170 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Comment: DebugMon_Handler used once
HardFault_Handler 0000000A
Symbol: HardFault_Handler
Definitions
At line 144 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 68 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 145 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ00_Handler 0000001A
Symbol: IRQ00_Handler
Definitions
At line 184 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 84 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 185 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ01_Handler 0000001C
Symbol: IRQ01_Handler
Definitions
At line 189 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 85 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 190 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ02_Handler 0000001E
Symbol: IRQ02_Handler
Definitions
At line 194 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 86 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 195 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
ARM Macro Assembler Page 2 Alphabetic symbol ordering
Relocatable symbols
IRQ03_Handler 00000020
Symbol: IRQ03_Handler
Definitions
At line 199 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 87 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 200 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ04_Handler 00000022
Symbol: IRQ04_Handler
Definitions
At line 204 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 88 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 205 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ05_Handler 00000024
Symbol: IRQ05_Handler
Definitions
At line 209 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 89 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 210 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ06_Handler 00000026
Symbol: IRQ06_Handler
Definitions
At line 214 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 90 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 215 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ07_Handler 00000028
Symbol: IRQ07_Handler
Definitions
At line 219 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 91 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 220 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ08_Handler 0000002A
Symbol: IRQ08_Handler
Definitions
At line 224 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 92 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 225 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ09_Handler 0000002C
Symbol: IRQ09_Handler
Definitions
ARM Macro Assembler Page 3 Alphabetic symbol ordering
Relocatable symbols
At line 229 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 93 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 230 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ10_Handler 0000002E
Symbol: IRQ10_Handler
Definitions
At line 234 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 94 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 235 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ11_Handler 00000030
Symbol: IRQ11_Handler
Definitions
At line 239 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 95 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 240 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ12_Handler 00000032
Symbol: IRQ12_Handler
Definitions
At line 244 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 96 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 245 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ13_Handler 00000034
Symbol: IRQ13_Handler
Definitions
At line 249 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 97 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 250 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ14_Handler 00000036
Symbol: IRQ14_Handler
Definitions
At line 254 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 98 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 255 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ15_Handler 00000038
Symbol: IRQ15_Handler
Definitions
At line 259 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 99 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 260 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
ARM Macro Assembler Page 4 Alphabetic symbol ordering
Relocatable symbols
IRQ16_Handler 0000003A
Symbol: IRQ16_Handler
Definitions
At line 264 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 100 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 265 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ17_Handler 0000003C
Symbol: IRQ17_Handler
Definitions
At line 269 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 101 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 270 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ18_Handler 0000003E
Symbol: IRQ18_Handler
Definitions
At line 274 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 102 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 275 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ19_Handler 00000040
Symbol: IRQ19_Handler
Definitions
At line 279 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 103 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 280 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ20_Handler 00000042
Symbol: IRQ20_Handler
Definitions
At line 284 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 104 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 285 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ21_Handler 00000044
Symbol: IRQ21_Handler
Definitions
At line 289 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 105 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 290 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ22_Handler 00000046
Symbol: IRQ22_Handler
Definitions
At line 294 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
ARM Macro Assembler Page 5 Alphabetic symbol ordering
Relocatable symbols
Uses
At line 106 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 295 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ23_Handler 00000048
Symbol: IRQ23_Handler
Definitions
At line 299 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 107 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 300 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ24_Handler 0000004A
Symbol: IRQ24_Handler
Definitions
At line 304 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 108 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 305 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ25_Handler 0000004C
Symbol: IRQ25_Handler
Definitions
At line 309 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 109 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 310 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ26_Handler 0000004E
Symbol: IRQ26_Handler
Definitions
At line 314 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 110 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 315 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ27_Handler 00000050
Symbol: IRQ27_Handler
Definitions
At line 319 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 111 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 320 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ28_Handler 00000052
Symbol: IRQ28_Handler
Definitions
At line 324 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 112 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 325 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ29_Handler 00000054
ARM Macro Assembler Page 6 Alphabetic symbol ordering
Relocatable symbols
Symbol: IRQ29_Handler
Definitions
At line 329 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 113 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 330 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ30_Handler 00000056
Symbol: IRQ30_Handler
Definitions
At line 334 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 114 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 335 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
IRQ31_Handler 00000058
Symbol: IRQ31_Handler
Definitions
At line 339 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 115 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 340 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
MemManage_Handler 0000000C
Symbol: MemManage_Handler
Definitions
At line 149 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 150 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Comment: MemManage_Handler used once
NMI_Handler 00000008
Symbol: NMI_Handler
Definitions
At line 139 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 67 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 140 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
PendSV_Handler 00000016
Symbol: PendSV_Handler
Definitions
At line 174 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 79 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 175 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Reset_Handler 00000000
Symbol: Reset_Handler
Definitions
At line 125 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 66 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
ARM Macro Assembler Page 7 Alphabetic symbol ordering
Relocatable symbols
At line 126 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
SVC_Handler 00000012
Symbol: SVC_Handler
Definitions
At line 164 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 76 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 165 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
SysTick_Handler 00000018
Symbol: SysTick_Handler
Definitions
At line 179 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 80 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
At line 180 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
UsageFault_Handler 00000010
Symbol: UsageFault_Handler
Definitions
At line 159 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 160 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Comment: UsageFault_Handler used once
43 symbols
ARM Macro Assembler Page 1 Alphabetic symbol ordering
Absolute symbols
Heap_Size 00000100
Symbol: Heap_Size
Definitions
At line 46 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 50 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Comment: Heap_Size used once
Stack_Size 00000600
Symbol: Stack_Size
Definitions
At line 35 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 38 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Comment: Stack_Size used once
__Vectors_Size 000000C0
Symbol: __Vectors_Size
Definitions
At line 118 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 63 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Comment: __Vectors_Size used once
3 symbols
ARM Macro Assembler Page 1 Alphabetic symbol ordering
External symbols
SystemInit 00000000
Symbol: SystemInit
Definitions
At line 127 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 129 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Comment: SystemInit used once
__main 00000000
Symbol: __main
Definitions
At line 128 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Uses
At line 131 in file RTE\Device\BAT32A239KK64FB\startup_BAT32A239.s
Comment: __main used once
2 symbols
393 symbols in table
ARM Macro Assembler Page 1
1 00000000 ;/******************************************************
********************//**
2 00000000 ; * @file startup_BAT32A279.s
3 00000000 ; * @brief CMSIS Cortex-M ARMv6-M based Core Device S
tartup File for
4 00000000 ; * Device BAT32A279
5 00000000 ; * @version V1.00
6 00000000 ; * @date 2019/04/24
7 00000000 ; ******************************************************
************************/
8 00000000 ;/*
9 00000000 ; * Copyright (c) 2009-2016 ARM Limited. All rights rese
rved.
10 00000000 ; *
11 00000000 ; * SPDX-License-Identifier: Apache-2.0
12 00000000 ; *
13 00000000 ; * Licensed under the Apache License, Version 2.0 (the
License); you may
14 00000000 ; * not use this file except in compliance with the Lice
nse.
15 00000000 ; * You may obtain a copy of the License at
16 00000000 ; *
17 00000000 ; * www.apache.org/licenses/LICENSE-2.0
18 00000000 ; *
19 00000000 ; * Unless required by applicable law or agreed to in wr
iting, software
20 00000000 ; * distributed under the License is distributed on an A
S IS BASIS, WITHOUT
21 00000000 ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied.
22 00000000 ; * See the License for the specific language governing
permissions and
23 00000000 ; * limitations under the License.
24 00000000 ; */
25 00000000 ;/*
26 00000000
27 00000000 ;//-------- <<< Use Configuration Wizard in Context Menu
>>> ------------------
28 00000000 ;*/
29 00000000
30 00000000
31 00000000 ; <h> Stack Configuration
32 00000000 ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
33 00000000 ; </h>
34 00000000
35 00000000 00001000
Stack_Size
EQU 0x00001000
36 00000000
37 00000000 AREA STACK, NOINIT, READWRITE, ALIGN
=3
38 00000000 Stack_Mem
SPACE Stack_Size
39 00001000 __initial_sp
40 00001000
41 00001000
42 00001000 ; <h> Heap Configuration
43 00001000 ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
44 00001000 ; </h>
ARM Macro Assembler Page 2
45 00001000
46 00001000 00000100
Heap_Size
EQU 0x00000100
47 00001000
48 00001000 AREA HEAP, NOINIT, READWRITE, ALIGN=
3
49 00000000 __heap_base
50 00000000 Heap_Mem
SPACE Heap_Size
51 00000100 __heap_limit
52 00000100
53 00000100
54 00000100 PRESERVE8
55 00000100 THUMB
56 00000100
57 00000100
58 00000100 ; Vector Table Mapped to Address 0 at Reset
59 00000100
60 00000100 AREA RESET, DATA, READONLY
61 00000000 EXPORT __Vectors
62 00000000 EXPORT __Vectors_End
63 00000000 EXPORT __Vectors_Size
64 00000000
65 00000000 00000000
__Vectors
DCD __initial_sp ; Top of Stack
66 00000004 00000000 DCD Reset_Handler ; Reset Handler
67 00000008 00000000 DCD NMI_Handler ; NMI Handler
68 0000000C 00000000 DCD HardFault_Handler ; Hard Fault
Handler
69 00000010 00000000 DCD 0 ; Reserved
70 00000014 00000000 DCD 0 ; Reserved
71 00000018 00000000 DCD 0 ; Reserved
72 0000001C 00000000 DCD 0 ; Reserved
73 00000020 00000000 DCD 0 ; Reserved
74 00000024 00000000 DCD 0 ; Reserved
75 00000028 00000000 DCD 0 ; Reserved
76 0000002C 00000000 DCD SVC_Handler ; SVCall Handler
77 00000030 00000000 DCD 0 ; Reserved
78 00000034 00000000 DCD 0 ; Reserved
79 00000038 00000000 DCD PendSV_Handler ; PendSV Handler
80 0000003C 00000000 DCD SysTick_Handler
; SysTick Handler
81 00000040
82 00000040 ; External Interrupts
83 00000040 ; ToDo: Add here the vectors for the device specific ex
ternal interrupts handler
84 00000040 00000000 DCD IRQ00_Handler ; LVI IRQ
85 00000044 00000000 DCD IRQ01_Handler ; INTP0 or INTP6
IRQ
86 00000048 00000000 DCD IRQ02_Handler ; INTP1 or INTP7
IRQ
87 0000004C 00000000 DCD IRQ03_Handler ; INTP2 or INTP8
IRQ
88 00000050 00000000 DCD IRQ04_Handler ; INTP3 or INTP9
IRQ
89 00000054 00000000 DCD IRQ05_Handler ; INTP4 or INTP1
ARM Macro Assembler Page 3
0 IRQ
90 00000058 00000000 DCD IRQ06_Handler ; INTP5 or INTP1
1 IRQ
91 0000005C 00000000 DCD IRQ07_Handler ; ST2/SPI20/IIC2
0 IRQ
92 00000060 00000000 DCD IRQ08_Handler ; SR2/SPI21/IIC2
1 IRQ
93 00000064 00000000 DCD IRQ09_Handler ; SRE2 IRQ
94 00000068 00000000 DCD IRQ10_Handler ; ST0/SPI00/IIC0
0 IRQ
95 0000006C 00000000 DCD IRQ11_Handler ; SR0/SPI01/IIC0
1 IRQ
96 00000070 00000000 DCD IRQ12_Handler ; SRE0 or TM01H
IRQ
97 00000074 00000000 DCD IRQ13_Handler ; ST1/SPI10/IIC1
0 IRQ
98 00000078 00000000 DCD IRQ14_Handler ; SR1/SPI11/IIC1
1 IRQ
99 0000007C 00000000 DCD IRQ15_Handler ; SRE1 or TM03H
IRQ
100 00000080 00000000 DCD IRQ16_Handler
; IICA or DIV IRQ
101 00000084 00000000 DCD IRQ17_Handler ; TM00 IRQ
102 00000088 00000000 DCD IRQ18_Handler ; TM01 IRQ
103 0000008C 00000000 DCD IRQ19_Handler ; TM02 IRQ
104 00000090 00000000 DCD IRQ20_Handler ; TM03 IRQ
105 00000094 00000000 DCD IRQ21_Handler ; ADC IRQ
106 00000098 00000000 DCD IRQ22_Handler ; RTC or IT IRQ
107 0000009C 00000000 DCD IRQ23_Handler ; KEY IRQ
108 000000A0 00000000 DCD IRQ24_Handler ; CMP0 IRQ
109 000000A4 00000000 DCD IRQ25_Handler ; CMP1 IRQ
110 000000A8 00000000 DCD IRQ26_Handler ; TMA IRQ
111 000000AC 00000000 DCD IRQ27_Handler ; TMM0 IRQ
112 000000B0 00000000 DCD IRQ28_Handler ; TMM1 IRQ
113 000000B4 00000000 DCD IRQ29_Handler ; TMB IRQ
114 000000B8 00000000 DCD IRQ30_Handler ; TMC IRQ
115 000000BC 00000000 DCD IRQ31_Handler ; FMC IRQ
116 000000C0 __Vectors_End
117 000000C0
118 000000C0 000000C0
__Vectors_Size
EQU __Vectors_End - __Vectors
119 000000C0
120 000000C0 AREA |.text|, CODE, READONLY
121 00000000
122 00000000
123 00000000 ; Reset Handler
124 00000000
125 00000000 Reset_Handler
PROC
126 00000000 EXPORT Reset_Handler [WEAK
]
127 00000000 IMPORT SystemInit
128 00000000 IMPORT __main
129 00000000 4816 LDR R0, =SystemInit
130 00000002 4780 BLX R0
131 00000004 4816 LDR R0, =__main
132 00000006 4700 BX R0
133 00000008 ENDP
ARM Macro Assembler Page 4
134 00000008
135 00000008
136 00000008 ; Dummy Exception Handlers (infinite loops which can be
modified)
137 00000008
139 00000008 NMI_Handler
PROC
140 00000008 EXPORT NMI_Handler [WEAK
]
141 00000008 E7FE B .
142 0000000A ENDP
144 0000000A HardFault_Handler
PROC
145 0000000A EXPORT HardFault_Handler [WEAK
]
146 0000000A E7FE B .
147 0000000C ENDP
149 0000000C MemManage_Handler
PROC
150 0000000C EXPORT MemManage_Handler [WEAK
]
151 0000000C E7FE B .
152 0000000E ENDP
154 0000000E BusFault_Handler
PROC
155 0000000E EXPORT BusFault_Handler [WEAK
]
156 0000000E E7FE B .
157 00000010 ENDP
159 00000010 UsageFault_Handler
PROC
160 00000010 EXPORT UsageFault_Handler [WEAK
]
161 00000010 E7FE B .
162 00000012 ENDP
164 00000012 SVC_Handler
PROC
165 00000012 EXPORT SVC_Handler [WEAK
]
166 00000012 E7FE B .
167 00000014 ENDP
169 00000014 DebugMon_Handler
PROC
170 00000014 EXPORT DebugMon_Handler [WEAK
]
171 00000014 E7FE B .
172 00000016 ENDP
174 00000016 PendSV_Handler
PROC
175 00000016 EXPORT PendSV_Handler [WEAK
]
176 00000016 E7FE B .
177 00000018 ENDP
179 00000018 SysTick_Handler
PROC
180 00000018 EXPORT SysTick_Handler [WEAK
]
181 00000018 E7FE B .
182 0000001A ENDP
ARM Macro Assembler Page 5
184 0000001A IRQ00_Handler
PROC
185 0000001A EXPORT IRQ00_Handler [WEAK]
186 0000001A E7FE B .
187 0000001C ENDP
189 0000001C IRQ01_Handler
PROC
190 0000001C EXPORT IRQ01_Handler [WEAK]
191 0000001C E7FE B .
192 0000001E ENDP
194 0000001E IRQ02_Handler
PROC
195 0000001E EXPORT IRQ02_Handler [WEAK]
196 0000001E E7FE B .
197 00000020 ENDP
199 00000020 IRQ03_Handler
PROC
200 00000020 EXPORT IRQ03_Handler [WEAK]
201 00000020 E7FE B .
202 00000022 ENDP
204 00000022 IRQ04_Handler
PROC
205 00000022 EXPORT IRQ04_Handler [WEAK]
206 00000022 E7FE B .
207 00000024 ENDP
209 00000024 IRQ05_Handler
PROC
210 00000024 EXPORT IRQ05_Handler [WEAK]
211 00000024 E7FE B .
212 00000026 ENDP
214 00000026 IRQ06_Handler
PROC
215 00000026 EXPORT IRQ06_Handler [WEAK]
216 00000026 E7FE B .
217 00000028 ENDP
219 00000028 IRQ07_Handler
PROC
220 00000028 EXPORT IRQ07_Handler [WEAK]
221 00000028 E7FE B .
222 0000002A ENDP
224 0000002A IRQ08_Handler
PROC
225 0000002A EXPORT IRQ08_Handler [WEAK]
226 0000002A E7FE B .
227 0000002C ENDP
229 0000002C IRQ09_Handler
PROC
230 0000002C EXPORT IRQ09_Handler [WEAK]
231 0000002C E7FE B .
232 0000002E ENDP
234 0000002E IRQ10_Handler
PROC
235 0000002E EXPORT IRQ10_Handler [WEAK]
236 0000002E E7FE B .
237 00000030 ENDP
239 00000030 IRQ11_Handler
PROC
240 00000030 EXPORT IRQ11_Handler [WEAK]
241 00000030 E7FE B .
ARM Macro Assembler Page 6
242 00000032 ENDP
244 00000032 IRQ12_Handler
PROC
245 00000032 EXPORT IRQ12_Handler [WEAK]
246 00000032 E7FE B .
247 00000034 ENDP
249 00000034 IRQ13_Handler
PROC
250 00000034 EXPORT IRQ13_Handler [WEAK]
251 00000034 E7FE B .
252 00000036 ENDP
254 00000036 IRQ14_Handler
PROC
255 00000036 EXPORT IRQ14_Handler [WEAK]
256 00000036 E7FE B .
257 00000038 ENDP
259 00000038 IRQ15_Handler
PROC
260 00000038 EXPORT IRQ15_Handler [WEAK]
261 00000038 E7FE B .
262 0000003A ENDP
264 0000003A IRQ16_Handler
PROC
265 0000003A EXPORT IRQ16_Handler [WEAK]
266 0000003A E7FE B .
267 0000003C ENDP
269 0000003C IRQ17_Handler
PROC
270 0000003C EXPORT IRQ17_Handler [WEAK]
271 0000003C E7FE B .
272 0000003E ENDP
274 0000003E IRQ18_Handler
PROC
275 0000003E EXPORT IRQ18_Handler [WEAK]
276 0000003E E7FE B .
277 00000040 ENDP
279 00000040 IRQ19_Handler
PROC
280 00000040 EXPORT IRQ19_Handler [WEAK]
281 00000040 E7FE B .
282 00000042 ENDP
284 00000042 IRQ20_Handler
PROC
285 00000042 EXPORT IRQ20_Handler [WEAK]
286 00000042 E7FE B .
287 00000044 ENDP
289 00000044 IRQ21_Handler
PROC
290 00000044 EXPORT IRQ21_Handler [WEAK]
291 00000044 E7FE B .
292 00000046 ENDP
294 00000046 IRQ22_Handler
PROC
295 00000046 EXPORT IRQ22_Handler [WEAK]
296 00000046 E7FE B .
297 00000048 ENDP
299 00000048 IRQ23_Handler
PROC
300 00000048 EXPORT IRQ23_Handler [WEAK]
ARM Macro Assembler Page 7
301 00000048 E7FE B .
302 0000004A ENDP
304 0000004A IRQ24_Handler
PROC
305 0000004A EXPORT IRQ24_Handler [WEAK]
306 0000004A E7FE B .
307 0000004C ENDP
309 0000004C IRQ25_Handler
PROC
310 0000004C EXPORT IRQ25_Handler [WEAK]
311 0000004C E7FE B .
312 0000004E ENDP
314 0000004E IRQ26_Handler
PROC
315 0000004E EXPORT IRQ26_Handler [WEAK]
316 0000004E E7FE B .
317 00000050 ENDP
319 00000050 IRQ27_Handler
PROC
320 00000050 EXPORT IRQ27_Handler [WEAK]
321 00000050 E7FE B .
322 00000052 ENDP
324 00000052 IRQ28_Handler
PROC
325 00000052 EXPORT IRQ28_Handler [WEAK]
326 00000052 E7FE B .
327 00000054 ENDP
329 00000054 IRQ29_Handler
PROC
330 00000054 EXPORT IRQ29_Handler [WEAK]
331 00000054 E7FE B .
332 00000056 ENDP
334 00000056 IRQ30_Handler
PROC
335 00000056 EXPORT IRQ30_Handler [WEAK]
336 00000056 E7FE B .
337 00000058 ENDP
339 00000058 IRQ31_Handler
PROC
340 00000058 EXPORT IRQ31_Handler [WEAK]
341 00000058 E7FE B .
342 0000005A ENDP
343 0000005A
344 0000005A
345 0000005A 00 00 ALIGN
346 0000005C
347 0000005C
348 0000005C ; User Initial Stack & Heap
349 0000005C
350 0000005C IF :DEF:__MICROLIB
351 0000005C
352 0000005C EXPORT __initial_sp
353 0000005C EXPORT __heap_base
354 0000005C EXPORT __heap_limit
355 0000005C
356 0000005C ELSE
371 ENDIF
372 0000005C
373 0000005C
ARM Macro Assembler Page 8
374 0000005C END
00000000
00000000
Command Line: --debug --xref --diag_suppress=9931 --cpu=Cortex-M0+ --apcs=inter
work --depend=.\objects\startup_bat32a279.d -o.\objects\startup_bat32a279.o -I.
\RTE\Device\BAT32A279KM64FB -I.\RTE\_HaoJin750TFT -IC:\Users\tyw05\AppData\Loca
l\Arm\Packs\ARM\CMSIS\5.8.0\CMSIS\Core\Include -IC:\Users\tyw05\AppData\Local\A
rm\Packs\Cmsemicon\BAT32A279\1.0.4\Device\Include --predefine="__MICROLIB SETA
1" --predefine="__UVISION_VERSION SETA 535" --predefine="_RTE_ SETA 1" --predef
ine="_RTE_ SETA 1" --list=.\listings\startup_bat32a279.lst RTE\Device\BAT32A279
KM64FB\startup_BAT32A279.s
ARM Macro Assembler Page 1 Alphabetic symbol ordering
Relocatable symbols
STACK 00000000
Symbol: STACK
Definitions
At line 37 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
None
Comment: STACK unused
Stack_Mem 00000000
Symbol: Stack_Mem
Definitions
At line 38 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
None
Comment: Stack_Mem unused
__initial_sp 00001000
Symbol: __initial_sp
Definitions
At line 39 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 65 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 352 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
3 symbols
ARM Macro Assembler Page 1 Alphabetic symbol ordering
Relocatable symbols
HEAP 00000000
Symbol: HEAP
Definitions
At line 48 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
None
Comment: HEAP unused
Heap_Mem 00000000
Symbol: Heap_Mem
Definitions
At line 50 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
None
Comment: Heap_Mem unused
__heap_base 00000000
Symbol: __heap_base
Definitions
At line 49 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 353 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Comment: __heap_base used once
__heap_limit 00000100
Symbol: __heap_limit
Definitions
At line 51 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 354 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Comment: __heap_limit used once
4 symbols
ARM Macro Assembler Page 1 Alphabetic symbol ordering
Relocatable symbols
RESET 00000000
Symbol: RESET
Definitions
At line 60 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
None
Comment: RESET unused
__Vectors 00000000
Symbol: __Vectors
Definitions
At line 65 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 61 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 118 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
__Vectors_End 000000C0
Symbol: __Vectors_End
Definitions
At line 116 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 62 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 118 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
3 symbols
ARM Macro Assembler Page 1 Alphabetic symbol ordering
Relocatable symbols
.text 00000000
Symbol: .text
Definitions
At line 120 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
None
Comment: .text unused
BusFault_Handler 0000000E
Symbol: BusFault_Handler
Definitions
At line 154 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 155 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Comment: BusFault_Handler used once
DebugMon_Handler 00000014
Symbol: DebugMon_Handler
Definitions
At line 169 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 170 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Comment: DebugMon_Handler used once
HardFault_Handler 0000000A
Symbol: HardFault_Handler
Definitions
At line 144 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 68 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 145 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ00_Handler 0000001A
Symbol: IRQ00_Handler
Definitions
At line 184 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 84 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 185 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ01_Handler 0000001C
Symbol: IRQ01_Handler
Definitions
At line 189 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 85 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 190 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ02_Handler 0000001E
Symbol: IRQ02_Handler
Definitions
At line 194 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 86 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 195 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
ARM Macro Assembler Page 2 Alphabetic symbol ordering
Relocatable symbols
IRQ03_Handler 00000020
Symbol: IRQ03_Handler
Definitions
At line 199 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 87 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 200 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ04_Handler 00000022
Symbol: IRQ04_Handler
Definitions
At line 204 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 88 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 205 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ05_Handler 00000024
Symbol: IRQ05_Handler
Definitions
At line 209 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 89 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 210 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ06_Handler 00000026
Symbol: IRQ06_Handler
Definitions
At line 214 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 90 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 215 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ07_Handler 00000028
Symbol: IRQ07_Handler
Definitions
At line 219 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 91 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 220 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ08_Handler 0000002A
Symbol: IRQ08_Handler
Definitions
At line 224 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 92 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 225 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ09_Handler 0000002C
Symbol: IRQ09_Handler
Definitions
ARM Macro Assembler Page 3 Alphabetic symbol ordering
Relocatable symbols
At line 229 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 93 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 230 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ10_Handler 0000002E
Symbol: IRQ10_Handler
Definitions
At line 234 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 94 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 235 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ11_Handler 00000030
Symbol: IRQ11_Handler
Definitions
At line 239 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 95 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 240 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ12_Handler 00000032
Symbol: IRQ12_Handler
Definitions
At line 244 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 96 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 245 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ13_Handler 00000034
Symbol: IRQ13_Handler
Definitions
At line 249 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 97 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 250 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ14_Handler 00000036
Symbol: IRQ14_Handler
Definitions
At line 254 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 98 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 255 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ15_Handler 00000038
Symbol: IRQ15_Handler
Definitions
At line 259 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 99 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 260 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
ARM Macro Assembler Page 4 Alphabetic symbol ordering
Relocatable symbols
IRQ16_Handler 0000003A
Symbol: IRQ16_Handler
Definitions
At line 264 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 100 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 265 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ17_Handler 0000003C
Symbol: IRQ17_Handler
Definitions
At line 269 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 101 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 270 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ18_Handler 0000003E
Symbol: IRQ18_Handler
Definitions
At line 274 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 102 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 275 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ19_Handler 00000040
Symbol: IRQ19_Handler
Definitions
At line 279 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 103 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 280 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ20_Handler 00000042
Symbol: IRQ20_Handler
Definitions
At line 284 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 104 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 285 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ21_Handler 00000044
Symbol: IRQ21_Handler
Definitions
At line 289 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 105 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 290 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ22_Handler 00000046
Symbol: IRQ22_Handler
Definitions
At line 294 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
ARM Macro Assembler Page 5 Alphabetic symbol ordering
Relocatable symbols
Uses
At line 106 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 295 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ23_Handler 00000048
Symbol: IRQ23_Handler
Definitions
At line 299 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 107 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 300 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ24_Handler 0000004A
Symbol: IRQ24_Handler
Definitions
At line 304 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 108 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 305 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ25_Handler 0000004C
Symbol: IRQ25_Handler
Definitions
At line 309 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 109 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 310 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ26_Handler 0000004E
Symbol: IRQ26_Handler
Definitions
At line 314 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 110 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 315 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ27_Handler 00000050
Symbol: IRQ27_Handler
Definitions
At line 319 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 111 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 320 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ28_Handler 00000052
Symbol: IRQ28_Handler
Definitions
At line 324 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 112 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 325 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ29_Handler 00000054
ARM Macro Assembler Page 6 Alphabetic symbol ordering
Relocatable symbols
Symbol: IRQ29_Handler
Definitions
At line 329 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 113 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 330 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ30_Handler 00000056
Symbol: IRQ30_Handler
Definitions
At line 334 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 114 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 335 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
IRQ31_Handler 00000058
Symbol: IRQ31_Handler
Definitions
At line 339 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 115 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 340 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
MemManage_Handler 0000000C
Symbol: MemManage_Handler
Definitions
At line 149 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 150 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Comment: MemManage_Handler used once
NMI_Handler 00000008
Symbol: NMI_Handler
Definitions
At line 139 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 67 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 140 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
PendSV_Handler 00000016
Symbol: PendSV_Handler
Definitions
At line 174 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 79 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 175 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Reset_Handler 00000000
Symbol: Reset_Handler
Definitions
At line 125 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 66 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
ARM Macro Assembler Page 7 Alphabetic symbol ordering
Relocatable symbols
At line 126 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
SVC_Handler 00000012
Symbol: SVC_Handler
Definitions
At line 164 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 76 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 165 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
SysTick_Handler 00000018
Symbol: SysTick_Handler
Definitions
At line 179 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 80 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
At line 180 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
UsageFault_Handler 00000010
Symbol: UsageFault_Handler
Definitions
At line 159 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 160 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Comment: UsageFault_Handler used once
43 symbols
ARM Macro Assembler Page 1 Alphabetic symbol ordering
Absolute symbols
Heap_Size 00000100
Symbol: Heap_Size
Definitions
At line 46 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 50 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Comment: Heap_Size used once
Stack_Size 00001000
Symbol: Stack_Size
Definitions
At line 35 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 38 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Comment: Stack_Size used once
__Vectors_Size 000000C0
Symbol: __Vectors_Size
Definitions
At line 118 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 63 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Comment: __Vectors_Size used once
3 symbols
ARM Macro Assembler Page 1 Alphabetic symbol ordering
External symbols
SystemInit 00000000
Symbol: SystemInit
Definitions
At line 127 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 129 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Comment: SystemInit used once
__main 00000000
Symbol: __main
Definitions
At line 128 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Uses
At line 131 in file RTE\Device\BAT32A279KM64FB\startup_BAT32A279.s
Comment: __main used once
2 symbols
393 symbols in table
/******************************************************************************
文 件 名:Diag_ID_Def
功能描述:诊断地址配置文件
作 者:张暄
版 本:V1.0
日 期:2016.9.22
******************************************************************************/
#ifndef _DIAG_ID_DEF_H_
#define _DIAG_ID_DEF_H_
#define DIAG_ID_Tx 0x07E8 /*发送ID*/
#define DIAG_ID_Rx_PHY 0x07E0 /*接收ID,物理寻址*/
#define DIAG_ID_Rx_FUN 0x07DF /*接收ID,功能寻址*/
#endif
/******************************************************************************
文 件 名:DoCAN_ISO15765.c
功能描述:ISO 15765 规范规定的诊断服务函数库文件
作 者:张暄
版 本:V1.0
日 期:2016.7.18
******************************************************************************/
#include "DoCAN_ISO15765.h"
#include "Application.h"
#include "can.h"
LinkRxFIFOStruct LinkRxFIFO;
LinkTxCtrlStruct LinkTxCtrl;
volatile TransportDataUnion TransportRxData;
volatile TransportDataUnion TransportTxData;
N_USDataRxStruct N_USDataRxBuffer;
N_USDataTxStruct N_USDataTxBuffer;
TransportControlStruct TpCtrl;
TransportTimingControlStruct TpTimingCtrl;
uint8_t DiagnosticReceived;
extern void UDS_N_USData_Confirm(uint16_t N_TAtype, uint8_t N_Result);
extern void UDS_N_USData_FF_Indication(uint16_t N_TAtype, uint16_t Length);
extern void UDS_N_USData_Indication(uint16_t N_TAtype, uint8_t *MessageData, uint16_t Length, uint8_t N_Result);
/******************************************************************************
后台服务
******************************************************************************/
/******************************************************************************
函数名:DoCAN_Communication_Service
功 能:基于CAN总线的诊断通信服务后台控制函数
参 数:无
返回值:无
*******************************************************************************
注 意:该服务函数必须被实时调用
******************************************************************************/
void DoCAN_Communication_Service(void)
{
DoCAN_Update_Timer( );
DoCAN_Handle_Time_Out( );
UDS_Server_Application_Service( );
DoCAN_Receive_And_Assemble_N_USData( );
DoCAN_Disassemble_And_Transmit_N_USData( );
}
/******************************************************************************
函数名:DoCAN_Timer_Update
功 能:更新定时器数值,用于时序控制以及STmin计时
参 数:Interval:定时器两次更新的时间间隔,单位us
返回值:无
*******************************************************************************
注 意:该服务函数必须被嵌入到定时中断中
******************************************************************************/
void DoCAN_Timer_Update(uint16_t Interval)
{
TpTimingCtrl.Cnt += Interval;
}
/******************************************************************************
Services provided by network layer to higher layers
******************************************************************************/
/******************************************************************************
函数名:DoCAN_N_USData_Request
功 能:该服务函数用于请求传输数据
This service is used to request the transfer of data. If necessary, the
network layer segments the data.
参 数:N_TAtype :目标地址类型,发送数据请使用 DIAG_ID_Tx
MessageData :请求传输的数据
Length :数据长度
返回值:无
******************************************************************************/
void DoCAN_N_USData_Request(uint16_t N_TAtype, uint8_t *MessageData, uint16_t Length)
{
uint8_t i;
// 非空闲状态下不允许发送
if ( TpCtrl.Process != TP_IDLE )
{
DoCAN_N_USData_Confirm(N_TAtype, N_ERROR);
return;
}
if ( (Length == 0) || (Length > N_USDATA_TX_BUFFER_SIZE) ) // 非法的长度
{
DoCAN_N_USData_Confirm(N_TAtype, N_ERROR);
return;
}
// 将数据缓存到发送Buffer中
N_USDataTxBuffer.N_TAtype = N_TAtype;
N_USDataTxBuffer.Length = Length;
for ( i = 0; i < Length; i++ )
{
N_USDataTxBuffer.MsgData [ i ] = *MessageData;
MessageData++;
}
// 更新传输层状态
TpCtrl.NonStopMode = 0;
TpCtrl.TotalLen = Length; // 记录字节总数
TpCtrl.BSMax = 0xFF; // 初始化BSMax数值
TpCtrl.STmin = 0x7F;
// 拆分为N_PDU
if ( TpCtrl.TotalLen < 8 ) // 数据总长度小于8,采用单帧发送
{
TpCtrl.BlockSize = 1; // 单帧,Block总数为1
TpCtrl.Len = TpCtrl.TotalLen; // 单帧发出全部的数据
TpCtrl.BlockCnt = 1; // 记录已发送Block数
TransportTxData.N_PDU_SF.N_TAtype = N_USDataTxBuffer.N_TAtype;
TransportTxData.N_PDU_SF.N_PCI.Type = SINGLE_FRAME;
TransportTxData.N_PDU_SF.N_PCI.SF_DL = ( uint8_t )(TpCtrl.TotalLen);
TransportTxData.N_PDU_SF.DLC = ( uint8_t )(TpCtrl.TotalLen) + 1;
for ( i = 0; i < TpCtrl.TotalLen; i++ )
TransportTxData.N_PDU_SF.N_Data [ i ] = N_USDataTxBuffer.MsgData [ i ];
}
else // 数据总长度大于等于8,采用多帧发送,首先发送首帧
{
if ( (Length + 1) % 7 ) // 计算BlockSize
TpCtrl.BlockSize = (Length + 8) / 7; // 等效于(Length + 1) / 7 + 1
else
TpCtrl.BlockSize = (Length + 1) / 7;
TpCtrl.Len = 6; // 首帧发出数据长度为6
TpCtrl.BlockCnt = 1; // 记录已发送Block数
TransportTxData.N_PDU_FF.N_TAtype = N_USDataTxBuffer.N_TAtype;
TransportTxData.N_PDU_FF.N_PCI.Type = FIRST_FRAME;
TransportTxData.N_PDU_FF.N_PCI.FF_DL_H = ( uint8_t )((TpCtrl.TotalLen >> 8) & 0x000F);
TransportTxData.N_PDU_FF.N_PCI.FF_DL_L = ( uint8_t )(TpCtrl.TotalLen & 0x00FF);
TransportTxData.N_PDU_FF.DLC = 8;
for ( i = 0; i < 6; i++ )
TransportTxData.N_PDU_FF.N_Data [ i ] = N_USDataTxBuffer.MsgData [ i ];
}
DoCAN_Start_Timer(TIMING_PARA_N_As); // 启动N_As计时
DoCAN_L_Data_Request(TransportTxData.Frame.Identifier, TransportTxData.Frame.DLC, ( uint8_t * )TransportTxData.Frame.Data);
TpCtrl.Process = TP_TX_INIT; // 数据帧已发出,等待发送完成
DoCAN_L_Data_Confirm(TransportTxData.Frame.Identifier, COMPLETE);
}
/******************************************************************************
函数名:DoCAN_N_USData_Confirm
功 能:该服务函数由网络层发起,用于确认前一次使用N_USData.request服务向
N_TAtype地址发送的数据是否发送完成
The N_USData.confirm service is issued by the network layer. The service
primitive confirms the completion of an N_USData.request service
identified by the address information in N_TAtype.
参 数:N_TAtype :N_USData.confirm服务请求的发送地址
N_Result :N_USData.request服务的传输状态
返回值:无
******************************************************************************/
void DoCAN_N_USData_Confirm(uint16_t N_TAtype, N_ResultEnum N_Result)
{
UDS_N_USData_Confirm(N_TAtype, N_Result);
}
/******************************************************************************
函数名:DoCAN_N_USData_FF_Indication
功 能:该服务函数由网络层发起,用于向上层指示地址为N_TAtype的一组多帧数据的首帧
的到来
The N_USData_FF.indication service is issued by the network layer. The
service primitive indicates to the adjacent upper layer the arrival of
a FirstFrame (FF) of a segmented message received from a peer protocol
entity, identified by the address information N_TAtype.
参 数:N_TAtype :新到的多帧数据首帧的地址信息
Length :新到的多帧数据的总长度
返回值:无
******************************************************************************/
void DoCAN_N_USData_FF_Indication(uint16_t N_TAtype, uint16_t Length)
{
UDS_N_USData_FF_Indication(N_TAtype, Length);
}
/******************************************************************************
函数名:DoCAN_N_USData_Indication
功 能:该服务函数由网络层发起,用于向上层指出由N_TAtype地址发送来的长度为Length
的MessageData数据的传送结果N_Result,并同时传递这一数据
The N_USData.indication service is issued by the network layer. The
service primitive indicates <N_Result> events and delivers
<MessageData> with <Length> bytes received from a peer protocol entity
identified by the address information in N_TAtype to the adjacent upper
layer.
参 数:N_TAtype :接收到的数据地址信息
MessageData :接收到的数据 (仅在N_Result为N_OK时有效)
Length :接收到的数据长度 (仅在N_Result为N_OK时有效)
N_Result :数据的接收结果
返回值:无
******************************************************************************/
void DoCAN_N_USData_Indication(uint16_t N_TAtype, uint8_t *MessageData, uint16_t Length, N_ResultEnum N_Result)
{
UDS_N_USData_Indication(N_TAtype, MessageData, Length, N_Result);
}
/******************************************************************************
下层接口函数
******************************************************************************/
/******************************************************************************
函数名:DoCAN_L_Data_Request
功 能:该服务原语请求向<Identifier>传输特定格式的<Data>数据
The service primitive requests transmission of <Data> that shall be
mapped within specific attributes of the data link protocol data unit
selected by means of <Identifier>.
参 数:Identifier :报文ID
dlc :数据长度
Data :数据<Data>于数据链路层的存放地址
返回值:无
******************************************************************************/
void DoCAN_L_Data_Request(uint16_t Identifier, uint8_t dlc, uint8_t *Data)
{
uint8_t i;
CanTxRxMsg msg_diag_tx;
LinkTxCtrl.Identifier = Identifier;
for ( i = 0; i < dlc; i++ )
{
LinkTxCtrl.Data[i] = *Data;
Data++;
}
for ( i = dlc; i < 8; i++ )
LinkTxCtrl.Data[i] = FILLER_BYTE;
msg_diag_tx.Id = LinkTxCtrl.Identifier;
msg_diag_tx.DLC = 8;
msg_diag_tx.RTR = 0;
msg_diag_tx.IDE = 0;
msg_diag_tx.CacheType = CAN_CacheType_Tx;
for(i =0;i<8;i++)
{
msg_diag_tx.Data[i] = LinkTxCtrl.Data[i] ;
}
CAN_Transmit(CAN0MSG09, &msg_diag_tx);
// Can_Write(&msg);
//CANFD_Ch1_L_Data_Request(LinkTxCtrl.Identifier,8,LinkTxCtrl.Data);
LinkTxCtrl.Busy = 1;
}
/******************************************************************************
函数名:DoCAN_L_Data_Confirm
功 能:该服务原语用于确认具有特定<Identifier>的报文是否发送完成。
<TransferStatus>参数用于传递发送完成与否的状态。
The service primitive confirms the completion of an L_Data.request
service for a specific <Identifier>.The parameter <TransferStatus>
provides the status of the service request.
参 数:Identifier :报文ID
TransferStatus :Not_Complete - 未完成
Complete - 已发送完成
返回值:无
******************************************************************************/
void DoCAN_L_Data_Confirm(uint16_t Identifier, uint8_t TransferStatus)
{
// 如果数据发送成功,收发状态相应改变
if ( (LinkTxCtrl.Identifier == Identifier) && (TransferStatus == COMPLETE) )
{
switch ( TpCtrl.Process )
{
case TP_TX_INIT:
if ( TpCtrl.BlockSize == 1 ) // BlockSize为1,单帧发送成功
{
TpCtrl.Process = TP_IDLE; // 所有数据发送完毕,回到空闲状态
DoCAN_Stop_Timer( ); // 停止计时
DoCAN_N_USData_Confirm(N_USDataTxBuffer.N_TAtype, N_OK);
}
else // BlockSize不为1,首帧发送成功
{
DoCAN_Start_Timer(TIMING_PARA_N_Bs); // 启动N_Bs计时
TpCtrl.Process = TP_TX_RTS; // 等待接收机许可多帧发送
}
break;
case TP_TX_CTS:
if ( TpCtrl.BlockCnt == TpCtrl.BlockSize ) // 最后一帧发送完成
{
TpCtrl.Process = TP_IDLE; // 所有数据发送完毕,回到空闲状态
DoCAN_Stop_Timer( ); // 停止计时
// DoCAN_Start_Timer(TIMING_PARA_N_Bs);
DoCAN_N_USData_Confirm(N_USDataTxBuffer.N_TAtype, N_OK);
}
else
{
// DoCAN_Start_Timer ( TIMING_PARA_N_Bs ); //启动/重启N_Bs计时
if ( TpCtrl.BSMax ) // 还可以继续发送数据帧,则启动STmin计时
{
DoCAN_Stop_Timer( );
DoCAN_Start_STmin_Timer(TpCtrl.STmin);
}
else
{
DoCAN_Start_Timer(TIMING_PARA_N_Bs);
}
}
break;
case TP_RX_RTS:
DoCAN_Start_Timer(TIMING_PARA_N_Cr); // 启动N_Cr计时
TpCtrl.Process = TP_RX_CTS;
break;
case TP_RX_WAIT:
DoCAN_Start_Timer(TIMING_PARA_N_Cr); // 启动N_Cr计时
TpCtrl.Process = TP_RX_CTS;
break;
case TP_RX_OVFL:
TpCtrl.Process = TP_IDLE; // 停止接收过程
DoCAN_Stop_Timer( ); // 停止计时
DoCAN_N_USData_Indication(N_USDataRxBuffer.N_TAtype, N_USDataRxBuffer.MsgData,
N_USDataRxBuffer.Length, N_ERROR);
break;
default:
break;
}
}
}
/******************************************************************************
函数名:DoCAN_L_Data_Indication
功 能:该服务原语标示一个数据链路层事件到相邻上层并根据<Identifier>传送<Data>
The service primitive indicates a data link layer event to the adjacent
upper layer and delivers <Data> identified by <Identifier>
参 数:Identifier :报文ID
dlc :数据长度
pData :数据<Data>于数据链路层的存放地址
返回值:无
******************************************************************************/
void DoCAN_L_Data_Indication(uint16_t Identifier, uint32_t dlc, uint8_t *pData)
{
uint8_t i;
if ( LinkRxFIFO.Depth >= LINK_RX_FIFO_MAX_DEPTH ) // FIFO未满时装入报文,否则抛弃报文
{
#if DOCAN_DEBUG_EN
LINK_RX_FIFO_OVERFLOW_INDICATOR( );
#endif
return;
}
LinkRxFIFO.LinkData [ LinkRxFIFO.IPtr ].Identifier = Identifier; // 装入报文ID
for ( i = 0; i < dlc; i++ ) // 拷贝报文
LinkRxFIFO.LinkData [ LinkRxFIFO.IPtr ].Data [ i ] = *(pData + i);
LinkRxFIFO.LinkData [ LinkRxFIFO.IPtr ].DLC = dlc; // 保存报文长度
LinkRxFIFO.Depth++; // 新报文装入,深度+1
LinkRxFIFO.IPtr++; // 输入指针+1
if ( LinkRxFIFO.IPtr >= LINK_RX_FIFO_MAX_DEPTH )
LinkRxFIFO.IPtr = 0;
}
/******************************************************************************
传输层协议解析
******************************************************************************/
/******************************************************************************
函数名:DoCAN_Receive_And_Assemble_N_USData();
功 能:接收N_PDU并重组数据
参 数:无
返回值:无
******************************************************************************/
void DoCAN_Receive_And_Assemble_N_USData(void)
{
DoCAN_Get_N_PDU( );
if ( TransportRxData.N_PDU.New )
{
switch ( TransportRxData.N_PDU.N_PCI.Type )
{
case SINGLE_FRAME:
DoCAN_Receive_Single_Frame_N_Data( );
break;
case FIRST_FRAME:
DoCAN_Receive_First_Frame_N_Data( );
DoCAN_Transmit_Flow_Control( ); // 首帧发送完毕后必须发送流控帧
break;
case CONSECUTIVE_FRAME:
DoCAN_Receive_Consecutive_Frame_N_Data( );
DoCAN_Transmit_Flow_Control( ); // 当接收满一个BlockSize时,需要发送流控帧
break;
case FLOW_CONTROL:
DoCAN_Receive_Flow_Control( );
break;
default:
DoCAN_Handle_Unknown_N_PDU( );
break;
}
TransportRxData.N_PDU_FC.New = 0;
}
}
/******************************************************************************
函数名:DoCAN_Get_N_PDU
功 能:从数据链路层获取N_PDU(network protocol data unit)
参 数:无
返回值:无
******************************************************************************/
void DoCAN_Get_N_PDU(void)
{
uint8_t i;
if ( LinkRxFIFO.Depth ) // FIFO中有数据
{
TransportRxData.Frame.Identifier = LinkRxFIFO.LinkData [ LinkRxFIFO.OPtr ].Identifier; // 取出ID
for ( i = 0; i < 8; i++ ) // 拷贝报文
TransportRxData.Frame.Data [ i ] = LinkRxFIFO.LinkData [ LinkRxFIFO.OPtr ].Data [ i ];
TransportRxData.Frame.DLC = LinkRxFIFO.LinkData [ LinkRxFIFO.OPtr ].DLC; // 取出报文长度
TransportRxData.Frame.New = 1;
LinkRxFIFO.Depth--; // 报文已取出,深度-1
LinkRxFIFO.OPtr++; // 输出指针+1
if ( LinkRxFIFO.OPtr >= LINK_RX_FIFO_MAX_DEPTH )
LinkRxFIFO.OPtr = 0;
}
}
/******************************************************************************
函数名:DoCAN_Receive_Single_Frame_N_Data
功 能:单帧数据接收
参 数:无
返回值:无
******************************************************************************/
void DoCAN_Receive_Single_Frame_N_Data(void)
{
uint8_t i;
if ( (TpCtrl.Process & TP_DIR_MASK) == TP_TX ) // 发送中不接收
return;
/*---------------------------------------------------------------------------
Whether the interleaving Tester Present messages would lead to a loss of CF
or termination of the reception of an ongoing multiple frame request
2018.11.29
---------------------------------------------------------------------------*/
if ( (TpCtrl.Process != TP_IDLE) && (TransportRxData.N_PDU_SF.N_TAtype != DIAG_ID_Rx_PHY) )
return;
/*---------------------------------------------------------------------------
Tester sends a Single frame with a CAN-DLC shorter and equal to the transport
protocol data length field. ECU must not send a response.
2018.11.28添加长度还要等于8
---------------------------------------------------------------------------*/
if ( (TransportRxData.N_PDU_SF.DLC <= TransportRxData.N_PDU_SF.N_PCI.SF_DL) || (TransportRxData.N_PDU_SF.DLC != 8) )
return;
/*---------------------------------------------------------------------------
Tester sends a Single frame with a data length that is not allowed by the
protocol. ECU must not send a response.
---------------------------------------------------------------------------*/
if ( (TransportRxData.N_PDU_SF.N_PCI.SF_DL == 0) || (TransportRxData.N_PDU_SF.N_PCI.SF_DL > 7) )
return;
N_USDataRxBuffer.N_TAtype = TransportRxData.N_PDU_SF.N_TAtype;
N_USDataRxBuffer.Length = TransportRxData.N_PDU_SF.N_PCI.SF_DL;
for ( i = 0; i < N_USDataRxBuffer.Length; i++ )
N_USDataRxBuffer.MsgData [ i ] = TransportRxData.N_PDU_SF.N_Data [ i ];
TpCtrl.Process = TP_IDLE; // 接收完成,回到IDLE状态
DoCAN_Stop_Timer( );
DoCAN_N_USData_Indication(N_USDataRxBuffer.N_TAtype, N_USDataRxBuffer.MsgData,
N_USDataRxBuffer.Length, N_OK);
}
/******************************************************************************
函数名:DoCAN_Receive_First_Frame_N_Data
功 能:接收首帧数据并初始化多帧数据接收
参 数:无
返回值:无
******************************************************************************/
void DoCAN_Receive_First_Frame_N_Data(void)
{
uint8_t i;
uint16_t Len;
if ( (TpCtrl.Process & TP_DIR_MASK) == TP_TX ) // 发送中不接收
return;
/*-----------------------------------------------------------------------------
Tester sends a functional addressed First frame. ECU must not send a response.
-----------------------------------------------------------------------------*/
if ( TransportRxData.N_PDU_FF.N_TAtype != DIAG_ID_Rx_PHY )
return;
/*---------------------------------------------------------------------------
(8.3) A FirstFrame protocol data unit (FF N_PDU), containing the first six
data bytes
---------------------------------------------------------------------------*/
if ( TransportRxData.N_PDU_FF.DLC != 8 ) // 首帧总长(N_PCI + N_Data)应为8
return;
/*---------------------------------------------------------------------------
Tester sends a First frame with Data length set to 0. ECU must not send a
response.
-----------------------------------------------------------------------------
(8.5.3.3) If the network layer receives an FF with an FF_DL that is less than
eight when using normal addressing, then the network layer shall ignore the
received FF N_PDU and not transmit an FC N_PDU.
---------------------------------------------------------------------------*/
Len = ( uint16_t )(TransportRxData.N_PDU_FF.N_PCI.FF_DL_H);
Len <<= 8;
Len |= ( uint16_t )(TransportRxData.N_PDU_FF.N_PCI.FF_DL_L);
if ( Len < 8 )
return;
/*---------------------------------------------------------------------------
Tester sends a First frame of a segmented request. After the receipt of the
ECU Flow Control the Tester sends another segmented request. The ECU must
send a response for the second request.
---------------------------------------------------------------------------*/
#if ( N_MAX_BS )
TpCtrl.NonStopMode = 0;
#else
TpCtrl.NonStopMode = 1;
#endif
TpCtrl.Len = 6; // 首帧接收6字节
TpCtrl.TotalLen = Len; // 记录字节总数
TpCtrl.BlockCnt = 1; // 首帧接收1个block
TpCtrl.BSMax = N_MAX_BS; // 装入最大的BS数
TpCtrl.WFTCnt = N_WFTmax; // 装入最大等待次数
// 首帧含6字节数据,连续帧含7字节数据,根据字节数计算Block总数
if ( (TpCtrl.TotalLen + 1) % 7 )
TpCtrl.BlockSize = (TpCtrl.TotalLen + 8) / 7; // 等效于(TpCtrl.TotalLen + 1) / 7 + 1
else
TpCtrl.BlockSize = (TpCtrl.TotalLen + 1) / 7;
// 开始接收首帧数据
N_USDataRxBuffer.N_TAtype = TransportRxData.N_PDU_FF.N_TAtype;
N_USDataRxBuffer.Length = Len;
for ( i = 0; i < 6; i++ )
N_USDataRxBuffer.MsgData [ i ] = TransportRxData.N_PDU_FF.N_Data [ i ];
DoCAN_Start_Timer(TIMING_PARA_N_Br); // 启动N_Br计时
TpCtrl.Process = TP_RX_INIT;
DoCAN_N_USData_FF_Indication(N_USDataRxBuffer.N_TAtype, N_USDataRxBuffer.Length);
}
/******************************************************************************
函数名:DoCAN_Receive_Consecutive_Frame_N_Data
功 能:接收连接帧数据
参 数:无
返回值:无
******************************************************************************/
void DoCAN_Receive_Consecutive_Frame_N_Data(void)
{
uint8_t i;
/*---------------------------------------------------------------------------
Tester sends a request with a response that is longer than one frame. After
the Flow control the Tester sends a Consecutive frame. ECU must send a
diagnostic response for the first request. ECU must not send a response
for the Consecutive frame.
-----------------------------------------------------------------------------
Tester sends a single Consecutive frame. The ECU must not send a response.
---------------------------------------------------------------------------*/
if ( TpCtrl.Process != TP_RX_CTS )
return;
if ( TransportRxData.N_PDU_CF.N_TAtype != DIAG_ID_Rx_PHY )
return;
/*---------------------------------------------------------------------------
Send a request which requires more than 4 frames. Drop the third consecutive
frame (CF). The ECU should not respond.
-----------------------------------------------------------------------------
Send a multi frame message to the ECU. Send the first consecutive frame (CF)
twice. No response is expected.
---------------------------------------------------------------------------*/
if ( TransportRxData.N_PDU_CF.N_PCI.SN != ( uint8_t )(TpCtrl.BlockCnt & 0x000F) )
{
TpCtrl.Process = TP_IDLE; // 停止接收过程
DoCAN_Stop_Timer( ); // 停止计时
DoCAN_N_USData_Indication(N_USDataRxBuffer.N_TAtype, N_USDataRxBuffer.MsgData,
N_USDataRxBuffer.Length, N_WRONG_SN);
return;
}
TpCtrl.BlockCnt++; // 接收到1个Block
TpCtrl.BSMax--;
if ( TpCtrl.BlockCnt < TpCtrl.BlockSize ) // 此次接收不是最后一帧
{
if ( TransportRxData.N_PDU_CF.DLC != 8 ) // 此时连续帧总长(N_PCI + N_Data)应为8
return;
for ( i = 0; i < 7; i++ )
{
N_USDataRxBuffer.MsgData [ TpCtrl.Len ] = TransportRxData.N_PDU_CF.N_Data [ i ];
TpCtrl.Len++;
}
DoCAN_Start_Timer(TIMING_PARA_N_Cr); // 重启N_Cr计时
}
else // 此次接收是最后一帧
{
/*-------------------------------------------------------------------------
In a segmented request the Tester sends a Consecutive frame with a CAN-DLC
shorter or equal to transport protocol data length field. ECU must not send
a response.
-------------------------------------------------------------------------*/
if ( (TransportRxData.N_PDU_CF.DLC <= TpCtrl.TotalLen - TpCtrl.Len) || (TransportRxData.N_PDU_CF.DLC != 8) ) // 此时连续帧总长应不小于剩余数据长度
return;
i = 0;
while ( TpCtrl.Len < TpCtrl.TotalLen )
{
N_USDataRxBuffer.MsgData [ TpCtrl.Len ] = TransportRxData.N_PDU_CF.N_Data [ i ];
i++;
TpCtrl.Len++;
}
TpCtrl.Process = TP_IDLE; // 接收完成,回到IDLE状态
DoCAN_Stop_Timer( );
DoCAN_N_USData_Indication(N_USDataRxBuffer.N_TAtype, N_USDataRxBuffer.MsgData,
N_USDataRxBuffer.Length, N_OK);
}
}
/******************************************************************************
函数名:DoCAN_Receive_Flow_Control
功 能:接收流控帧数据
参 数:无
返回值:无
******************************************************************************/
void DoCAN_Receive_Flow_Control(void)
{
/*--------------------------------------------------------------------------
Tester sends a segmented request interrupted by a Flow control after the ECU
Flow control. After that the Tester sends the remaining consecutive frames.
ECU should send a diagnostic response for the request.
-----------------------------------------------------------------------------
Tester sends a single Flow Control. The ECU must not send a response.
---------------------------------------------------------------------------*/
if ( (TpCtrl.Process != TP_TX_RTS) && (TpCtrl.Process != TP_TX_CTS) && (TpCtrl.Process != TP_TX_WAIT) )
return;
/*---------------------------------------------------------------------------
Tester sends a request with a response that is longer than one frame. After
the First frame is received the Tester sends a functional addressed Flow
control. ECU must abort sending of the response.
---------------------------------------------------------------------------*/
if ( TransportRxData.N_PDU_FC.N_TAtype != DIAG_ID_Rx_PHY )
{
DoCAN_N_USData_Confirm(N_USDataTxBuffer.N_TAtype, N_ERROR);
DoCAN_Stop_Timer( ); // 停止计时
TpCtrl.Process = TP_IDLE; // 中止数据发送,回到空闲状态
return;
}
/*---------------------------------------------------------------------------
Tester sends a Flow control with a too short CAN-DLC for a response that is
longer than one frame. ECU must not send Consecutive frames. After that the
tester sends a new request. ECU must send a response for the last request.
---------------------------------------------------------------------------*/
if ( TransportRxData.N_PDU_FC.DLC != 8 )
{
DoCAN_N_USData_Confirm(N_USDataTxBuffer.N_TAtype, N_ERROR);
DoCAN_Stop_Timer( ); // 停止计时
TpCtrl.Process = TP_IDLE; // 中止数据发送,回到空闲状态
return;
}
switch ( TransportRxData.N_PDU_FC.N_PCI.FS )
{
case FC_FS_CTS:
if ( TpCtrl.NonStopMode )
break;
/*-------------------------------------------------------
Tester sends a Flow control with Blocksize 0 for a
response that is longer than one frame. ECU must send the
complete response.
---------------------------------------------------------
Tester sends a Flow control with Blocksize 0 for a
response that is longer than one frame. ECU must send the
complete response without waiting for another Flow
control. Tester verifies that every Consecutive frame is
received within TimeoutCr.
-------------------------------------------------------*/
if ( TransportRxData.N_PDU_FC.N_PCI.BS == 0 )
TpCtrl.NonStopMode = 1;
/*-------------------------------------------------------
Tester sends a Flow control with a special Blocksize for
a response that is longer than one frame. ECU must send
the number of Consecutive frames that matches the
blocksize. Blocksize 1, 8 and 20 is checked if the
response is long enough.
-------------------------------------------------------*/
else
TpCtrl.BSMax = TransportRxData.N_PDU_FC.N_PCI.BS;
/*-------------------------------------------------------
Tester sends a Flow control for a response that is longer
than one frame. ECU must send the complete response.
Tester verifies that the time between the Consecutive
Frames is not below STMin time. This is tested for STMin
values 1,10,20,30,40,50 and 60.
-------------------------------------------------------*/
if ( TpCtrl.Process != TP_TX_CTS )
{
if(TransportRxData.N_PDU_FC.N_PCI.STmin == 0)
{
TpCtrl.STmin = 1;
}
else
{
TpCtrl.STmin = TransportRxData.N_PDU_FC.N_PCI.STmin;
}
}
/*-------------------------------------------------------
Request a service where the response requires more than
one response frame. Tester sends two Flow Controls (FC)
instead of one. A response from the ECU is expected.
-------------------------------------------------------*/
TpCtrl.Process = TP_TX_CTS; // 发送机被许可发送
DoCAN_Stop_Timer( );
DoCAN_Start_STmin_Timer(TpCtrl.STmin); // 启动STmin计时
break;
case FC_FS_WAIT:
if ( TpCtrl.NonStopMode )
break;
/*-------------------------------------------------------
Tester sends a Flow control with Status value wait (WT)
for a response that is longer than one frame. ECU must
not send Consecutive frames. After the N_Bs Timeout the
Tester sends another Flow control with status continue to
send (CTS). Then the tester sends a new request. ECU must
send a response for the last request.
-------------------------------------------------------*/
TpCtrl.Process = TP_TX_WAIT; // 接收机请求发送机等待
DoCAN_Start_Timer(TIMING_PARA_N_Bs); // 启动/重启N_Bs计时
break;
case FC_FS_OVFL:
if ( TpCtrl.NonStopMode )
break;
/*-------------------------------------------------------
Tester sends a Flow control with status overflow for a
response that is longer than one frame. ECU must not send
Consecutive frame(s).
---------------------------------------------------------
Tester sends a request with a response that is longer
than one frame. After sending the Flow control the Tester
receives the first Consecutive frame and sends another
Flow control with status overflow (OVFLW). ECU must send
a diagnostic response for the first request. ECU must not
send a response for the Flow control.
-------------------------------------------------------*/
if ( TpCtrl.Process == TP_TX_RTS )
{
DoCAN_N_USData_Confirm(N_USDataTxBuffer.N_TAtype, N_BUFFER_OVFLW);
DoCAN_Stop_Timer( ); // 停止计时
TpCtrl.Process = TP_IDLE; // 中止数据发送,回到空闲状态
}
break;
default: /*-------------------------------------------------------
Tester sends a Flow control with an invalid Status value
(3-15) for a response that is longer than one frame. ECU
must not send a response.
-------------------------------------------------------*/
DoCAN_N_USData_Confirm(N_USDataTxBuffer.N_TAtype, N_INVALID_FS);
DoCAN_Stop_Timer( ); // 停止计时
TpCtrl.Process = TP_IDLE; // 中止数据发送,回到空闲状态
break;
}
}
/******************************************************************************
函数名:DoCAN_Transmit_Flow_Control
功 能:根据当前的接收机状态发送流控帧
参 数:无
返回值:无
******************************************************************************/
void DoCAN_Transmit_Flow_Control(void)
{
if ( TpCtrl.Process == TP_RX_INIT )
{
/*-------------------------------------------------------------------------
(8.5.3.3) If the network layer receives an FF with an FF_DL that is greater
than the available receiver buffer size, then this shall be considered as
an error condition. The network layer shall abort the message reception and
send an FC N_PDU with the parameter FlowStatus = Overflow.
-------------------------------------------------------------------------*/
if ( N_USDataRxBuffer.Length > N_USDATA_RX_BUFFER_SIZE )
{
TransportTxData.N_PDU_FC.N_PCI.FS = FC_FS_OVFL;
TpCtrl.Process = TP_RX_OVFL;
}
else
{
TransportTxData.N_PDU_FC.N_PCI.FS = FC_FS_CTS;
TpCtrl.Process = TP_RX_RTS;
}
}
else if ( TpCtrl.Process == TP_RX_CTS )
{
if ( TpCtrl.BSMax ) // 仍然没有接收满一个BS的N_PDU
return;
if ( TpCtrl.NonStopMode ) // 如果是连续接收模式(BS本来就是0)
return;
/*
if (0) //如果满足等待条件,则发送等待FC帧
{
if(TpCtrl.WFTCnt == 0)
{
TpCtrl.Process = TP_IDLE;
DoCAN_Stop_Timer();
DoCAN_N_USData_Indication(N_USDataRxBuffer.N_TAtype, N_USDataRxBuffer.MsgData, \
N_USDataRxBuffer.Length, N_WFT_OVRN);
return;
}
TpCtrl.WFTCnt--;
TransportTxData.N_PDU_FC.N_PCI.FS = FC_FS_WAIT;
}*/
TpCtrl.BSMax = N_MAX_BS; // 重新装入最大的BS数
TransportTxData.N_PDU_FC.N_PCI.FS = FC_FS_CTS;
TpCtrl.Process = TP_RX_RTS; // 等待RTS发送完成
}
else
return;
TransportTxData.N_PDU_FC.N_TAtype = DIAG_ID_Tx;
TransportTxData.N_PDU_FC.N_PCI.Type = FLOW_CONTROL;
TransportTxData.N_PDU_FC.N_PCI.BS = 0;
/*---------------------------------------------------------------------------
Tester sends a segmented request to check for a valid STMin time in the ECU
Flow control. The STMin time value must be within 0x01-0x7F or 0xF1-0xF9.
---------------------------------------------------------------------------*/
TransportTxData.N_PDU_FC.N_PCI.STmin = N_STmin;
TransportTxData.N_PDU_FC.DLC = 3;
DoCAN_Start_Timer(TIMING_PARA_N_Ar); // 启动N_Ar计时
DoCAN_L_Data_Request(TransportTxData.Frame.Identifier, TransportTxData.Frame.DLC, ( uint8_t * )TransportTxData.Frame.Data);
DoCAN_L_Data_Confirm(TransportTxData.Frame.Identifier, COMPLETE);
}
/******************************************************************************
函数名:DoCAN_Handle_Unknown_N_PDU
功 能:处理接收到的未知类型的N_PDU
参 数:无
返回值:无
******************************************************************************/
void DoCAN_Handle_Unknown_N_PDU(void)
{
}
/******************************************************************************
函数名:DoCAN_Disassemble_And_Transmit_N_USData
功 能:将数据拆分为连续帧(CF)并发送出去
参 数:无
返回值:无
******************************************************************************/
void DoCAN_Disassemble_And_Transmit_N_USData(void)
{
uint8_t i;
uint8_t Len;
if ( TpCtrl.Process != TP_TX_CTS ) // 未被许可时不可以发送连续帧
return;
// 仅在STmin计时时间到后发送一次
if ( DoCAN_Get_STmin_Timer_Status( ) == STmin_TIME_UP )
{
TransportTxData.N_PDU_CF.N_TAtype = N_USDataTxBuffer.N_TAtype;
TransportTxData.N_PDU_CF.N_PCI.Type = CONSECUTIVE_FRAME;
TransportTxData.N_PDU_CF.N_PCI.SN = ( uint8_t )(TpCtrl.BlockCnt & 0x000F);
// 当BSMax减小到0时,链路层数据发送完毕后,将不会再启动STmin计数器(详情见DoCAN_L_Data_Confirm函数)
// 因此STmin_TIME_UP状态将不会再出现,从而停止了连续帧的发送
// 直到有新的CF帧到来给BSMax赋予新值,或N_Bs计时超时
TpCtrl.BSMax--;
TpCtrl.BlockCnt++;
if ( TpCtrl.BlockCnt < TpCtrl.BlockSize ) // 将要发送的不是最后一帧
{
TransportTxData.N_PDU_CF.DLC = 8;
for ( i = 0; i < 7; i++ )
{
TransportTxData.N_PDU_CF.N_Data [ i ] = N_USDataTxBuffer.MsgData [ TpCtrl.Len ];
TpCtrl.Len++;
}
}
else if ( TpCtrl.BlockCnt == TpCtrl.BlockSize ) // 将要发送最后一帧
{
Len = ( uint8_t )(TpCtrl.TotalLen - TpCtrl.Len);
TransportTxData.N_PDU_CF.DLC = Len + 1;
for ( i = 0; i < Len; i++ )
{
TransportTxData.N_PDU_CF.N_Data [ i ] = N_USDataTxBuffer.MsgData [ TpCtrl.Len ];
TpCtrl.Len++;
}
}
else // 已发送帧数不可能大于帧总数,除非有错误发生
{
DoCAN_Stop_Timer( ); // 停止计时
TpCtrl.Process = TP_IDLE; // 中止数据发送,回到空闲状态
DoCAN_N_USData_Confirm(N_USDataTxBuffer.N_TAtype, N_ERROR);
return;
}
DoCAN_Start_Timer(TIMING_PARA_N_As); // 启动N_As计时
DoCAN_L_Data_Request(TransportTxData.Frame.Identifier, TransportTxData.Frame.DLC, ( uint8_t * )TransportTxData.Frame.Data);
DoCAN_L_Data_Confirm(TransportTxData.Frame.Identifier, COMPLETE);
}
}
/******************************************************************************
传输层时序管理
******************************************************************************/
/******************************************************************************
函数名:DoCAN_Update_Timer
功 能:定时器更新函数
参 数:无
返回值:无
******************************************************************************/
void DoCAN_Update_Timer(void)
{
uint16_t CurrentCnt;
uint16_t Dec;
CurrentCnt = TpTimingCtrl.Cnt;
if ( CurrentCnt != TpTimingCtrl.LastCnt ) // 定时器计数值有更新
{
if ( CurrentCnt > TpTimingCtrl.LastCnt )
Dec = CurrentCnt - TpTimingCtrl.LastCnt;
else
Dec = 65535 - TpTimingCtrl.LastCnt + 1 + CurrentCnt;
TpTimingCtrl.LastCnt = CurrentCnt;
if ( TpTimingCtrl.Type != TIMING_PARA_NONE )
{
if ( TpTimingCtrl.NTimer )
{
if ( TpTimingCtrl.NTimer > ( uint32_t )Dec )
TpTimingCtrl.NTimer -= Dec;
else
TpTimingCtrl.NTimer = 0;
}
}
if ( TpTimingCtrl.STminStatus == STmin_TIMING )
{
if ( TpTimingCtrl.STimer )
{
if ( TpTimingCtrl.STimer > ( uint32_t )Dec )
TpTimingCtrl.STimer -= Dec;
else
TpTimingCtrl.STimer = 0;
}
if ( TpTimingCtrl.STimer == 0 )
TpTimingCtrl.STminStatus = STmin_TIME_UP;
}
}
}
/******************************************************************************
函数名:DoCAN_Handle_Time_Out
功 能:超时处理
参 数:无
返回值:无
******************************************************************************/
void DoCAN_Handle_Time_Out(void)
{
if ( TpTimingCtrl.NTimer == 0 ) // 计时超时
{
switch ( TpTimingCtrl.Type )
{
case TIMING_PARA_N_As:
if ( TpCtrl.Process != TP_IDLE )
{
TpCtrl.Process = TP_IDLE; // 中止数据收发,回到空闲状态
DoCAN_N_USData_Confirm(N_USDataTxBuffer.N_TAtype, N_TIMEOUT_A);
}
break;
case TIMING_PARA_N_Ar:
if ( TpCtrl.Process != TP_IDLE )
{
TpCtrl.Process = TP_IDLE; // 中止数据收发,回到空闲状态
DoCAN_N_USData_Indication(N_USDataRxBuffer.N_TAtype, N_USDataRxBuffer.MsgData,
N_USDataRxBuffer.Length, N_TIMEOUT_A);
}
break;
case TIMING_PARA_N_Bs:
if ( TpCtrl.Process != TP_IDLE )
{
TpCtrl.Process = TP_IDLE; // 中止数据发送,回到空闲状态
DoCAN_N_USData_Confirm(N_USDataTxBuffer.N_TAtype, N_TIMEOUT_Bs);
}
break;
case TIMING_PARA_N_Br:
if ( TpCtrl.Process != TP_IDLE )
{
TpCtrl.Process = TP_IDLE; // 中止数据收发,回到空闲状态
DoCAN_N_USData_Indication(N_USDataRxBuffer.N_TAtype, N_USDataRxBuffer.MsgData,
N_USDataRxBuffer.Length, N_ERROR);
}
break;
case TIMING_PARA_N_Cs:
if ( TpCtrl.Process != TP_IDLE )
{
TpCtrl.Process = TP_IDLE; // 中止数据收发,回到空闲状态
DoCAN_N_USData_Confirm(N_USDataTxBuffer.N_TAtype, N_ERROR);
}
break;
case TIMING_PARA_N_Cr:
if ( TpCtrl.Process != TP_IDLE )
{
TpCtrl.Process = TP_IDLE; // 中止数据接收,回到空闲状态
DoCAN_N_USData_Indication(N_USDataRxBuffer.N_TAtype, N_USDataRxBuffer.MsgData,
N_USDataRxBuffer.Length, N_TIMEOUT_Cr);
}
break;
default:
break;
}
DoCAN_Stop_Timer( ); // 停止计时
}
}
/******************************************************************************
函数名:DoCAN_Start_Timer
功 能:启动时序定时器
参 数:TimingParameter :时序参数,可以是下列参数中的一种
TIMING_PARA_N_As
TIMING_PARA_N_Ar
TIMING_PARA_N_Bs
TIMING_PARA_N_Br
TIMING_PARA_N_Cs
TIMING_PARA_N_Cr
返回值:无
******************************************************************************/
void DoCAN_Start_Timer(uint8_t TimingParameter)
{
switch ( TimingParameter )
{
case TIMING_PARA_N_As:
TpTimingCtrl.Type = TIMING_PARA_N_As;
TpTimingCtrl.NTimer = N_As * 1000;
break;
case TIMING_PARA_N_Ar:
TpTimingCtrl.Type = TIMING_PARA_N_Ar;
TpTimingCtrl.NTimer = N_Ar * 1000;
break;
case TIMING_PARA_N_Bs:
TpTimingCtrl.Type = TIMING_PARA_N_Bs;
TpTimingCtrl.NTimer = N_Bs * 1000;
break;
case TIMING_PARA_N_Br:
TpTimingCtrl.Type = TIMING_PARA_N_Br;
TpTimingCtrl.NTimer = N_Br * 1000;
break;
case TIMING_PARA_N_Cs:
TpTimingCtrl.Type = TIMING_PARA_N_Cs;
TpTimingCtrl.NTimer = N_Cs * 1000;
break;
case TIMING_PARA_N_Cr:
TpTimingCtrl.Type = TIMING_PARA_N_Cr;
TpTimingCtrl.NTimer = N_Cr * 1000;
break;
default:
TpTimingCtrl.Type = TIMING_PARA_NONE;
TpTimingCtrl.NTimer = 0;
break;
}
}
/******************************************************************************
函数名:DoCAN_Stop_Timer
功 能:停止时序定时器
参 数:无
返回值:无
******************************************************************************/
void DoCAN_Stop_Timer(void)
{
TpTimingCtrl.Type = TIMING_PARA_NONE;
}
/******************************************************************************
函数名:DoCAN_Start_STmin_Timer
功 能:启动STmin定时器
参 数:STminTime:STmin时间
返回值:无
******************************************************************************/
void DoCAN_Start_STmin_Timer(uint8_t STminTime)
{
if ( STminTime <= 0x7F ) // 0x00 - 0x7F:0ms - 127ms
TpTimingCtrl.STimer = ( uint32_t )STminTime * 1000;
else if ( (STminTime >= 0xF1) && (STminTime <= 0xF9) ) // 0xF1 - 0xF9:100us - 900us
TpTimingCtrl.STimer = ( uint32_t )(STminTime & 0x0F) * 100;
else // Reserved :127ms
TpTimingCtrl.STimer = 127000;
TpTimingCtrl.STminStatus = STmin_TIMING; // STmin开始计时
}
/******************************************************************************
函数名:DoCAN_Get_STmin_Timer_Status
功 能:获取当前STmin定时器的状态
参 数:无
返回值:STmin_TIMER_IDLE:STmin定时器空闲
STmin_TIME_UP :STmin定时时间到
STmin_TIMING :STmin定时器计时中
******************************************************************************/
uint8_t DoCAN_Get_STmin_Timer_Status(void)
{
uint8_t Status;
Status = TpTimingCtrl.STminStatus;
if ( Status == STmin_TIME_UP )
TpTimingCtrl.STminStatus = STmin_TIMER_IDLE;
return Status;
}
/******************************************************************************
文 件 名:DoCAN_ISO15765.h
功能描述:ISO 15765 规范规定的诊断服务函数头文件
作 者:张暄
版 本:V1.0
日 期:2016.7.18
******************************************************************************/
/******************************************************************************
诊断服务的OSI模型映射
===============================================================================
* NO. OSI Layer Diagnostics services
-------------------------------------------------------------------------------
7 Application ISO 14229-1 ISO 14229-3
6 Presentation -
5 Session ISO 14229-2
* 4 Transport ISO 15765-2
* 3 Network ISO 15765-2
2 Data Link ISO 11898
1 Physical ISO 11898
===============================================================================
******************************************************************************/
#ifndef _DOCAN_ISO15765_H_
#define _DOCAN_ISO15765_H_
#include "stdint.h"
#include "UDS_ISO14229_Server.h"
#include "DoCAN_ISO15765_Config.h"
/*-----------------------------------------------------------------------------
Transfer_Status
-----------------------------------------------------------------------------*/
#ifndef COMPLETE
#define COMPLETE 0x00
#endif
#ifndef NOT_COMPLETE
#define NOT_COMPLETE (! COMPLETE)
#endif
/*-----------------------------------------------------------------------------
N_PDU 名称
-----------------------------------------------------------------------------*/
#define SINGLE_FRAME 0x00
#define FIRST_FRAME 0x01
#define CONSECUTIVE_FRAME 0x02
#define FLOW_CONTROL 0x03
/*-----------------------------------------------------------------------------
流控帧类型
-----------------------------------------------------------------------------*/
#define FC_FS_CTS 0x00
#define FC_FS_WAIT 0x01
#define FC_FS_OVFL 0x02
/*-----------------------------------------------------------------------------
时序参数名称
-----------------------------------------------------------------------------*/
#define TIMING_PARA_NONE 0X00
#define TIMING_PARA_N_As 0X01
#define TIMING_PARA_N_Ar 0X02
#define TIMING_PARA_N_Bs 0X03
#define TIMING_PARA_N_Br 0X04
#define TIMING_PARA_N_Cs 0X05
#define TIMING_PARA_N_Cr 0X06
/*-----------------------------------------------------------------------------
STmin计时状态
-----------------------------------------------------------------------------*/
#define STmin_TIMER_IDLE 0X00 // STmin定时器空闲
#define STmin_TIME_UP 0X01 // STmin定时时间到
#define STmin_TIMING 0X02 // STmin定时器计时中
/*-----------------------------------------------------------------------------
传输层收发控制
-----------------------------------------------------------------------------*/
#define TP_DIR_MASK 0x80 // 收发标志位
#define TP_RX 0x00 // 传输层接收状态
#define TP_TX 0x80 // 传输层发送状态
#define TP_IDLE 0x00 // Rx:空闲状态
// Tx:空闲状态
#define TP_ERR 0x01 // Rx:接收系统错误
// Tx:发送系统错误
#define TP_RX_INIT 0x10 // Rx:已接收到首帧,初始化多帧接收
#define TP_TX_INIT 0x90 // Tx:发送初始化完成,正在发送首帧或单帧(注意单帧也使用此标志)
#define TP_RX_CTS 0x11 // Rx:接收机允许发送机发送连续帧(Clear To Send)
#define TP_TX_CTS 0x91 // Tx:发送机被许可发送连续帧(Clear To Send)
#define TP_RX_RTS 0x20 // Rx:请求继续发送多帧(Request To Send)
#define TP_TX_RTS 0xA0 // Tx:等待接收机许可多帧发送(Request To Send)
#define TP_RX_WAIT 0x21 // Rx:请求发送机暂停发送
#define TP_TX_WAIT 0xA1 // Tx:接收机请求等待
#define TP_RX_OVFL 0x22 // Rx:接收机接收溢出
#define TP_TX_OVFL 0xA2 // Tx:接收机接收溢出
/******************************************************************************
结构体声明
******************************************************************************/
/*** 链路层数据帧结构 ***/
typedef struct
{
uint16_t Identifier; // 帧ID
uint8_t Data [ 8 ]; // 帧数据
uint8_t DLC; // 帧长度
} LinkDataStruct;
/*** 链路层接收FIFO结构 ***/
typedef struct
{
LinkDataStruct LinkData [ LINK_RX_FIFO_MAX_DEPTH ];
uint8_t Depth; // FIFO深度
uint8_t IPtr; // 输入指针
uint8_t OPtr; // 输出指针
} LinkRxFIFOStruct;
/*** 链路层发送控制结构 ***/
typedef struct
{
uint16_t Identifier; // 帧ID
uint8_t Data [ 8 ]; // 帧数据
uint8_t Busy; // 发送器忙标志
} LinkTxCtrlStruct;
/*---------------------------------------------------------------------------*/
/*** 传输层数据帧结构 ***/
typedef struct
{
uint16_t Identifier;
uint8_t Data [ 8 ];
uint8_t DLC;
uint8_t New;
} TP_Data_Struct;
/*** 通用N_PCI解析结构 ***/
typedef struct
{
uint8_t Rsvd : 4;
uint8_t Type : 4;
} TP_N_PCI_Struct;
/*** 通用N_PDU解析结构 ***/
typedef struct
{
uint16_t N_TAtype;
TP_N_PCI_Struct N_PCI;
uint8_t N_Data [ 7 ];
uint8_t DLC;
uint8_t New;
} TP_N_PDU_Struct;
/*** 单帧N_PCI解析结构 ***/
typedef struct
{
uint8_t SF_DL : 4;
uint8_t Type : 4;
} TP_SF_N_PCI_Struct;
/*** 单帧N_PDU解析结构 ***/
typedef struct
{
uint16_t N_TAtype;
TP_SF_N_PCI_Struct N_PCI;
uint8_t N_Data [ 7 ];
uint8_t DLC;
uint8_t New;
} TP_N_PDU_SF_Struct;
/*** 首帧N_PCI解析结构 ***/
typedef struct
{
uint8_t FF_DL_H : 4;
uint8_t Type : 4;
uint16_t FF_DL_L : 8;
} TP_FF_N_PCI_Struct;
/*** 首帧N_PDU解析结构 ***/
typedef struct
{
uint16_t N_TAtype;
TP_FF_N_PCI_Struct N_PCI;
uint8_t N_Data [ 6 ];
uint8_t DLC;
uint8_t New;
} TP_N_PDU_FF_Struct;
/*** 连续帧N_PCI解析结构 ***/
typedef struct
{
uint8_t SN : 4;
uint8_t Type : 4;
} TP_CF_N_PCI_Struct;
/*** 连续帧N_PDU解析结构 ***/
typedef struct
{
uint16_t N_TAtype;
TP_CF_N_PCI_Struct N_PCI;
uint8_t N_Data [ 7 ];
uint8_t DLC;
uint8_t New;
} TP_N_PDU_CF_Struct;
/*** 流控帧N_PCI解析结构 ***/
typedef struct
{
uint8_t FS : 4;
uint8_t Type : 4;
uint8_t BS : 8;
uint8_t STmin : 8;
} TP_FC_N_PCI_Struct;
/*** 流控帧N_PDU解析结构 ***/
typedef struct
{
uint16_t N_TAtype;
TP_FC_N_PCI_Struct N_PCI;
uint8_t N_Data [ 5 ];
uint8_t DLC;
uint8_t New;
} TP_N_PDU_FC_Struct;
/*** 传输层数据解析联合体 ***/
typedef union
{
TP_Data_Struct Frame;
TP_N_PDU_Struct N_PDU;
TP_N_PDU_SF_Struct N_PDU_SF;
TP_N_PDU_FF_Struct N_PDU_FF;
TP_N_PDU_CF_Struct N_PDU_CF;
TP_N_PDU_FC_Struct N_PDU_FC;
} TransportDataUnion;
/*** 传输层收发控制结构 ***/
typedef struct
{
uint8_t Process; // 当前收发进程
uint8_t NonStopMode; // 不间断收发模式(不再理会后续的FC帧)
uint16_t Len; // 已接收到或已发送出的数据长度
uint16_t TotalLen; // 数据总长
uint16_t BlockSize; // Block总数
uint16_t BlockCnt; // 已接收到或已发送出的Block数
uint8_t BSMax; // 当前接收机剩余的最大Block数
uint8_t WFTCnt; //[仅接收用]等待次数计数
uint8_t STmin; //[仅发送用]当前接收机要求的最小间隔时间
} TransportControlStruct;
/*** 时序控制结构 ***/
typedef struct
{
uint16_t Cnt; // 滚动计数器
uint16_t LastCnt; // 上次更新时的滚动计数器
uint32_t NTimer; // 时序定时器,单位:us
uint32_t STimer; // 最小间隔时间(STmin)定时器,单位:us
uint8_t Type; // 当前定时器计时参数名称
uint8_t STminStatus; // STmin计时状态
} TransportTimingControlStruct;
/*---------------------------------------------------------------------------*/
/*** 数据收发结果N_Result枚举 ***/
typedef enum
{
N_OK = 0,
N_TIMEOUT_A,
N_TIMEOUT_Bs,
N_TIMEOUT_Cr,
N_WRONG_SN,
N_INVALID_FS,
N_UNEXP_PDU,
N_WFT_OVRN,
N_BUFFER_OVFLW,
N_ERROR,
} N_ResultEnum;
/*** 接收用N_USData数据结构 ***/
typedef struct
{
uint16_t N_TAtype;
uint16_t Length;
uint8_t MsgData [ N_USDATA_RX_BUFFER_SIZE ];
} N_USDataRxStruct;
/*** 发送用N_USData数据结构 ***/
typedef struct
{
uint16_t N_TAtype;
uint16_t Length;
uint8_t MsgData [ N_USDATA_TX_BUFFER_SIZE ];
} N_USDataTxStruct;
/******************************************************************************
函数声明
******************************************************************************/
/*-- 外部接口函数 -----------------------------------------------------------*/
/*** 后台服务函数 ***/
extern void DoCAN_Communication_Service(void);
extern void DoCAN_Timer_Update(uint16_t Interval);
/*** 网络层上层接口函数 ***/
void DoCAN_N_USData_Request(uint16_t N_TAtype, uint8_t *MessageData, uint16_t Length);
void DoCAN_N_USData_Confirm(uint16_t N_TAtype, N_ResultEnum N_Result);
void DoCAN_N_USData_FF_Indication(uint16_t N_TAtype, uint16_t Length);
void DoCAN_N_USData_Indication(uint16_t N_TAtype, uint8_t *MessageData, uint16_t Length, N_ResultEnum N_Result);
/*** 链路层下层接口函数 ***/
void DoCAN_L_Data_Request(uint16_t Identifier, uint8_t dlc, uint8_t *Data);
void DoCAN_L_Data_Confirm(uint16_t Identifier, uint8_t TransferStatus);
extern void DoCAN_L_Data_Indication(uint16_t Identifier, uint32_t dlc, uint8_t *pData);
extern void CAN_LLC_Ch5_Data_Request(uint32_t Identifier, uint16_t idx, uint8_t DLC, uint8_t *Data);
/*-- 内部函数 ---------------------------------------------------------------*/
/*** 传输层协议解析 ***/
void DoCAN_Receive_And_Assemble_N_USData(void); // 接收主函数
void DoCAN_Get_N_PDU(void);
void DoCAN_Receive_Single_Frame_N_Data(void);
void DoCAN_Receive_First_Frame_N_Data(void);
void DoCAN_Receive_Consecutive_Frame_N_Data(void);
void DoCAN_Receive_Flow_Control(void);
void DoCAN_Transmit_Flow_Control(void);
void DoCAN_Handle_Unknown_N_PDU(void);
void DoCAN_Disassemble_And_Transmit_N_USData(void); // 发送主函数
/*** 时序管理 ***/
void DoCAN_Update_Timer(void);
void DoCAN_Handle_Time_Out(void);
void DoCAN_Start_Timer(uint8_t TimingParameter);
void DoCAN_Stop_Timer(void);
void DoCAN_Start_STmin_Timer(uint8_t STminTime);
uint8_t DoCAN_Get_STmin_Timer_Status(void);
#endif
/******************************************************************************
文 件 名:DoCAN_ISO15765_Config.h
功能描述:ISO 15765 规范规定的诊断服务配置文件
作 者:张暄
版 本:V1.0
日 期:2016.7.18
******************************************************************************/
/******************************************************************************
Diagnostic/Programming Specifications Applicable to the OSI Layers
===============================================================================
* NO. OSI Layer Diagnostics services
-------------------------------------------------------------------------------
7 Application ISO 14229-1 ISO 14229-3
6 Presentation -
5 Session ISO 14229-2
* 4 Transport ISO 15765-2
* 3 Network ISO 15765-2
2 Data Link ISO 11898
1 Physical ISO 11898
===============================================================================
******************************************************************************/
#ifndef _DOCAN_ISO15765_CONFIG_H_
#define _DOCAN_ISO15765_CONFIG_H_
#include "Diag_ID_Def.h"
/*-----------------------------------------------------------------------------
If CAN frame data padding is used, the DLC is always set to 8, even if the
N_PDU to be transmitted is shorter than 8 bytes. The sender has to pad any
unused bytes in the frame. In particular, this can be the case for an SF, FC
frame or the last CF of a segmented message.
-----------------------------------------------------------------------------*/
#define FILLER_BYTE_HANDLING 1
#define FILLER_BYTE 0xAA
/*-----------------------------------------------------------------------------
Link layer Rx FIFO depth
-----------------------------------------------------------------------------*/
#define LINK_RX_FIFO_MAX_DEPTH 2
/*-----------------------------------------------------------------------------
Network layer buffer size
-----------------------------------------------------------------------------*/
#define N_USDATA_RX_BUFFER_SIZE 96
#define N_USDATA_TX_BUFFER_SIZE 96
/******************************************************************************
The FlowControl mechanism allows the receiver to inform the sender about the
receiver’s capabilities. Since different nodes may have different capabilities,
the FlowControl sent by the receiver informs the sender about its capabilities.
The sender shall conform to the receiver’s capabilities.
These capabilities are defined as follows.
******************************************************************************/
/*-----------------------------------------------------------------------------
— BlockSize (BS): The maximum number of N_PDUs the receiver allows the sender
to send, before waiting for an authorization to continue transmission of the
following N_PDUs.
-----------------------------------------------------------------------------*/
#define N_MAX_BS 8
/*-----------------------------------------------------------------------------
— SeparationTime minimum (STmin): The minimum time the sender is to wait
between transmission of two CF N_PDUs. (Unit: ms)
-----------------------------------------------------------------------------*/
#define N_STmin 20
/*-----------------------------------------------------------------------------
— N_WFTmax: Upper limit to the number of FC.WAIT a receiver is allowed to send
in a row. This parameter is a system design constant and is not
transmitted in the first FC N_PDU.
-----------------------------------------------------------------------------*/
#define N_WFTmax 0
/******************************************************************************
Timing parameters
******************************************************************************/
/*-----------------------------------------------------------------------------
- Timing Parametera : N_As
- Description : Time for transmission of the CAN frame (any N_PDU)
on the sender side
- Start : L_Data.request
- End : L_Data.confirm
- Timeout(Max) : 1,000 ms
- Performance Requirement :
-----------------------------------------------------------------------------*/
#define N_As (( uint32_t )25)
/*-----------------------------------------------------------------------------
- Timing Parametera : N_Ar
- Description : Time for transmission of the CAN frame (any N_PDU)
on the receiver side
- Start : L_Data.request
- End : L_Data.confirm
- Timeout(Max) : 1,000 ms
- Performance Requirement :
-----------------------------------------------------------------------------*/
#define N_Ar (( uint32_t )25)
/*-----------------------------------------------------------------------------
- Timing Parametera : N_Bs
- Description : Time until reception of the next FlowControl N_PDU
- Start : L_Data.confirm (FF) / L_Data.confirm (CF) /
L_Data.indication (FC)
- End : L_Data.indication (FC)
- Timeout(Max) : 1,000 ms
- Performance Requirement :
-----------------------------------------------------------------------------*/
#define N_Bs (( uint32_t )75)
/*-----------------------------------------------------------------------------
- Timing Parametera : N_Br
- Description : Time until transmission of the next FlowControl
N_PDU
- Start : L_Data.indication (FF) / L_Data.indication (CF)
L_Data.confirm (FC)
- End : L_Data.request (FC)
- Timeout(Max) : N/A
- Performance Requirement : (N_Br + N_Ar) < (0.9 × N_Bs timeout)
-----------------------------------------------------------------------------*/
#define N_Br (( uint32_t )9)
/*-----------------------------------------------------------------------------
- Timing Parametera : N_Cs
- Description : Time until transmission of the next
ConsecutiveFrame N_PDU
- Start : L_Data.indication (FC) / L_Data.confirm (CF)
- End : L_Data.request (CF)
- Timeout(Max) : N/A
- Performance Requirement : (N_Cs + N_As) < (0.9 × N_Cr timeout)
-----------------------------------------------------------------------------*/
#define N_Cs (( uint32_t )0)
/*-----------------------------------------------------------------------------
- Timing Parametera : N_Cr
- Description : Time until reception of the next Consecutive Frame
N_PDU
- Start : L_Data.confirm (FC) / L_Data.indication (CF)
- End : L_Data.indication (CF)
- Timeout(Max) : 1,000 ms
- Performance Requirement :
-----------------------------------------------------------------------------*/
#define N_Cr (( uint32_t )150)
/******************************************************************************
For debug purpose
******************************************************************************/
/*-----------------------------------------------------------------------------
Global debug switch
-----------------------------------------------------------------------------*/
#define DOCAN_DEBUG_EN 0
/*-----------------------------------------------------------------------------
Bug indicator functions
-----------------------------------------------------------------------------*/
#if DOCAN_DEBUG_EN
#define LINK_RX_FIFO_OVERFLOW_INDICATOR( )
#endif
#endif
/******************************************************************************
文 件 名:UDS_ISO14229_Server.c
功能描述:ISO 14229 规范规定的诊断服务服务器端函数库文件
作 者:张暄
版 本:V1.0
日 期:2016.11.1
******************************************************************************/
#include "UDS_ISO14229_Server.h"
UDS_APP_RX_Union UDS_APP_RX;
UDS_APP_TX_Union UDS_APP_TX;
UDS_APP_TX_NEG_Union UDS_APP_TX_NEG;
extern DiagSendDataNeg NegRes;
extern uint8_t CAN_Current_state;
/******************************************************************************
后台服务
******************************************************************************/
/******************************************************************************
函数名:UDS_Server_Application_Service
功 能:UDS服务器应用层控制服务
参 数:无
返回值:无
*******************************************************************************
注 意:该服务函数必须被实时调用
******************************************************************************/
void UDS_Server_Application_Service(void)
{
UDS_Process_Service_Request( );
/*
if ( IsNMTimerOut ( NM_Tdiag_Timer ) )
{
NMStopTimer ( NM_Tdiag_Timer );
CanNm_NetworkRelease ( NM_REQ_DIAG_TIMEOUT );
}
*/
}
/******************************************************************************
会话层下层接口及计时功能实现
******************************************************************************/
/******************************************************************************
函数名:UDS_N_USData_Request
功 能:该服务函数用于请求传输数据
This service is used to request the transfer of data. If necessary, the
network layer segments the data.
参 数:N_TAtype :目标地址类型,发送数据请使用 DIAG_ID_Tx
MessageData :请求传输的数据
Length :数据长度
返回值:无
******************************************************************************/
void UDS_N_USData_Request(uint16_t N_TAtype, uint8_t *MessageData, uint16_t Length)
{
DoCAN_N_USData_Request(N_TAtype, MessageData, Length);
// 计时
}
/******************************************************************************
函数名:UDS_N_USData_Confirm
功 能:该服务函数由网络层发起,用于确认前一次使用N_USData.request服务向
N_TAtype地址发送的数据是否发送完成
The N_USData.confirm service is issued by the network layer. The service
primitive confirms the completion of an N_USData.request service
identified by the address information in N_TAtype.
参 数:N_TAtype :N_USData.confirm服务请求的发送地址
N_Result :N_USData.request服务的传输状态
返回值:无
******************************************************************************/
extern void UDS_N_USData_Confirm(uint16_t N_TAtype, uint8_t N_Result)
{
if ( N_Result == N_OK )
UDS_S_Data_Confirm(N_TAtype, S_OK);
else
UDS_S_Data_Confirm(N_TAtype, S_NOK);
// 计时
}
/******************************************************************************
函数名:UDS_N_USData_FF_Indication
功 能:该服务函数由网络层发起,用于向上层指示地址为N_TAtype的一组多帧数据的首帧
的到来
The N_USData_FF.indication service is issued by the network layer. The
service primitive indicates to the adjacent upper layer the arrival of
a FirstFrame (FF) of a segmented message received from a peer protocol
entity, identified by the address information N_TAtype.
参 数:N_TAtype :新到的多帧数据首帧的地址信息
Length :新到的多帧数据的总长度
返回值:无
******************************************************************************/
extern void UDS_N_USData_FF_Indication(uint16_t N_TAtype, uint16_t Length)
{
// 计时
}
/******************************************************************************
函数名:UDS_N_USData_Indication
功 能:该服务函数由网络层发起,用于向上层指出由N_TAtype地址发送来的长度为Length
的MessageData数据的传送结果N_Result,并同时传递这一数据
The N_USData.indication service is issued by the network layer. The
service primitive indicates <N_Result> events and delivers
<MessageData> with <Length> bytes received from a peer protocol entity
identified by the address information in N_TAtype to the adjacent upper
layer.
参 数:N_TAtype :接收到的数据地址信息
MessageData :接收到的数据 (仅在N_Result为N_OK时有效)
Length :接收到的数据长度 (仅在N_Result为N_OK时有效)
N_Result :数据的接收结果
返回值:无
******************************************************************************/
extern void UDS_N_USData_Indication(uint16_t N_TAtype, uint8_t *MessageData, uint16_t Length, uint8_t N_Result)
{
if ( N_Result == N_OK )
UDS_S_Data_Indication(N_TAtype, MessageData, Length, S_OK);
else
UDS_S_Data_Indication(N_TAtype, MessageData, Length, S_NOK);
// 计时
}
/******************************************************************************
会话层上层接口
******************************************************************************/
/******************************************************************************
函数名:UDS_S_Data_Request
功 能:该服务用于请求向目标地址S_TAtype发送长度为S_Length的S_Data.
The service primitive requests transmission of S_Data with S_Length
number of bytes from the sender to the receiver peer entities
identified by the address information in S_TAtype.
参 数:S_TAtype :发送数据的目标地址
S_Data :发送的数据
S_Length :数据的长度
返回值:无
******************************************************************************/
void UDS_S_Data_Request(uint16_t S_TAtype, uint8_t *S_Data, uint16_t S_Length)
{
UDS_N_USData_Request(S_TAtype, S_Data, S_Length);
}
/******************************************************************************
函数名:UDS_S_Data_Request
功 能:该服务由会话层发起,用于指出以S_TAtype为目标地址的S_Data.request发送请求
是否完成
The S_Data.confirm service is issued by the session layer. The service
primitive confirms the completion of an S_Data.request service
identified by the address information in S_TAtype.
参 数:S_TAtype :发送数据的目标地址
S_Result :数据的发送结果
返回值:无
******************************************************************************/
void UDS_S_Data_Confirm(uint16_t S_TAtype, S_Result_Enum S_Result)
{
}
/******************************************************************************
函数名:UDS_S_Data_Request
功 能:该服务由会话层发起,用于向上层指出S_Result接收状态以及传递从S_TAtype地址
接收到的S_Length长度的S_Data数据
The S_Data.indication service is issued by the session layer. The
service primitive indicates S_Result events and delivers S_Data with
S_Length bytes received from a peer protocol entity identified by the
address information in S_TAtype to the adjacent upper layer.
参 数:S_TAtype :接收到的数据地址信息
S_Data :接收到的数据 (仅在S_Result为S_OK时有效)
S_Length :接收到的数据长度 (仅在S_Result为S_OK时有效)
S_Result :数据的接收结果
返回值:无
******************************************************************************/
void UDS_S_Data_Indication(uint16_t S_TAtype, uint8_t *S_Data, uint16_t S_Length, S_Result_Enum S_Result)
{
uint16_t i;
if ( S_Result == S_OK )
{
UDS_APP_RX.Data.New = 1;
UDS_APP_RX.Data.TA_type = S_TAtype;
UDS_APP_RX.Data.Length = S_Length - 1;
for ( i = 0; i < S_Length; i++ )
{
UDS_APP_RX.Data.A_Data [ i ] = *S_Data;
S_Data++;
}
}
}
/******************************************************************************
应用层服务控制
******************************************************************************/
/******************************************************************************
函数名:UDS_Process_Service_Request
功 能:该函数用于处理来自客户端的服务请求,当有新的服务请求到达时,根据SI选择相
应的服务实现函数执行服务
参 数:无
返回值:无 SYSC0_RUNPLL2CNTR
******************************************************************************/
extern uint8_t S3_Server_refresh;
void UDS_Process_Service_Request(void)
{
if (UDS_APP_RX.A_PDU.New)
{
S3_Server_refresh = 1;
switch (UDS_APP_RX.A_PDU.A_PCI.SI)
{
case 0x10: UDS_Service_10_Indication(UDS_APP_RX.A_PDU.TA_type, UDS_APP_RX.A_PDU.Length, UDS_APP_RX.A_PDU.Data);
break;
case 0x22: UDS_Service_22_Indication(UDS_APP_RX.A_PDU.TA_type, UDS_APP_RX.A_PDU.Length, UDS_APP_RX.A_PDU.Data);
break;
case 0x2E: UDS_Service_2E_Indication(UDS_APP_RX.A_PDU.TA_type, UDS_APP_RX.A_PDU.Length, UDS_APP_RX.A_PDU.Data);
break;
case 0x27: UDS_Service_27_Indication(UDS_APP_RX.A_PDU.TA_type, UDS_APP_RX.A_PDU.Length, UDS_APP_RX.A_PDU.Data);
break;
case 0x28: UDS_Service_28_Indication(UDS_APP_RX.A_PDU.TA_type, UDS_APP_RX.A_PDU.Length, UDS_APP_RX.A_PDU.Data);
break;
case 0x85: UDS_Service_85_Indication(UDS_APP_RX.A_PDU.TA_type, UDS_APP_RX.A_PDU.Length, UDS_APP_RX.A_PDU.Data);
break;
case 0x11: UDS_Service_11_Indication(UDS_APP_RX.A_PDU.TA_type, UDS_APP_RX.A_PDU.Length, UDS_APP_RX.A_PDU.Data);
break;
case 0x3E: UDS_Service_3E_Indication(UDS_APP_RX.A_PDU.TA_type, UDS_APP_RX.A_PDU.Length, UDS_APP_RX.A_PDU.Data);
break;
default:
if (UDS_APP_RX.A_PDU.TA_type != DIAG_ID_Rx_FUN)
{
NegRes.code = serviceNotSupported;
UDS_Service_Response(UDS_APP_RX.A_PDU.A_PCI.SI, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
}
break;
}
UDS_APP_RX.A_PDU.New = 0;
}
}
/******************************************************************************
函数名:UDS_Service_Response
功 能:该函数根据反馈类型生成相应的反馈数据传递给客户端,通用于各个服务的反馈
参 数:si :服务ID
RspType :反馈类型 POSITIVE_RSP 正反馈
NEGATIVE_RSP 负反馈
A_TA_type :目标地址类型
A_Length :随反馈携带的数据的长度(仅是数据A_Data的长度)
A_Data :随反馈携带的数据
返回值:无
******************************************************************************/
extern void UDS_Service_Response(uint8_t si, uint8_t RspType, uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data)
{
uint16_t i;
if ( RspType )
{
UDS_APP_TX_NEG.A_PDU.TA_type = A_TA_type;
UDS_APP_TX_NEG.A_PDU.A_PCI.NR_SI = 0x7F;
UDS_APP_TX_NEG.A_PDU.A_PCI.SI = si;
UDS_APP_TX_NEG.A_PDU.Length = A_Length;
for ( i = 0; i < UDS_APP_TX_NEG.A_PDU.Length; i++ )
{
UDS_APP_TX_NEG.A_PDU.Data [ i ] = *A_Data;
A_Data++;
}
UDS_S_Data_Request(UDS_APP_TX_NEG.Data.TA_type, UDS_APP_TX_NEG.Data.A_Data, UDS_APP_TX_NEG.Data.Length + 2);
}
else
{
UDS_APP_TX.A_PDU.TA_type = A_TA_type;
UDS_APP_TX.A_PDU.A_PCI.SI = si | 0x40;
UDS_APP_TX.A_PDU.Length = A_Length;
for ( i = 0; i < UDS_APP_TX.A_PDU.Length; i++ )
{
UDS_APP_TX.A_PDU.Data [ i ] = *A_Data;
A_Data++;
}
UDS_S_Data_Request(UDS_APP_TX.Data.TA_type, UDS_APP_TX.Data.A_Data, UDS_APP_TX.Data.Length + 1);
}
}
/******************************************************************************
文 件 名:UDS_ISO14229_Server.h
功能描述:ISO 14229 规范规定的诊断服务服务器端函数头文件
作 者:张暄
版 本:V1.0
日 期:2016.11.1
******************************************************************************/
/******************************************************************************
诊断服务的OSI模型映射
===============================================================================
* NO. OSI Layer Diagnostics services
-------------------------------------------------------------------------------
* 7 Application ISO 14229-1 ISO 14229-3
6 Presentation -
* 5 Session ISO 14229-2
4 Transport ISO 15765-2
3 Network ISO 15765-2
2 Data Link ISO 11898
1 Physical ISO 11898
===============================================================================
******************************************************************************/
#ifndef _UDS_ISO14229_SERVER_H_
#define _UDS_ISO14229_SERVER_H_
#include "DoCAN_ISO15765.h"
#include "DoCAN_ISO15765_Config.h"
#include "UDS_ISO14229_Services.h"
/******************************************************************************
结构体声明
******************************************************************************/
/*** 会话层数据发送结果枚举 ***/
typedef enum
{
S_OK = 0,
S_NOK,
} S_Result_Enum;
/*---------------------------------------------------------------------------*/
/*** A_PCI解析结构(非负反馈) ***/
typedef struct
{
uint8_t SI;
} UDS_A_PCI_Struct;
/*** A_PCI解析结构(负反馈) ***/
typedef struct
{
uint8_t NR_SI;
uint8_t SI;
} UDS_NEG_A_PCI_Struct;
/*** 应用层接收数据解析结构 ***/
typedef struct
{
uint16_t TA_type;
uint8_t A_Data [ A_DATA_RX_BUFFER_SIZE ];
uint16_t Length; // 有效数据长度(不含A_PCI)
uint8_t New; // 新收到的数据
} UDS_RX_App_Data_Struct;
/*** 应用层接收A_PDU解析结构 ***/
typedef struct
{
uint16_t TA_type;
UDS_A_PCI_Struct A_PCI;
uint8_t Data [ A_DATA_RX_BUFFER_SIZE - 1 ];
uint16_t Length; // 有效数据长度(不含A_PCI)
uint8_t New; // 新收到的数据
} UDS_RX_A_PDU_Struct;
/*** 应用层发送数据解析结构 ***/
typedef struct
{
uint16_t TA_type;
uint8_t A_Data [ A_DATA_TX_BUFFER_SIZE ];
uint16_t Length; // 有效数据长度(不含A_PCI)
} UDS_TX_App_Data_Struct;
/*** 应用层发送正反馈A_PDU解析结构 ***/
typedef struct
{
uint16_t TA_type;
UDS_A_PCI_Struct A_PCI;
uint8_t Data [ A_DATA_TX_BUFFER_SIZE - 1 ];
uint16_t Length; // 有效数据长度(不含A_PCI)
} UDS_TX_A_PDU_Struct;
/*** 应用层发送负反馈A_PDU解析结构 ***/
typedef struct
{
uint16_t TA_type;
UDS_NEG_A_PCI_Struct A_PCI;
uint8_t Data [ A_DATA_TX_BUFFER_SIZE - 2 ];
uint16_t Length; // 有效数据长度(不含A_PCI)
} UDS_TX_NEG_A_PDU_Struct;
/*** 应用层接收数据解析联合体 ***/
typedef union
{
UDS_RX_App_Data_Struct Data;
UDS_RX_A_PDU_Struct A_PDU;
} UDS_APP_RX_Union;
/*** 应用层发送正反馈数据解析联合体 ***/
typedef union
{
UDS_TX_App_Data_Struct Data;
UDS_TX_A_PDU_Struct A_PDU;
} UDS_APP_TX_Union;
/*** 应用层发送负反馈数据解析联合体 ***/
typedef union
{
UDS_TX_App_Data_Struct Data;
UDS_TX_NEG_A_PDU_Struct A_PDU;
} UDS_APP_TX_NEG_Union;
/* 全局变量 变更为局部变量
uint8_t Service10DiagDataLength;
uint8_t Service11DiagDataLength;
uint8_t Service14DiagDataLength;
uint8_t Service19DiagDataLength;
uint8_t Service22DiagDataLength;
uint8_t Service27DiagDataLength;
uint8_t Service28DiagDataLength;
uint8_t Service2EDiagDataLength;
uint8_t Service2FDiagDataLength;
uint8_t Service31DiagDataLength;
uint8_t Service34DiagDataLength;
uint8_t Service36DiagDataLength;
uint8_t Service37DiagDataLength;
uint8_t Service3EDiagDataLength;
uint8_t Service85DiagDataLength;
*/
/******************************************************************************
函数声明
******************************************************************************/
/*-- 外部接口函数 -----------------------------------------------------------*/
/*** 后台服务函数 ***/
void UDS_Server_Application_Service(void);
/*** 传输层/网络层下层接口函数 ***/
void UDS_N_USData_Request(uint16_t N_TAtype, uint8_t *MessageData, uint16_t Length);
void UDS_N_USData_Confirm(uint16_t N_TAtype, uint8_t N_Result);
void UDS_N_USData_FF_Indication(uint16_t N_TAtype, uint16_t Length);
void UDS_N_USData_Indication(uint16_t N_TAtype, uint8_t *MessageData, uint16_t Length, uint8_t N_Result);
/*-- 内部函数 ---------------------------------------------------------------*/
/*** 会话层数据接口函数 ***/
void UDS_S_Data_Request(uint16_t S_TAtype, uint8_t *S_Data, uint16_t S_Length);
void UDS_S_Data_Confirm(uint16_t S_TAtype, S_Result_Enum S_Result);
void UDS_S_Data_Indication(uint16_t S_TAtype, uint8_t *S_Data, uint16_t S_Length, S_Result_Enum S_Result);
/*** 会话层时序控制函数 ***/
/*** 应用层服务控制函数 ***/
void UDS_Process_Service_Request(void);
extern void UDS_Service_Response(uint8_t si, uint8_t RspType, uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
#endif
/******************************************************************************
文 件 名:UDS_ISO14229_Server_Config.h
功能描述:ISO 14229 规范规定的诊断服务服务器端配置文件
作 者:张暄
版 本:V1.0
日 期:2016.11.1
******************************************************************************/
/******************************************************************************
诊断服务的OSI模型映射
===============================================================================
* NO. OSI Layer Diagnostics services
-------------------------------------------------------------------------------
* 7 Application ISO 14229-1 ISO 14229-3
6 Presentation -
* 5 Session ISO 14229-2
4 Transport ISO 15765-2
3 Network ISO 15765-2
2 Data Link ISO 11898
1 Physical ISO 11898
===============================================================================
******************************************************************************/
#ifndef _UDS_ISO14229_SERVER_CONFIG_H_
#define _UDS_ISO14229_SERVER_CONFIG_H_
#include "stdint.h"
#include "Diag_ID_Def.h"
#define A_DATA_RX_BUFFER_SIZE N_USDATA_RX_BUFFER_SIZE
#define A_DATA_TX_BUFFER_SIZE N_USDATA_TX_BUFFER_SIZE
#define P2_SERVER (uint16_t)50 /*P2Server*/
#define P2_AST_SERVER (uint16_t)200 /*P2*Server*/
#define S3_SERVER (uint8_t)50 /*S3Server 50 00ms*/
#endif
/******************************************************************************
�� �� ��;UDS_ISO14229_Services.c
��������;ISO 14229 �淶�涨����Ϸ���������˷���ʵ�ֺ������ļ�
�� ��;����
�� ��;V1.0
�� ��;2016.11.1
******************************************************************************/
#include "UDS_ISO14229_Services.h"
#include "flash.h"
#include "CAN_Signal\CAN_Lib.h"
#include "CAN_CH0_CAN_Communication_Matrix.h"
typedef struct
{
uint8_t ProjecName[16]; // 项目名
uint8_t PartNumber[16]; // 零件号
uint8_t PlatForm[16]; // 平台
struct
{
uint8_t type[16]; //标准*
uint8_t ch[16]; //通道*
uint8_t baudrate[16]; //速率*
uint32_t diagID[4]; //诊断ID*
}DiagCanCfg[1]; //(诊断CAN)通道配置*
} ProjectInfoStruct;
extern void UDS_Service_Response(uint8_t si, uint8_t RspType, uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
/*诊断使用, 判断App一致性, 禁止修改(内部版本号除外)*/
extern const ProjectInfoStruct ProjectInfo __attribute__((section(".ARM.__at_0x0000C200"))) =
{
"KeewayT06", // 凯威易行T06
"KEEWAY_T06_METER",
"BAT32A279KM64FB", // 中微芯片
{
"CAN_Ext",
"CAN_CH_0",
"CAN_500Kbps",
{DIAG_ID_Tx, DIAG_ID_Rx_PHY, DIAG_ID_Rx_FUN, 0}
}
};
DiagSendDataNeg NegRes;
uint8_t UDS_ISO14229_Transfer[250];
DiagDFlashData DiagDataForDFlash;
Ser2EDFlashData Ser2EDataForDFlash;
DiagFlag DiagDataForFlag;
Ser27_FlowCtrlCntUnion Ser27_FlowCtrlCnt;
uint8_t FlashDriverCheckSum = 0;
uint8_t BlocKCnt = 0;
/****************S3Timer********************/
uint8_t S3_ServerEN = 0;
uint8_t S3_ServerCnt = 0;
uint8_t S3_Server_refresh = 0;
/****************DiagnosticSession*****************/
uint8_t SessionType = 0x01;
/****************Ser28*********************/
uint8_t ControlType;
uint8_t CommunicationType;
/****************Ser27*********************/
uint8_t wait10cnt = 0;
uint8_t Wait10sFlag = 0;
uint8_t DiagLockFlag = 0;
uint8_t Seed [ 4 ];
uint32_t ValidSeedKey;
uint8_t Services27_01_Requested;
/******************************************************************************
The service access point of the diagnostics application layer provides a number
of services that all have the same general structure. For each service, three
service primitives are specified:
- a service indication primitive, used by the diagnostics application layer, to
pass data to the server function of the ECU diagnostic application;
- a service response primitive, used by the server function in the ECU
diagnostic application, to pass response data provided by the requested
diagnostic service to the diagnostics application layer;
- a service response-confirmation primitive, used by the server function in the
ECU diagnostic application, to indicate that the data passed in the service
response primitive is successfully sent on the vehicle communication bus the
ECU received the diagnostic request on;
******************************************************************************/
//软件版本号 F195
uint8_t MCU_SWversion[6] = {'S', 'V', (uint8_t)((SWV >> 8u) & 0x0Fu) + 0x30u, '.', (uint8_t)((SWV >> 4u) & 0x0Fu) + 0x30u, (uint8_t)(SWV & 0x0Fu) + 0x30u};
//硬件版本号 F193
uint8_t MCU_HWversion[6] = {'H', 'V', (uint8_t)((HWV >> 8u) & 0x0Fu) + 0x30u, '.', (uint8_t)((HWV >> 4u) & 0x0Fu) + 0x30u, (uint8_t)(HWV & 0x0Fu) + 0x30u};
//引导程序版本信息 F180
uint8_t MCU_FBLversion[6] = {'B', 'V', (uint8_t)((BTV >> 8u) & 0x0Fu) + 0x30u, '.', (uint8_t)((BTV >> 4u) & 0x0Fu) + 0x30u, (uint8_t)(BTV & 0x0Fu) + 0x30u};
//零件号信息 F187
uint8_t MCU_PartNumber[16] = {'K', 'E', 'E', 'W', 'A', 'Y', '_', 'T', '0', '6', '_', 'M', 'E', 'T', 'E', 'R'};
void Data_Set_DiagPara(void)
{
uint8_t i;
//获取DID的值,等待写入DFlash
for(i = 0; i < 6; i++)
{
DiagDataForDFlash.DID_F180[i] = MCU_FBLversion[i];
}
for(i = 0; i < 16; i++)
{
DiagDataForDFlash.DID_F187[i] = MCU_PartNumber[i];
}
for(i = 0; i < 6; i++)
{
DiagDataForDFlash.DID_F193[i] = MCU_HWversion[i];
}
for(i = 0; i < 6; i++)
{
DiagDataForDFlash.DID_F195[i] = MCU_SWversion[i];
}
for(i = 0; i < 2; i++)
{
DiagDataForDFlash.Filldata[i] = 0u;
}
}
/*写App有效性标志*/
void Write_App_InValid(uint32_t m32)
{
//设置App状态值
DiagDataForFlag.Flag = 0xA77A5AA5u;
DiagDataForFlag.APP_STATUS = m32;
//擦除扇区
EraseSector (APP_STATUS_ADDR);
//App程序状态和22服务数据全写进去
ProgramPage (APP_STATUS_ADDR, 8U, (uint8_t *)(&DiagDataForFlag));
}
/*写22服务数据*/
void DFlash_init(void)
{
}
void Data_Read_DiagPara(void)
{
uint8_t i;
Ser2EDFlashData* ReadSer2EDataForDFlash = (Ser2EDFlashData*)APP_DATA_WRITE;
DiagDFlashData* ReadDiagDataForDFlash =(DiagDFlashData*)APP_DATA_INFO;
if( (ReadDiagDataForDFlash->Flag != 0x5AA5A77Au)||
(0!=memcmp(ReadDiagDataForDFlash->DID_F180 , MCU_FBLversion,sizeof(MCU_FBLversion)))||
(0!=memcmp(ReadDiagDataForDFlash->DID_F187 , MCU_PartNumber,sizeof(MCU_PartNumber)))||
(0!=memcmp(ReadDiagDataForDFlash->DID_F193 , MCU_HWversion ,sizeof(MCU_HWversion )))||
(0!=memcmp(ReadDiagDataForDFlash->DID_F195 , MCU_SWversion ,sizeof(MCU_SWversion )))
)
{
Data_Set_DiagPara();
DiagDataForDFlash.Flag = 0x5AA5A77Au;
//擦除扇区
EraseSector (APP_DATA_INFO);
//App程序状态和22服务数据全写进去
ProgramPage (APP_DATA_INFO, sizeof(DiagDataForDFlash), (uint8_t *)(&DiagDataForDFlash));
}
else
{
memcpy(&DiagDataForDFlash,ReadDiagDataForDFlash,sizeof(DiagDFlashData));
}
if( ReadSer2EDataForDFlash->Flag != 0x5AA5A77Au)
{
memset(&Ser2EDataForDFlash.DID_F184[0],0,sizeof(Ser2EDataForDFlash.DID_F184));
EraseSector (APP_DATA_WRITE);
ProgramPage (APP_DATA_WRITE, sizeof(DiagDataForDFlash), (uint8_t *)(&DiagDataForDFlash));
}
else
{
for ( i = 0; i < sizeof(Ser2EDataForDFlash.DID_F184); i++)
{
Ser2EDataForDFlash.DID_F184[i] = ReadSer2EDataForDFlash->DID_F184[i];
}
}
}
void S3_ServerCNTT(void)
{
if ( Wait10sFlag == 1 )
{
if ( wait10cnt >= 100 )
{
Ser27_FlowCtrlCnt.RequestSeedCnt = 2;
Ser27_FlowCtrlCnt.Attemptcnt = 2;
// WriteDFlashData(0x02u, ( uint32_t * )&Ser27_FlowCtrlCnt.Flag, sizeof(Ser27_FlowCtrlCnt) / 4u, NoNeedWait);
wait10cnt = 0;
Wait10sFlag = 0;
}
else
{
++wait10cnt;
}
}
if ( S3_ServerEN == 1 )
{
if ( S3_Server_refresh == 1 )
{
S3_Server_refresh = 0;
S3_ServerCnt = 0;
}
if ( S3_ServerCnt >= S3_SERVER )
{
DIAG_InitParameter( );
CAN_RX_SetEnable(&CAN_CH0_CanMsgOp, CAN_N_RX_Enable);
CAN_TX_SetEnable(&CAN_CH0_CanMsgTxOp, CAN_N_TX_Enable);//S3超时解除
}
else
{
++S3_ServerCnt;
}
}
}
uint32_t RANDOM = 0xA77A;
void Randomcnt(void)
{
RANDOM++;
if (RANDOM >= 0xFF0F00F0)
{
RANDOM = 0x363;
}
}
uint8_t SerXXNRC12Filter(uint8_t insub, const uint8_t *supportsub, uint8_t size, uint8_t *index)
{
uint8_t sub = insub;
uint8_t i = 0;
uint8_t nrccode = 0;
if ( size > 0 )
{
nrccode = subFunctionNotSupported;
while ( i < size )
{
if ( supportsub [ i ] == sub )
{
nrccode = 0;
*index = i;
break;
}
i++;
}
}
else
{
*index = 0;
}
return nrccode;
}
uint8_t SerXXNRC13Filter(uint8_t type, uint8_t serlength, const uint8_t *length, uint8_t index)
{
uint8_t nrccode;
nrccode = incorrectMessageLength;
if ( 0 == type )
{
if ( length != 0 )
{
if ( length [ 0 ] <= serlength )
{
nrccode = 0;
}
}
else
{
nrccode = incorrectMessageLength;
}
}
else
{
if ( length != 0 )
{
if ( length [ index ] == serlength )
{
nrccode = 0;
}
}
else
{
nrccode = incorrectMessageLength;
}
}
return nrccode;
}
uint8_t SerXXNRC22Filter(void)
{
uint8_t nrccode = 0;
nrccode = 0;
return nrccode;
}
uint8_t SerXXNRC31DIDFilter(uint16_t inDID, const uint16_t *DIDList, uint8_t size, uint8_t *index)
{
uint8_t nrccode = 0;
uint8_t i = 0;
if ( size > 0 )
{
nrccode = requestOutOfRange;
while ( i < size )
{
if ( inDID == DIDList [ i ] )
{
nrccode = 0;
*index = i;
break;
}
else
{
++i;
}
}
}
return nrccode;
}
uint8_t SerXXNRC33Filter(const uint8_t *levelList, uint8_t index)
{
uint8_t nrccode;
nrccode = 0;
if ( NoNeed != levelList [ index ] )
{
if ( DiagLockFlag != levelList [ index ] )
{
nrccode = securityAccessDenied;
}
}
return nrccode;
}
uint8_t SerXXNRC7EFilter(const uint8_t *SubSupportSession, uint8_t index)
{
uint8_t nrccode;
nrccode = 0;
if ( 0 == (GetCurrentSession( ) & SubSupportSession [ index ]) )
{
nrccode = subfunctionNotSupportinActiveSession;
}
return nrccode;
}
uint8_t SerXXNRC7FFilter(uint8_t SupportSession)
{
uint8_t nrccode;
nrccode = 0;
if ( 0 == (GetCurrentSession( ) & SupportSession) )
{
nrccode = serviceNotSupportedInActiveSession;
}
return nrccode;
}
uint8_t GetCurrentSession(void)
{
uint8_t SessionMode;
if ( DefaultSession == SessionType )
{
SessionMode = DefaultMode;
}
else if ( ProgrammingSession == SessionType )
{
SessionMode = ProgrammingMode;
}
else if ( ExtendedDiagnosticSession == SessionType )
{
SessionMode = ExtendedDiagnosticMode;
}
else
{
SessionType = DefaultSession;
SessionMode = DefaultMode;
}
return SessionMode;
}
/******************************************************************************
10# - DiagnosticSessionControl
******************************************************************************/
static const uint8_t Ser10BanResponse = AbleResponseType;
static const uint8_t Ser10Sub [] = {DefaultSession, ProgrammingSession, ExtendedDiagnosticSession};
static const uint8_t Ser10MinLen [] = {1};
static const uint8_t Ser10SubLen [] = {1, 1, 1};
static const uint8_t Ser10UnlockLevel [] = {NoNeed, NoNeed, NoNeed};
static const uint8_t Ser10SupportSession = DefaultMode | ProgrammingMode | ExtendedDiagnosticMode;
static const uint8_t Ser10SubSupportSession [] = {DefaultMode | ProgrammingMode | ExtendedDiagnosticMode, ProgrammingMode | ExtendedDiagnosticMode,
DefaultMode | ExtendedDiagnosticMode};
void UDS_Service_10_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data)
{
uint8_t i;
uint8_t si = DiagnosticSessionControl;
uint8_t NrcCode = 0;
uint8_t Index = 0;
uint8_t SubFunction = 0;
uint16_t Service10DiagDataLength = A_Length;
uint16_t FunorPhy = A_TA_type;
for (i = 0; i < Service10DiagDataLength; ++i)
{
UDS_ISO14229_Transfer[i] = *(A_Data + i);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC7FFilter(Ser10SupportSession);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC13Filter(MinLengthType, Service10DiagDataLength, Ser10MinLen, Index);
}
if (0 == NrcCode)
{
if (Ser10BanResponse == AbleResponseType)
{
SubFunction = UDS_ISO14229_Transfer[0] & 0x7F;
}
else
{
SubFunction = UDS_ISO14229_Transfer[0];
}
NrcCode = SerXXNRC12Filter(SubFunction, Ser10Sub, sizeof(Ser10Sub), &Index);
}
if ((0 == NrcCode) && (DIAG_ID_Rx_FUN == FunorPhy) && (ProgrammingSession == Ser10Sub[Index]))
{
NrcCode = subFunctionNotSupported;
}
if (0 == NrcCode && Index < sizeof(Ser10UnlockLevel))
{
NrcCode = SerXXNRC33Filter(Ser10UnlockLevel, Index);
}
if (0 == NrcCode && (Index < sizeof(Ser10SubSupportSession)))
{
NrcCode = SerXXNRC7EFilter(Ser10SubSupportSession, Index);
}
if (0 == NrcCode && (Index < sizeof(Ser10SubLen)))
{
NrcCode = SerXXNRC13Filter(SubLengthType, Service10DiagDataLength, Ser10SubLen, Index);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC22Filter();
}
if (0 == NrcCode)
{
UDS_ISO14229_Transfer[1] = 0;
UDS_ISO14229_Transfer[2] = 50;
UDS_ISO14229_Transfer[3] = 0;
UDS_ISO14229_Transfer[4] = 200;
if (DefaultSession == SubFunction)
{
S3_ServerEN = 0;
SessionType = DefaultSession;
DIAG_InitParameter();
CAN_RX_SetEnable(&CAN_CH0_CanMsgOp, CAN_N_RX_Enable);
CAN_TX_SetEnable(&CAN_CH0_CanMsgTxOp, CAN_N_TX_Enable);//切会话解除
if (AbleResponseType == Ser10BanResponse)
{
if (bit_is_clear(UDS_ISO14229_Transfer[0], 7))
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 5, UDS_ISO14229_Transfer);
}
}
else
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 5, UDS_ISO14229_Transfer);
}
}
else if (ProgrammingSession == SubFunction)
{
S3_ServerEN = 1;
S3_Server_refresh = 1;
SessionType = ProgrammingSession;
Services27_01_Requested = 0;
DiagLockFlag = 0;
if (AbleResponseType == Ser10BanResponse)
{
if (bit_is_clear(UDS_ISO14229_Transfer[0], 7))
{
NegRes.code = requestCorrectlyReceivedResponsePending;
UDS_Service_Response(si, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
Write_App_InValid(Jump_To_Boot_Need_Answer);
for (i = 0; i < 250; ++i)
{
__NOP();
}
__NVIC_SystemReset();
}
else
{
Write_App_InValid(Jump_To_Boot_No_Answer);
for (i = 0; i < 250; ++i)
{
__NOP();
}
__NVIC_SystemReset();
}
}
else
{
NegRes.code = requestCorrectlyReceivedResponsePending;
UDS_Service_Response(si, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
Write_App_InValid(Jump_To_Boot_Need_Answer);
for (i = 0; i < 250; ++i)
{
__NOP();
}
__NVIC_SystemReset();
}
}
else if (ExtendedDiagnosticSession == SubFunction)
{
S3_ServerEN = 1;
S3_Server_refresh = 1;
SessionType = ExtendedDiagnosticSession;
Services27_01_Requested = 0;
DiagLockFlag = 0;
if (AbleResponseType == Ser10BanResponse)
{
if (bit_is_clear(UDS_ISO14229_Transfer[0], 7))
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 5, UDS_ISO14229_Transfer);
}
}
else
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 5, UDS_ISO14229_Transfer);
}
}
}
else
{
if (DIAG_ID_Rx_FUN == FunorPhy)
{
if ((NrcCode != 0x11) && (NrcCode != 0x12) && (NrcCode != 0x13) && (NrcCode != 0x7E) && (NrcCode != 0x7F) && (NrcCode != 0x31))
{
NegRes.code = NrcCode;
UDS_Service_Response(si, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
return;
}
}
else
{
NegRes.code = NrcCode;
UDS_Service_Response(si, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
return;
}
}
}
/******************************************************************************
11# - ECUReset
******************************************************************************/
static const uint8_t Ser11BanResponse = AbleResponseType;
static const uint8_t Ser11Sub [] = {HardReset};
static const uint8_t Ser11MinLen [] = {1};
static const uint8_t Ser11SubLen [] = {1};
static const uint8_t Ser11UnlockLevel [] = {NoNeed};
static const uint8_t Ser11SupportSession = ProgrammingMode | ExtendedDiagnosticMode;
static const uint8_t Ser11SubSupportSession [] = {ProgrammingMode | ExtendedDiagnosticMode};
void UDS_Service_11_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data)
{
uint8_t si = ECUReset;
uint8_t NrcCode = 0;
uint8_t Index = 0;
uint8_t SubFunction = 0;
uint16_t i;
uint16_t Service11DiagDataLength = A_Length;
uint16_t FunorPhy = A_TA_type;
for (i = 0; i < Service11DiagDataLength; ++i)
{
UDS_ISO14229_Transfer[i] = *(A_Data + i);
}
if ((0 == NrcCode) && (DIAG_ID_Rx_FUN == FunorPhy))
{
NrcCode = serviceNotSupported;
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC7FFilter(Ser11SupportSession);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC13Filter(MinLengthType, Service11DiagDataLength, Ser11MinLen, Index);
}
if (0 == NrcCode)
{
if (AbleResponseType == Ser11BanResponse)
{
SubFunction = UDS_ISO14229_Transfer[0] & 0x7F;
}
else
{
SubFunction = UDS_ISO14229_Transfer[0];
}
NrcCode = SerXXNRC12Filter(SubFunction, Ser11Sub, sizeof(Ser11Sub), &Index);
}
if (0 == NrcCode && Index < sizeof(Ser11UnlockLevel))
{
NrcCode = SerXXNRC33Filter(Ser11UnlockLevel, Index);
}
if (0 == NrcCode && (Index < sizeof(Ser11SubSupportSession)))
{
NrcCode = SerXXNRC7EFilter(Ser11SubSupportSession, Index);
}
if (0 == NrcCode && (Index < sizeof(Ser11SubLen)))
{
NrcCode = SerXXNRC13Filter(SubLengthType, Service11DiagDataLength, Ser11SubLen, Index);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC22Filter();
}
if (0 == NrcCode)
{
if (HardReset == SubFunction)
{
if (AbleResponseType == Ser11BanResponse)
{
if (bit_is_clear(UDS_ISO14229_Transfer[0], 7))
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer);
}
}
else
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer);
}
i = 900;
while (--i)
{
__NOP();
}
__NVIC_SystemReset();
}
}
else
{
if (DIAG_ID_Rx_FUN == FunorPhy)
{
if ((NrcCode != 0x11) && (NrcCode != 0x12) && (NrcCode != 0x13) && (NrcCode != 0x7E) && (NrcCode != 0x7F) && (NrcCode != 0x31))
{
NegRes.code = NrcCode;
UDS_Service_Response(si, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
return;
}
}
else
{
NegRes.code = NrcCode;
UDS_Service_Response(si, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
return;
}
}
}
/******************************************************************************
22# - ReadDataByIdentifier
******************************************************************************/
static const uint8_t Ser22BanResponse = DisableResponseType;
static const uint8_t Ser22Sub [] = {0xFF};
static const uint8_t Ser22MinLen [] = {2};
static const uint8_t Ser22SubLen [] = {2};
static const uint16_t Ser22DIDList [] = {0xF195, 0xF193, 0xF180, 0xF187, 0x1024, 0x1028, 0xF184,/*0x2024*/ };
static const uint8_t Ser22UnlockLevel [] = {NoNeed};
static const uint8_t Ser22SupportSession = DefaultMode | ProgrammingMode | ExtendedDiagnosticMode;
static const uint8_t Ser22SubSupportSession [] = {DefaultMode | ProgrammingMode | ExtendedDiagnosticMode};
void UDS_Service_22_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data)
{
uint8_t i;
uint8_t si = ReadDataByIdentifier;
uint8_t NrcCode = 0;
uint8_t Index = 0;
uint8_t SubFunction = 0;
uint16_t DID;
uint16_t Service22DiagDataLength = A_Length;
uint16_t FunorPhy = A_TA_type;
for (i = 0; i < Service22DiagDataLength; ++i)
{
UDS_ISO14229_Transfer[i] = *(A_Data + i);
}
if ((0 == NrcCode) && (DIAG_ID_Rx_FUN == FunorPhy))
{
NrcCode = serviceNotSupported;
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC7FFilter(Ser22SupportSession);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC13Filter(MinLengthType, Service22DiagDataLength, Ser22MinLen, Index);
}
if (0 == NrcCode)
{
if (AbleResponseType == Ser22BanResponse)
{
SubFunction = UDS_ISO14229_Transfer[0] & 0x7F;
}
else
{
SubFunction = UDS_ISO14229_Transfer[0];
}
NrcCode = SerXXNRC12Filter(SubFunction, Ser22Sub, 0, &Index);
}
if (0 == NrcCode && Index < sizeof(Ser22UnlockLevel))
{
NrcCode = SerXXNRC33Filter(Ser22UnlockLevel, Index);
}
if (0 == NrcCode && (Index < sizeof(Ser22SubSupportSession)))
{
NrcCode = SerXXNRC7EFilter(Ser22SubSupportSession, Index);
}
if (0 == NrcCode && (Index < sizeof(Ser22SubLen)))
{
NrcCode = SerXXNRC13Filter(SubLengthType, Service22DiagDataLength, Ser22SubLen, Index);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC22Filter();
}
if (0 == NrcCode)
{
DID = ((uint16_t)UDS_ISO14229_Transfer[0] << 8) | UDS_ISO14229_Transfer[1];
NrcCode = SerXXNRC31DIDFilter(DID, Ser22DIDList, (sizeof(Ser22DIDList) / 2), &Index);
}
if (0 == NrcCode)
{
switch (DID)
{
case 0xF195: // 读软件版本号
for (i = 0; i < 6; i++)
{
UDS_ISO14229_Transfer[i + 2] = MCU_SWversion[i];
}
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 2 + 6, UDS_ISO14229_Transfer);
break;
case 0xF193: // 读硬件版本号
for (i = 0; i < 6; i++)
{
UDS_ISO14229_Transfer[i + 2] = MCU_HWversion[i];
}
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 2 + 6, UDS_ISO14229_Transfer);
break;
case 0xF180: // 读硬件版本号
for (i = 0; i < 6; i++)
{
UDS_ISO14229_Transfer[i + 2] = MCU_FBLversion[i];
}
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 2 + 6, UDS_ISO14229_Transfer);
break;
case 0xF187: // 读零件号
for (i = 0; i < 16; i++)
{
UDS_ISO14229_Transfer[i + 2] = MCU_PartNumber[i];
}
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 2 + 16, UDS_ISO14229_Transfer);
break;
case 0x1024: // 读内部版本号
UDS_ISO14229_Transfer[0] = 0x10u;
UDS_ISO14229_Transfer[1] = 0x24u;
UDS_ISO14229_Transfer[2] = 'A';
UDS_ISO14229_Transfer[3] = '_';
UDS_ISO14229_Transfer[4] = 'V';
UDS_ISO14229_Transfer[5] = (uint8_t)((INTLV >> 8u) & 0x0Fu) + 0x30u;
UDS_ISO14229_Transfer[6] = '.';
UDS_ISO14229_Transfer[7] = (uint8_t)((INTLV >> 4u) & 0x0Fu) + 0x30u;
UDS_ISO14229_Transfer[8] = (uint8_t)(INTLV & 0x0Fu) + 0x30u;
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 2 + 7, UDS_ISO14229_Transfer);
break;
case 0x1028: // 读内部版本号
UDS_ISO14229_Transfer[0] = 0x10u;
UDS_ISO14229_Transfer[1] = 0x28u;
UDS_ISO14229_Transfer[2] = '2';
UDS_ISO14229_Transfer[3] = '0';
UDS_ISO14229_Transfer[4] = (uint8_t)((PROG_Y >> 4u) & 0x0Fu) + 0x30u;
UDS_ISO14229_Transfer[5] = (uint8_t)(PROG_Y & 0x0Fu) + 0x30u;
UDS_ISO14229_Transfer[6] = (uint8_t)((PROG_M >> 4u) & 0x0Fu) + 0x30u;
UDS_ISO14229_Transfer[7] = (uint8_t)(PROG_M & 0x0Fu) + 0x30u;
UDS_ISO14229_Transfer[8] = (uint8_t)((PROG_D >> 4u) & 0x0Fu) + 0x30u;
UDS_ISO14229_Transfer[9] = (uint8_t)(PROG_D & 0x0Fu) + 0x30u;
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 2 + 8, UDS_ISO14229_Transfer);
break;
case 0xF184: // UUID
for (i = 0; i < 32; i++)
{
UDS_ISO14229_Transfer[i + 2] = Ser2EDataForDFlash.DID_F184[i];
}
UDS_Service_Response(0x22, POSITIVE_RSP, DIAG_ID_Tx, 2 + 32, UDS_ISO14229_Transfer);
break;
// case 0x2024: // ESP32内部版本号
// UDS_ISO14229_Transfer[3] = BlueTooth.ESP32_SWV;
// UDS_Service_Response(0x22, POSITIVE_RSP, DIAG_ID_Tx, 2 + 1, UDS_ISO14229_Transfer);
// break;
default:
if (FunorPhy == DIAG_ID_Rx_FUN)
{
return;
}
NegRes.code = requestOutOfRange;
UDS_Service_Response ( 0x22, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
break;
}
}
else
{
if (DIAG_ID_Rx_FUN == FunorPhy)
{
if ((NrcCode != 0x11) && (NrcCode != 0x12) && (NrcCode != 0x13) && (NrcCode != 0x7E) && (NrcCode != 0x7F) && (NrcCode != 0x31))
{
NegRes.code = NrcCode;
UDS_Service_Response(si, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
return;
}
}
else
{
NegRes.code = NrcCode;
UDS_Service_Response(si, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
return;
}
}
}
void UDS_Service_2E_Indication ( uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data )
{
uint16_t i;
uint16_t DID;
uint8_t Data[8];
uint8_t Service2EDiagDataLength;
uint16_t FunorPhy = 0;
Service2EDiagDataLength = A_Length;
S3_ServerCnt = 0;
FunorPhy = A_TA_type;
for (i = 0; i < Service2EDiagDataLength; ++i)
{
UDS_ISO14229_Transfer[i] = *(A_Data + i);
}
if ( FunorPhy == 0X7DF )
return;
if ( DiagLockFlag == 0x00 )
{
NegRes.code = securityAccessDenied; //NRC33
UDS_Service_Response ( 0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
if ( Service2EDiagDataLength < 3 )
{
NegRes.code = incorrectMessageLength; //NRC13
UDS_Service_Response ( 0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
if( (SessionType == DefaultSession) || (SessionType == ProgrammingSession))
{
NegRes.code = serviceNotSupportedInActiveSession; //NRC7F
UDS_Service_Response ( 0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
DID = ((uint16_t)UDS_ISO14229_Transfer[0] << 8) | ((uint16_t)UDS_ISO14229_Transfer[1]);
switch ( DID )
{
case 0xF184: // 读指纹数据标识符
for (i = 0; i < 33; i++)
{
Data[i] = UDS_ISO14229_Transfer[i+2];
}
for (i = 0; i < (sizeof(Ser2EDataForDFlash.DID_F184)); i++)
{
Ser2EDataForDFlash.DID_F184[i] = Data[i];
}
Ser2EDataForDFlash.Flag = 0x5AA5A77Au;
// memcpy(Ser2EDataForDFlash.DID_F184, Data, sizeof(Ser2EDataForDFlash.DID_F184));
//擦除扇区
EraseSector (APP_DATA_WRITE);
//App程序状态和22服务数据全写进去
ProgramPage (APP_DATA_WRITE, sizeof(Ser2EDataForDFlash), (uint8_t *)(&Ser2EDataForDFlash));
UDS_Service_Response(0x2E, POSITIVE_RSP, DIAG_ID_Tx, 2, UDS_ISO14229_Transfer);
break;
default:
if ( FunorPhy == 0x7df )
{
return;
}
NegRes.code = requestOutOfRange;
UDS_Service_Response ( 0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
break;
}
}
void GetSeed(void)
{
uint8_t SeedHigh;
uint8_t SeedLow;
uint16_t tempbuffer;
tempbuffer = (uint16_t)(RANDOM);
SeedHigh = (uint8_t)(tempbuffer >> 8);
SeedLow = (uint8_t)(tempbuffer & 0xff);
Seed[0] = 0x31 + ~SeedHigh;
Seed[1] = 0x23 + ~SeedLow;
Seed[2] = 0x56 + SeedHigh;
Seed[3] = 0x71 + SeedLow;
}
const uint32_t KeyK = 0x00000201;
void CalculateKey(void)
{
uint32_t SaccSeed;
uint32_t KeyResult;
SaccSeed = ((uint32_t)Seed[0]) << 24 | ((uint32_t)Seed[1]) << 16 | ((uint32_t)Seed[2]) << 8 | ((uint32_t)Seed[3]);
KeyResult = (((SaccSeed >> 1) ^ SaccSeed) << 3) ^ (SaccSeed >> 2);
KeyResult = KeyResult ^ KeyK;
ValidSeedKey = KeyResult;
}
void CalculateKeyLv11(void)
{
uint32_t SaccSeed;
uint32_t KeyResult;
SaccSeed = (( uint32_t )Seed [ 0 ]) << 24 | (( uint32_t )Seed [ 1 ]) << 16 | (( uint32_t )Seed [ 2 ]) << 8 | (( uint32_t )Seed [ 3 ]);
KeyResult = (((SaccSeed >> 1) ^ SaccSeed) << 3) ^ (SaccSeed >> 2);
KeyResult = KeyResult ^ KeyK;
ValidSeedKey = KeyResult;
}
/******************************************************************************
27# - SecurityAccess
******************************************************************************/
static const uint8_t Ser27BanResponse = DisableResponseType;
static const uint8_t Ser27Sub [] = {requestSeed_LV1, sendKey_LV1};
static const uint8_t Ser27MinLen [] = {1};
static const uint8_t Ser27SubLen [] = {1, 5};
static const uint8_t Ser27UnlockLevel [] = {NoNeed, NoNeed};
static const uint8_t Ser27SupportSession = ProgrammingMode | ExtendedDiagnosticMode;
static const uint8_t Ser27SubSupportSession [] = {ProgrammingMode | ExtendedDiagnosticMode, ProgrammingMode | ExtendedDiagnosticMode};
void UDS_Service_27_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data)
{
uint8_t i;
uint8_t si = SecurityAccess;
uint8_t NrcCode = 0;
uint8_t Index = 0;
uint8_t SubFunction = 0;
uint16_t FunorPhy = A_TA_type;
uint16_t Service27DiagDataLength = A_Length;
uint32_t KeyReceive;
for (i = 0; i < Service27DiagDataLength; ++i)
{
UDS_ISO14229_Transfer[i] = *(A_Data + i);
}
if ((0 == NrcCode) && (DIAG_ID_Rx_FUN == FunorPhy))
{
NrcCode = serviceNotSupported;
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC7FFilter(Ser27SupportSession);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC13Filter(MinLengthType, Service27DiagDataLength, Ser27MinLen, Index);
}
if (0 == NrcCode)
{
if (AbleResponseType == Ser27BanResponse)
{
SubFunction = UDS_ISO14229_Transfer[0] & 0x7F;
}
else
{
SubFunction = UDS_ISO14229_Transfer[0];
}
NrcCode = SerXXNRC12Filter(SubFunction, Ser27Sub, sizeof(Ser27Sub), &Index);
}
if (0 == NrcCode && Index < sizeof(Ser27UnlockLevel))
{
NrcCode = SerXXNRC33Filter(Ser27UnlockLevel, Index);
}
if (0 == NrcCode && (Index < sizeof(Ser27SubSupportSession)))
{
NrcCode = SerXXNRC7EFilter(Ser27SubSupportSession, Index);
}
if (0 == NrcCode && (Index < sizeof(Ser27SubLen)))
{
NrcCode = SerXXNRC13Filter(SubLengthType, Service27DiagDataLength, Ser27SubLen, Index);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC22Filter();
}
if (0 == NrcCode)
{
if (1 == Wait10sFlag)
{
NrcCode = requiredTimeDelayNotExpired;
}
}
if (0 == NrcCode)
{
if (0 == Services27_01_Requested && sendKey_LV1 == SubFunction)
{
NrcCode = requestSequenceError;
}
}
if (0 == NrcCode)
{
KeyReceive = ((uint32_t)UDS_ISO14229_Transfer[1] << 24) | ((uint32_t)UDS_ISO14229_Transfer[2] << 16) | ((uint16_t)UDS_ISO14229_Transfer[3] << 8) | UDS_ISO14229_Transfer[4];
if (sendKey_LV1 == SubFunction && (KeyReceive == 0x00000000 || KeyReceive == 0xFFFFFFFF))
{
NrcCode = requestOutOfRange;
}
}
if (0 == NrcCode)
{
if (sendKey_LV1 == SubFunction && KeyReceive != ValidSeedKey)
{
Services27_01_Requested = 0;
Ser27_FlowCtrlCnt.Attemptcnt++;
// WriteDFlashData(0x02u, (uint32_t *)&Ser27_FlowCtrlCnt.Flag, sizeof(Ser27_FlowCtrlCnt) / 4u, NeedWait);
NrcCode = invalidKey;
}
}
if (0 == NrcCode || invalidKey == NrcCode)
{
if (sendKey_LV1 == SubFunction)
{
if (AttemptMaxCnt <= Ser27_FlowCtrlCnt.Attemptcnt)
{
Wait10sFlag = 1;
NrcCode = exceedNumberOfAttempts;
}
}
if (requestSeed_LV1 == SubFunction)
{
Ser27_FlowCtrlCnt.Attemptcnt = Ser27_FlowCtrlCnt.RequestSeedCnt;
Ser27_FlowCtrlCnt.RequestSeedCnt++;
// WriteDFlashData(0x02u, (uint32_t *)&Ser27_FlowCtrlCnt.Flag, sizeof(Ser27_FlowCtrlCnt) / 4u, NeedWait);
if (RequestSeedMaxCnt <= Ser27_FlowCtrlCnt.RequestSeedCnt)
{
Wait10sFlag = 1;
NrcCode = exceedNumberOfAttempts;
}
}
}
if (0 == NrcCode)
{
if (requestSeed_LV1 == SubFunction)
{
if (NormalKeyLock == DiagLockFlag)
{
Services27_01_Requested = 1;
do
{
GetSeed();
} while (Seed[0] == 0 && Seed[1] == 0 && Seed[2] == 0 && Seed[3] == 0);
UDS_ISO14229_Transfer[1] = Seed[0];
UDS_ISO14229_Transfer[2] = Seed[1];
UDS_ISO14229_Transfer[3] = Seed[2];
UDS_ISO14229_Transfer[4] = Seed[3];
if (AbleResponseType == Ser27BanResponse)
{
if (bit_is_clear(UDS_ISO14229_Transfer[0], 7))
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 5, UDS_ISO14229_Transfer);
}
}
else
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 5, UDS_ISO14229_Transfer);
}
CalculateKey();
}
else if (NormalKeyUnlock == DiagLockFlag)
{
UDS_ISO14229_Transfer[1] = 0;
UDS_ISO14229_Transfer[2] = 0;
UDS_ISO14229_Transfer[3] = 0;
UDS_ISO14229_Transfer[4] = 0;
if (AbleResponseType == Ser27BanResponse)
{
if (bit_is_clear(UDS_ISO14229_Transfer[0], 7))
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 5, UDS_ISO14229_Transfer);
}
}
else
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 5, UDS_ISO14229_Transfer);
}
}
}
else if (sendKey_LV1 == SubFunction)
{
Services27_01_Requested = 0;
Ser27_FlowCtrlCnt.RequestSeedCnt = 0;
Ser27_FlowCtrlCnt.Attemptcnt = 0;
DiagLockFlag = NormalKeyUnlock;
if (AbleResponseType == Ser27BanResponse)
{
if (bit_is_clear(UDS_ISO14229_Transfer[0], 7))
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer);
}
}
else
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer);
}
// WriteDFlashData(0x02u, (uint32_t *)&Ser27_FlowCtrlCnt.Flag, sizeof(Ser27_FlowCtrlCnt) / 4u, NeedWait);
}
}
else
{
if (DIAG_ID_Rx_FUN == FunorPhy)
{
if ((NrcCode != 0x11) && (NrcCode != 0x12) && (NrcCode != 0x13) && (NrcCode != 0x7E) && (NrcCode != 0x7F) && (NrcCode != 0x31))
{
NegRes.code = NrcCode;
UDS_Service_Response(si, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
return;
}
}
else
{
NegRes.code = NrcCode;
UDS_Service_Response(si, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
return;
}
}
}
/******************************************************************************
28# - CommunicationControl
******************************************************************************/
static const uint8_t Ser28BanResponse = AbleResponseType;
static const uint8_t Ser28Sub [] = {enableRxAndTx,/*enableRxAndDisableTx, disableRxAndEnableTx, */disableRxAndTx};
static const uint8_t Ser28MinLen [] = {2};
static const uint8_t Ser28SubLen [] = {2, /*2, 2,*/ 2};
static const uint8_t Ser28UnlockLevel [] = {NoNeed, NoNeed, NoNeed, NoNeed};
static const uint8_t Ser28SupportSession = ProgrammingMode | ExtendedDiagnosticMode;
static const uint8_t Ser28SubSupportSession [] = {ProgrammingMode | ExtendedDiagnosticMode, ProgrammingMode | ExtendedDiagnosticMode, ProgrammingMode | ExtendedDiagnosticMode, ProgrammingMode | ExtendedDiagnosticMode};
void UDS_Service_28_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data)
{
uint8_t i;
uint8_t si = CommunicationControl;
uint8_t NrcCode = 0;
uint8_t Index = 0;
uint8_t SubFunction = 0;
uint16_t FunorPhy = A_TA_type;
uint16_t Service28DiagDataLength = A_Length;
for (i = 0; i < Service28DiagDataLength; ++i)
{
UDS_ISO14229_Transfer[i] = *(A_Data + i);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC7FFilter(Ser28SupportSession);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC13Filter(MinLengthType, Service28DiagDataLength, Ser28MinLen, Index);
}
if (0 == NrcCode)
{
if (AbleResponseType == Ser28BanResponse)
{
SubFunction = UDS_ISO14229_Transfer[0] & 0x7F;
}
else
{
SubFunction = UDS_ISO14229_Transfer[0];
}
NrcCode = SerXXNRC12Filter(SubFunction, Ser28Sub, sizeof(Ser28Sub), &Index);
}
if (0 == NrcCode && Index < sizeof(Ser28UnlockLevel))
{
NrcCode = SerXXNRC33Filter(Ser28UnlockLevel, Index);
}
if (0 == NrcCode && (Index < sizeof(Ser28SubSupportSession)))
{
NrcCode = SerXXNRC7EFilter(Ser28SubSupportSession, Index);
}
if (0 == NrcCode && (Index < sizeof(Ser28SubLen)))
{
NrcCode = SerXXNRC13Filter(SubLengthType, Service28DiagDataLength, Ser28SubLen, Index);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC22Filter();
}
// if (0 == NrcCode)
// {
// if (normalCommunicationMessages != UDS_ISO14229_Transfer[1])
// {
// NrcCode = requestOutOfRange;
// }
// }
if (0 == NrcCode)
{
if (enableRxAndTx == SubFunction)
{
if (UDS_ISO14229_Transfer[1] & normalCommunicationMessages)
{
CAN_RX_SetEnable(&CAN_CH0_CanMsgOp, CAN_N_RX_Enable);
CAN_TX_SetEnable(&CAN_CH0_CanMsgTxOp, CAN_N_TX_Enable);
}
if (UDS_ISO14229_Transfer[1] & networkManagementCommunicationMessages)
{
}
}
else if (disableRxAndTx == SubFunction)
{
if (UDS_ISO14229_Transfer[1] & normalCommunicationMessages)
{
CAN_RX_SetEnable(&CAN_CH0_CanMsgOp, CAN_N_RX_Disable);
CAN_TX_SetEnable(&CAN_CH0_CanMsgTxOp, CAN_N_TX_Disable);
}
if (UDS_ISO14229_Transfer[1] & networkManagementCommunicationMessages)
{
}
if (UDS_ISO14229_Transfer[1] & networkManagementCommunicationMessagesnormalCommunicationMessages)
{
}
}
if (AbleResponseType == Ser28BanResponse)
{
if (bit_is_clear(UDS_ISO14229_Transfer[0], 7))
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer);
}
}
else
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer);
}
}
else
{
if (DIAG_ID_Rx_FUN == FunorPhy)
{
if ((NrcCode != 0x11) && (NrcCode != 0x12) && (NrcCode != 0x13) && (NrcCode != 0x7E) && (NrcCode != 0x7F) && (NrcCode != 0x31))
{
NegRes.code = NrcCode;
UDS_Service_Response(si, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
return;
}
}
else
{
NegRes.code = NrcCode;
UDS_Service_Response(si, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
return;
}
}
}
/******************************************************************************
3E# - TesterPresent
******************************************************************************/
static const uint8_t Ser3EBanResponse = AbleResponseType;
static const uint8_t Ser3ESub [] = {0x00};
static const uint8_t Ser3EMinLen [] = {1};
static const uint8_t Ser3ESubLen [] = {1};
static const uint8_t Ser3EUnlockLevel [] = {NoNeed};
static const uint8_t Ser3ESupportSession = DefaultMode | ProgrammingMode | ExtendedDiagnosticMode;
static const uint8_t Ser3ESubSupportSession [] = {DefaultMode | ProgrammingMode | ExtendedDiagnosticMode};
void UDS_Service_3E_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data)
{
uint8_t i;
uint8_t si = TesterPresent;
uint8_t NrcCode = 0;
uint8_t Index = 0;
uint8_t SubFunction = 0;
uint16_t Service3EDiagDataLength = A_Length;
uint16_t FunorPhy = A_TA_type;
for (i = 0; i < Service3EDiagDataLength; ++i)
{
UDS_ISO14229_Transfer[i] = *(A_Data + i);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC7FFilter(Ser3ESupportSession);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC13Filter(MinLengthType, Service3EDiagDataLength, Ser3EMinLen, Index);
}
if (0 == NrcCode)
{
if (AbleResponseType == Ser3EBanResponse)
{
SubFunction = UDS_ISO14229_Transfer[0] & 0x7F;
}
else
{
SubFunction = UDS_ISO14229_Transfer[0];
}
NrcCode = SerXXNRC12Filter(SubFunction, Ser3ESub, sizeof(Ser3ESub), &Index);
}
if (0 == NrcCode && Index < sizeof(Ser3EUnlockLevel))
{
NrcCode = SerXXNRC33Filter(Ser3EUnlockLevel, Index);
}
if (0 == NrcCode && (Index < sizeof(Ser3ESubSupportSession)))
{
NrcCode = SerXXNRC7EFilter(Ser3ESubSupportSession, Index);
}
if (0 == NrcCode && (Index < sizeof(Ser3ESubLen)))
{
NrcCode = SerXXNRC13Filter(SubLengthType, Service3EDiagDataLength, Ser3ESubLen, Index);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC22Filter();
}
if (0 == NrcCode)
{
if (0x00 == SubFunction)
{
S3_Server_refresh = 1;
if (AbleResponseType == Ser3EBanResponse)
{
if (bit_is_clear(UDS_ISO14229_Transfer[0], 7))
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer);
}
}
else
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer);
}
}
}
else
{
if (DIAG_ID_Rx_FUN == FunorPhy)
{
if ((NrcCode != 0x11) && (NrcCode != 0x12) && (NrcCode != 0x13) && (NrcCode != 0x7E) && (NrcCode != 0x7F) && (NrcCode != 0x31))
{
NegRes.code = NrcCode;
UDS_Service_Response(si, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
return;
}
}
else
{
NegRes.code = NrcCode;
UDS_Service_Response(si, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
return;
}
}
}
/******************************************************************************
85# - ControlDTCSetting
******************************************************************************/
static const uint8_t Ser85BanResponse = AbleResponseType;
static const uint8_t Ser85Sub [] = {DTCSettingOn, DTCSettingOff};
static const uint8_t Ser85MinLen [] = {1};
static const uint8_t Ser85SubLen [] = {1, 1};
static const uint8_t Ser85UnlockLevel [] = {NoNeed, NoNeed};
static const uint8_t Ser85SupportSession = ProgrammingMode | ExtendedDiagnosticMode;
static const uint8_t Ser85SubSupportSession [] = {ProgrammingMode | ExtendedDiagnosticMode};
void UDS_Service_85_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data)
{
uint8_t i;
uint8_t si = ControlDTCSetting;
uint8_t NrcCode = 0;
uint8_t Index = 0;
uint8_t SubFunction = 0;
uint16_t Service85DiagDataLength = A_Length;
uint16_t FunorPhy = A_TA_type;
for (i = 0; i < Service85DiagDataLength; ++i)
{
UDS_ISO14229_Transfer[i] = *(A_Data + i);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC7FFilter(Ser85SupportSession);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC13Filter(MinLengthType, Service85DiagDataLength, Ser85MinLen, Index);
}
if (0 == NrcCode)
{
if (AbleResponseType == Ser85BanResponse)
{
SubFunction = UDS_ISO14229_Transfer[0] & 0x7F;
}
else
{
SubFunction = UDS_ISO14229_Transfer[0];
}
NrcCode = SerXXNRC12Filter(SubFunction, Ser85Sub, sizeof(Ser85Sub), &Index);
}
if (0 == NrcCode && Index < sizeof(Ser85UnlockLevel))
{
NrcCode = SerXXNRC33Filter(Ser85UnlockLevel, Index);
}
if (0 == NrcCode && (Index < sizeof(Ser85SubSupportSession)))
{
NrcCode = SerXXNRC7EFilter(Ser85SubSupportSession, Index);
}
if (0 == NrcCode && (Index < sizeof(Ser85SubLen)))
{
NrcCode = SerXXNRC13Filter(SubLengthType, Service85DiagDataLength, Ser85SubLen, Index);
}
if (0 == NrcCode)
{
NrcCode = SerXXNRC22Filter();
}
if (0 == NrcCode)
{
if (DTCSettingOn == SubFunction)
{
// CAN_DTC_OFF = 0;
}
else if (DTCSettingOff == SubFunction)
{
// CAN_DTC_OFF = 1;
}
if (AbleResponseType == Ser85BanResponse)
{
if (bit_is_clear(UDS_ISO14229_Transfer[0], 7))
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer);
}
}
else
{
UDS_Service_Response(si, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer);
}
}
else
{
if (DIAG_ID_Rx_FUN == FunorPhy)
{
if ((NrcCode != 0x11) && (NrcCode != 0x12) && (NrcCode != 0x13) && (NrcCode != 0x7E) && (NrcCode != 0x7F) && (NrcCode != 0x31))
{
NegRes.code = NrcCode;
UDS_Service_Response(si, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
return;
}
}
else
{
NegRes.code = NrcCode;
UDS_Service_Response(si, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
return;
}
}
}
/*************IGN on,S3 Timeout****************/
void DIAG_InitParameter(void)
{
S3_ServerCnt = 0;
S3_ServerEN = 0;
SessionType = DefaultSession;
DiagLockFlag = 0;
RANDOM = 1573;
Services27_01_Requested = 0;
}
/******************************************************************************
�� �� ����UDS_ISO14229_Services.h
����������ISO 14229 �淶�涨����Ϸ���������˷���ʵ�ֺ���ͷ�ļ�
�� �ߣ�����
�� ����V1.0
�� �ڣ�2016.11.1
******************************************************************************/
/******************************************************************************
��Ϸ����OSIģ��ӳ��
===============================================================================
* NO. OSI Layer Diagnostics services
-------------------------------------------------------------------------------
* 7 Application ISO 14229-1 ISO 14229-3
6 Presentation -
* 5 Session ISO 14229-2
4 Transport ISO 15765-2
3 Network ISO 15765-2
2 Data Link ISO 11898
1 Physical ISO 11898
===============================================================================
******************************************************************************/
#ifndef _UDS_ISO14229_SERVICES_H_
#define _UDS_ISO14229_SERVICES_H_
#include "UDS_ISO14229_Server_Config.h"
/**
*DFlash
*/
#define NoNeedWait 0x00u
#define NeedWait 0x01u
#define APP_STATUS_ADDR (0x501000)
#define APP_DATA_INFO (0x501400)
#define APP_DATA_WRITE (0x501800)
#define Data_Flash_Addr_BootValid_OFFSET 0x00000000
#define Data_Flash_Addr_DiagReceive_OFFSET 0x00002000
#define Data_Flash_Addr_Diag2E_OFFSET 0x00004000
#define Data_Flash_Addr_DiagDTC_OFFSET 0x00006000
#define Data_Flash_Addr_GHdata_OFFSET 0x0000A000 // ��������
#define Jump_To_Boot_Need_Answer 0xA77A3AA3
#define Jump_To_Boot_No_Answer 0xA77A8AA8
#define Flag_App_OTAStatus 0x3663B88B // ����Boot��ԭ������ΪOTA
#define EnableInterrupts \
{ \
__asm CLI; \
}
#define DisableInterrupts \
{ \
__asm SEI; \
}
/*-----------------------------------------------------------------------------
Response
-----------------------------------------------------------------------------*/
#define POSITIVE_RSP 0x00
#define NEGATIVE_RSP (! POSITIVE_RSP)
/*-----------------------------------------------------------------------------
SPRMB
-----------------------------------------------------------------------------*/
#define AbleResponseType 0x00
#define DisableResponseType (! AbleResponseType)
/*-----------------------------------------------------------------------------
NRC13 check type
-----------------------------------------------------------------------------*/
#define MinLengthType 0x00
#define SubLengthType (! MinLengthType)
/*-----------------------------------------------------------------------------
Session mode
-----------------------------------------------------------------------------*/
#define DefaultMode 0x01
#define ProgrammingMode 0x02
#define ExtendedDiagnosticMode 0x04
/*----------------------------------------------- ------------------------------
Security level
-----------------------------------------------------------------------------*/
#define NoNeed 0x00
#define NeedLevel1 0x01
#define NeedLevel2 0x02
/******************************************************************************
Function and subFunction
Diagnostic Session
*******************************************************************************/
#define DiagnosticSessionControl 0x10
#define DefaultSession 0x01
#define ProgrammingSession 0x02
#define ExtendedDiagnosticSession 0x03
/******************************************************************************
Function and subFunction
ECUReset
********************************************************************************/
#define ECUReset 0x11
#define HardReset 0x01
#define SoftReset 0x03
/******************************************************************************
Function and subFunction
ClearDiagnosticInformation
********************************************************************************/
#define ClearDiagnosticInformation 0x14
/******************************************************************************
Function and subFunction
ReadDTCInformation
********************************************************************************/
#define ReadDTCInformation 0x19
#define Error 0x09
#define NoError 0x08
#define OTA_None 0x00
#define OTA_Reqed 0x01
#define OTA_Quit 0x02
// typedef void (*pfuMsgLost)(void);
// typedef void (*pfuMsgOk)(void);
// typedef struct
// {
// const uint16_t Msg_ID;
// volatile uint16_t *DTC_NodeLostCnt;
// volatile uint8_t *DTC_NodeLostFlag;
// const uint16_t DTC_LostPeriod;
// pfuMsgLost pfuLostHandleCBK;
// pfuMsgOk pfuOkHandleCBK;
// } DTC_NodeLostType;
#define _CLRBIT(p, b) p &= ~(1 << b)
#define _SETBIT(p, b) p |= (1 << b)
#define _bit_is_set(p, b) p & (1 << b)
#define CLRBIT(p, b) p &= ~(1 << b)
#define SETBIT(p, b) p |= (1 << b)
#define bit_is_set(p, b) p & (1 << b)
#define bit_is_clear(p, b) ! (p & (1 << b))
#define bit_2_set(p, b) ((p >> b) & 0x03)
#define bit_3_set(p, b) ((p >> b) & 0x07)
#define bit_4_set(p, b) ((p >> b) & 0x0F)
#define bit_5_set(p, b) ((p >> b) & 0x1F)
#define bit_6_set(p, b) ((p >> b) & 0x3F)
#define bit_7_set(p, b) ((p >> b) & 0x7F)
/******************************************************************************
Function and subFunction
ReadDataByIdentifier
********************************************************************************/
#define ReadDataByIdentifier 0x22
/******************************************************************************
Function and subFunction
SecurityAccess
********************************************************************************/
#define SecurityAccess 0x27
#define requestSeed_LV1 0x01
#define sendKey_LV1 0x02
// #define requestSeed_LV3 0x03
// #define sendKey_LV3 0x04
// #define requestSeed_LV5 0x05
// #define sendKey_LV5 0x06
// #define requestSeed_LV11 0x11
// #define sendKey_LV11 0x12
#define NormalKeyUnlock 0x01
#define NormalKeyLock 0x00
#define BootKeyUnlock 0x02
#define BootKeyLock 0x00
#define RequestSeedMaxCnt 0x04
#define AttemptMaxCnt 0x03
#define FLASH_SECTOR_SIZE 0x400
/******************************************************************************
Function and subFunction and type
CommunicationControl
********************************************************************************/
#define CommunicationControl 0x28
#define enableRxAndTx 0x00
#define enableRxAndDisableTx 0x01
#define disableRxAndEnableTx 0x02
#define disableRxAndTx 0x03
#define normalCommunicationMessages 0x01
#define networkManagementCommunicationMessages 0x02
#define networkManagementCommunicationMessagesnormalCommunicationMessages 0x03
/************************28SerStart*********************/
#define DIAG_COM_NOR_TX 0x01
#define DIAG_COM_NOR_RX 0x02
#define DIAG_COM_NW_TX 0x04
#define DIAG_COM_NW_RX 0x08
#define DIAG_SET_COM_DISABLE(Var, BitField, Type) ((Var) |= ( Type )(BitField))
#define DIAG_SET_COM_ENABLE(Var, BitField, Type) ((Var) &= (Type) ~( Type )(BitField))
#define DIAG_TST_BIT_SET(Var, BitField, Type) (0U != ((Var) & ( Type )(BitField)))
#define DIAG_TST_BIT_RESET(Var, BitField, Type) (0U == ((Var) & ( Type )(BitField)))
/************************28SerEnd***********************/
/******************************************************************************
Function and subFunction
WriteDataByIdentifier
********************************************************************************/
#define WriteDataByIdentifier 0x2E
/******************************************************************************
Function and subFunction
InputOutputControlByIdentifier
********************************************************************************/
#define InputOutputControlByIdentifier 0x2F
#define WhiteColor 0x01
#define BlackColor 0x02
#define RedColor 0x03
#define GreenColor 0x04
#define BlueColor 0x05
#define GaugeSpeed 0x01
#define GaugeTacho 0x02
#define GaugeFuel 0x03
#define GaugeEngCoolantTemp 0x04
#define ZeroPosition 0x00
#define HalfPosition 0x01
#define FullPosition 0x02
#define Clear 0x08
#define Contrl 0x03
#define Resume 0x00
/******************************************************************************
Function and subFunction
RoutineControl
********************************************************************************/
#define RoutineControl 0x31
#define startRoutine 0x01
#define stopRoutine 0x02
#define requestRoutineResults 0x03
#define MaintenanceReset 0X62F1
#define CheckMemory 0x0202
#define UpdateConditionCheck 0x0203
#define ECU_selftest 0xDFF0
#define EraseMemory 0xFF00
#define CheckProgrammingDependencies 0xFF01
#define RoutineCompletedSuccessfully 0x00
#define RoutineCompletedUnsuccessfully 0x05
/******************************************************************************
Function and subFunction
RequestDownload
********************************************************************************/
#define RequestDownload 0X34
#define LengthFormatIdentifier 0x20
#define Download 0x01
/******************************************************************************
Function and subFunction
TransferDataf
********************************************************************************/
#define TransferData 0x36
/******************************************************************************
Function and subFunction
RequestTransferExit
********************************************************************************/
#define RequestTransferExit 0x37
/******************************************************************************
Function and subFunction
TesterPresent
********************************************************************************/
#define TesterPresent 0x3E
/******************************************************************************
Function and subFunction
ControlDTCSetting
********************************************************************************/
#define ControlDTCSetting 0x85
#define DTCSettingOn 0x01
#define DTCSettingOff 0x02
/******************************************************************************
Supported negative response codes
*******************************************************************************/
#define positiveResponse 0x00
#define serviceNotSupported 0x11
#define subFunctionNotSupported 0x12
#define incorrectMessageLength 0x13
#define responseTooLong 0x14
#define conditionsNotCorrect 0x22
#define requestSequenceError 0x24
#define requestOutOfRange 0x31
#define securityAccessDenied 0x33
#define invalidKey 0x35
#define exceedNumberOfAttempts 0x36
#define requiredTimeDelayNotExpired 0x37
#define uploadDownloadNotAccepted 0x70
#define transferDataSuspended 0x71
#define generalProgrammingFailure 0x72
#define wrongBlockSequenceCounter 0x73
#define requestCorrectlyReceivedResponsePending 0x78
#define subfunctionNotSupportinActiveSession 0x7E
#define serviceNotSupportedInActiveSession 0x7F
#define engineIsRunning 0x83
#define engineIsNotRunning 0x84
#define engineRunTimeTooLow 0x85
#define voltageTooHigh 0x92
#define voltageTooLow 0x93
#define noErr 0
#define SRecRangeError 1
#define SRecOddError 2 // S-Record Size Must Be Even
#define FlashProgramError 3 // Flash Programming Error
#define FlashEraseError 4 // Flash Erase Error
#define BadHexData 5 // Bad Hex Data
#define SRecTooLong 6 // S-Record Too Long
#define CheckSumErr 7 // Checksum Error
#define UnknownPartID 8 // Unknown Part ID
#define SWV 0x100 // 0x100 = 1.00 software version 软件版本号
#define HWV 0x100 // 0x100 = 1.00 hardware version 硬件版本号
#define BTV 0x100 // 0x100 = 1.00 bootloader version boot程序版本号
#define INTLV 0x100 // 0x100 = 1.00 internal version 内部版本号
#define PROG_Y 0x24 // 0x24 = 2024年, program year
#define PROG_M 0x07 // 0x03 = 3月, program month
#define PROG_D 0x16 // 0x19 = 19日, program day
typedef struct
{
uint32_t Flag;
uint8_t Attemptcnt;
uint8_t RequestSeedCnt;
uint8_t AttemptIIcnt;
uint8_t RequestSeedIICnt;
} Ser27_FlowCtrlCntUnion;
typedef struct
{
uint32_t Flag;
uint8_t DID_F180[6];
uint8_t DID_F187[16];
uint8_t DID_F193[6];
uint8_t DID_F195[6];
uint8_t Filldata[2];
}DiagDFlashData;
extern DiagDFlashData DiagDataForDFlash;
typedef struct
{
uint32_t Flag;
uint8_t DID_F184[32];
} Ser2EDFlashData;
extern Ser2EDFlashData Ser2EDataForDFlash;
typedef struct
{
uint32_t Flag;
uint32_t APP_STATUS;
}DiagFlag;
extern DiagFlag DiagDataForFlag;
typedef struct
{
uint8_t Para;
uint8_t code;
uint8_t OpCode;
} DiagSendDataNeg;
void UDS_Service_10_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
void UDS_Service_11_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
void UDS_Service_22_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
void UDS_Service_2E_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
void UDS_Service_27_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
void UDS_Service_28_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
void UDS_Service_3E_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
void UDS_Service_85_Indication(uint16_t A_TA_type, uint16_t A_Length, uint8_t *A_Data);
void S3_ServerCNTT(void);
void Randomcnt(void);
extern void DIAG_InitParameter(void);
void GetSeed(void);
void CalculateKey(void);
void CalculateKeyLv11(void);
typedef void (*InitFunction)(void);
/***********Local Functin*************/
uint8_t GetCurrentSession(void);
uint8_t SerXXNRC12Filter(uint8_t insub, const uint8_t *supportsub, uint8_t size, uint8_t *index);
uint8_t SerXXNRC13Filter(uint8_t type, uint8_t serlength, const uint8_t *length, uint8_t index);
uint8_t SerXXNRC22Filter(void);
uint8_t SerXXNRC31DIDFilter(uint16_t inDID, const uint16_t *DIDList, uint8_t size, uint8_t *index);
uint8_t SerXXNRC33Filter(const uint8_t *levelList, uint8_t index);
uint8_t SerXXNRC7EFilter(const uint8_t *SubSupportSession, uint8_t index);
uint8_t SerXXNRC7FFilter(uint8_t SupportSession);
extern void Data_Set_DiagPara(void);
void Write_App_InValid(uint32_t m32);
void Data_Read_DiagPara(void);
void DFlash_init(void);
void Data_Read_DiagPara(void);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment