tao_z
2022-06-01 0ff91e66071237834a1501c78648729c8c32f67a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
/**
  ******************************************************************************
  * @file      startup_Xl6600.s
  * @author    chipways
  * @version   V3.5.0
  * @date      11-March-2011
  * @brief     xl6600d High Density Devices vector table for Atollic toolchain.
  *            This module performs:
  *                - Set the initial SP
  *                - Set the initial PC == Reset_Handler,
  *                - Set the vector table entries with the exceptions ISR address,
  *                - Configure the clock system
  *                - Configure external SRAM mounted on xl6600d board
  *                  to be used as data memory (optional, to be enabled by user)
  *                - Branches to main in the C library (which eventually
  *                  calls main()).
  *            After Reset the Cortex-M3 processor is in Thread mode,
  *            priority is Privileged, and the Stack is set to Main.
  ******************************************************************************
  * @attention
  *
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  * TIME. AS A RESULT, CHIPWAYS SHALL NOT BE HELD LIABLE FOR ANY
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  *
  * <h2><center>&copy; COPYRIGHT 2011 CHIPWAYS</center></h2>
  ******************************************************************************
  */
 
    .syntax unified
    .cpu cortex-m3
    .fpu softvfp
    .thumb
    .align 4
 
.global    g_pfnVectors
.global    Default_Handler
 
.global GPIOA
.global GPIOB
.global GPIOC
.global IRQ
.global    SCB
.global    NVIC
.global SysTick
.global    SIM
.global    KBI0
.global    KBI1
.global    PIT
.global    RTC
.global    PWT
.global    UART0
.global    UART1
.global    UART2
.global    WDOG
.global    MCAN
.global    ICS
.global    OSC
.global    FTM0
.global    FTM1
.global    FTM2
.global    FMC
.global    I2C0
.global    I2C1
.global    SPI0
.global    SPI1
.global    PORT
.global    PMC
.global    ACMP0
.global    ACMP1
.global    ADC0
.global    CLMA
.global    CLMB
.global    CRC
.global    DMA
.global    EWM
 
/* start address for the initialization values of the .data section.
defined in linker script */
.word    _sidata
/* start address for the .data section. defined in linker script */
.word    _sdata
/* end address for the .data section. defined in linker script */
.word    _edata
/* start address for the .bss section. defined in linker script */
.word    _sbss
/* end address for the .bss section. defined in linker script */
.word    _ebss
 
.equ  BootRAM,        0xF1E0F85F
/**
 * @brief  This is the code that gets called when the processor first
 *          starts execution following a reset event. Only the absolutely
 *          necessary set is performed, after which the application
 *          supplied main() routine is called.
 * @param  None
 * @retval : None
*/
 
    .section    .text.Reset_Handler
    .align 4
    .weak    Reset_Handler
    .type    Reset_Handler, %function
Reset_Handler:
 
/* Copy the data segment initializers from flash to SRAM */
  movs    r1, #0
  b    LoopCopyDataInit
  
CopyDataInit:
    ldr    r3, =_sidata
    ldr    r3, [r3, r1]
    str    r3, [r0, r1]
    adds    r1, r1, #4
 
LoopCopyDataInit:
    ldr    r0, =_sdata
    ldr    r3, =_edata
    adds    r2, r0, r1
    cmp    r2, r3
    bcc    CopyDataInit
    ldr    r2, =_sbss
/*    b    LoopFillZerobss    */
     movs    r1, #0
    b    LoopCopyFalshCodeInit
 
CopyFlashCodeInit:
    ldr    r3, =_falsh_sidata
    ldr    r3, [r3, r1]
    str    r3, [r0, r1]
    adds    r1, r1, #4
 
LoopCopyFalshCodeInit:
    ldr    r0, =_flash_start
    ldr    r3, =_flash_end
    adds    r2, r0, r1
    cmp    r2, r3
    bcc    CopyFlashCodeInit
    ldr    r2, =_sbss
    b    LoopFillZerobss
    
/* Zero fill the bss segment. */
FillZerobss:
    movs    r3, #0
    str    r3, [r2], #4
 
LoopFillZerobss:
    ldr    r3, = _ebss
    cmp    r2, r3
    bcc    FillZerobss
/* Initialize the stack pointer */
     ldr    r0,=_estack
  mov    r13,r0
/* Call the clock system intitialization function.*/
    bl  SystemInit
/* Call static constructors */
    bl __libc_init_array
/* Call the application's entry point.*/
    bl    main
    bx    lr
.size    Reset_Handler, .-Reset_Handler
 
/**
 * @brief  This is the code that gets called when the processor receives an
 *         unexpected interrupt.  This simply enters an infinite loop, preserving
 *         the system state for examination by a debugger.
 *
 * @param  None
 * @retval : None
*/
    .section    .text.Default_Handler,"ax",%progbits
    .align 4
Default_Handler:
Infinite_Loop:
    b    Infinite_Loop
    .size    Default_Handler, .-Default_Handler
/******************************************************************************
*
* The minimal vector table for a Cortex M3.  Note that the proper constructs
* must be placed on this to ensure that it ends up at physical address
* 0x0000.0000.
*
******************************************************************************/
     .section    .isr_vector,"a",%progbits
     .align 4
    .type    g_pfnVectors, %object
    .size    g_pfnVectors, .-g_pfnVectors
 
 
g_pfnVectors:
    .word    _estack
    .word    Reset_Handler
    .word    NMI_Handler
    .word    HardFault_Handler
    .word    MemManage_Handler
    .word    BusFault_Handler
    .word    UsageFault_Handler
    .word    0
    .word    0
    .word    0
    .word    0
    .word    SVC_Handler
    .word    DebugMon_Handler
    .word    0
    .word    PendSV_Handler
    .word    SysTick_Handler
    .word    Reserved16_IRQHandler
    .word    Reserved17_IRQHandler
    .word    Reserved18_IRQHandler
    .word    Reserved19_IRQHandler
    .word    Reserved20_IRQHandler
    .word    FMC_IRQHandler
    .word    PMC_IRQHandler
    .word    DMA_IRQHandler
    .word    I2C0_IRQHandler
    .word    I2C1_IRQHandler
    .word    SPI0_IRQHandler
    .word    SPI1_IRQHandler
    .word    UART0_IRQHandler
    .word    UART1_IRQHandler
    .word    UART2_IRQHandler
    .word    ADC0_IRQHandler
    .word    ACMP0_IRQHandler
    .word    FTM0_IRQHandler
    .word    FTM1_IRQHandler
    .word    FTM2_IRQHandler
    .word    RTC_IRQHandler
    .word    ACMP1_IRQHandler
    .word    PIT_CH0_IRQHandler
    .word    PIT_CH1_IRQHandler
    .word    KBI0_IRQHandler
    .word    KBI1_IRQHandler
    .word    Reserved42_IRQHandler
    .word    ICS_IRQHandler
    .word    WDOG_IRQHandler
    .word    PWT_IRQHandler
    .word    MCAN_IRQHandler
    .word    EXTI0_IRQHandler
    .word    EXTI1_IRQHandler
    .word    EXTI2_IRQHandler
    .word    EXTI3_IRQHandler
    .word    EXTI4_IRQHandler
    .word    EXTI5_IRQHandler
    .word    EXTI6_IRQHandler
    .word    EXTI7_IRQHandler
    .word    EXTI8_IRQHandler
    .word    EXTI9_IRQHandler
    .word    EXTI10_IRQHandler
    .word    EXTI11_IRQHandler
    .word    EXTI12_IRQHandler
    .word    EXTI13_IRQHandler
    .word    EXTI14_IRQHandler
    .word    EXTI15_IRQHandler
    .word    EWM_IRQHandler
    .word    Reserved21_IRQHandler
    .word    BootRAM       /* @0x1E0. This is for boot in RAM mode for
                         xl6600d High Density devices. */
GPIOA:
    .word    0x40100000
GPIOB:
    .word    0x40100040
GPIOC:
    .word    0x40100080
IRQ:
    .word    0x40031000
SysTick:
    .word    0xE000E010
NVIC:
    .word    0xE000E100
SCB:
    .word    0xE000ED00
SIM:
    .word    0x40048000
KBI0:
    .word    0x40079000
KBI1:
    .word    0x4007A000
PIT:
    .word    0x40037000
RTC:
    .word    0x4003D000
PWT:
    .word    0x40033000
UART0:
    .word    0x4006A000
UART1:
    .word    0x4006B000
UART2:
    .word    0x4006C000
WDOG:
    .word    0x40052000
MCAN:
    .word    0x40024000
ICS:
    .word    0x40064000
OSC:
    .word    0x40065000
FTM0:
    .word    0x40038000
FTM1:
    .word    0x40039000
FTM2:
    .word    0x4003A000
FMC:
    .word    0x40020000
I2C0:
    .word    0x40066000
I2C1:
    .word    0x40067000
SPI0:
    .word    0x40076000
SPI1:
    .word    0x40077000
PORT:
    .word    0x40140000
PMC:
    .word    0x4007D000
ACMP0:
    .word    0x40073000
ACMP1:
    .word    0x40074000
ADC0:
    .word    0x4003B000
CLMA:
    .word    0x4007E000
CLMB:
    .word    0x4007F000
CRC:
    .word    0x40032000
DMA:
    .word    0x40080000
EWM:
    .word    0x4007C000
/*******************************************************************************
*
* Provide weak aliases for each Exception handler to the Default_Handler.
* As they are weak aliases, any function with the same name will override
* this definition.
*
*******************************************************************************/
 
  .weak    NMI_Handler
    .thumb_set NMI_Handler,Default_Handler
 
  .weak    HardFault_Handler
    .thumb_set HardFault_Handler,Default_Handler
 
  .weak    MemManage_Handler
    .thumb_set MemManage_Handler,Default_Handler
 
  .weak    BusFault_Handler
    .thumb_set BusFault_Handler,Default_Handler
 
    .weak    UsageFault_Handler
    .thumb_set UsageFault_Handler,Default_Handler
 
    .weak    SVC_Handler
    .thumb_set SVC_Handler,Default_Handler
 
    .weak    DebugMon_Handler
    .thumb_set DebugMon_Handler,Default_Handler
 
    .weak    PendSV_Handler
    .thumb_set PendSV_Handler,Default_Handler
 
    .weak    SysTick_Handler
    .thumb_set SysTick_Handler,Default_Handler
 
    .weak    Reserved16_IRQHandler
    .thumb_set Reserved16_IRQHandler,Default_Handler
 
    .weak    Reserved17_IRQHandler
    .thumb_set Reserved17_IRQHandler,Default_Handler
 
    .weak    Reserved18_IRQHandler
    .thumb_set Reserved18_IRQHandler,Default_Handler
 
    .weak    Reserved19_IRQHandler
    .thumb_set Reserved19_IRQHandler,Default_Handler
 
    .weak    Reserved20_IRQHandler
    .thumb_set Reserved20_IRQHandler,Default_Handler
 
    .weak    FMC_IRQHandler
    .thumb_set FMC_IRQHandler,Default_Handler
 
    .weak    PMC_IRQHandler
    .thumb_set PMC_IRQHandler,Default_Handler
 
    .weak    DMA_IRQHandler
    .thumb_set DMA_IRQHandler,Default_Handler
 
    .weak    I2C0_IRQHandler
    .thumb_set I2C0_IRQHandler,Default_Handler
 
    .weak    I2C1_IRQHandler
    .thumb_set I2C1_IRQHandler,Default_Handler
 
    .weak    SPI0_IRQHandler
    .thumb_set SPI0_IRQHandler,Default_Handler
 
    .weak    SPI1_IRQHandler
    .thumb_set SPI1_IRQHandler,Default_Handler
 
    .weak    UART0_IRQHandler
    .thumb_set UART0_IRQHandler,Default_Handler
 
    .weak    UART1_IRQHandler
    .thumb_set UART1_IRQHandler,Default_Handler
 
    .weak    UART2_IRQHandler
    .thumb_set UART2_IRQHandler,Default_Handler
 
    .weak    ADC0_IRQHandler
    .thumb_set ADC0_IRQHandler,Default_Handler
 
    .weak    ACMP0_IRQHandler
    .thumb_set ACMP0_IRQHandler,Default_Handler
 
    .weak    FTM0_IRQHandler
    .thumb_set FTM0_IRQHandler,Default_Handler
 
    .weak    FTM1_IRQHandler
    .thumb_set FTM1_IRQHandler,Default_Handler
 
    .weak    FTM2_IRQHandler
    .thumb_set FTM2_IRQHandler,Default_Handler
 
    .weak    RTC_IRQHandler
    .thumb_set RTC_IRQHandler,Default_Handler
 
    .weak    ACMP1_IRQHandler
    .thumb_set ACMP1_IRQHandler,Default_Handler
 
    .weak    PIT_CH0_IRQHandler
    .thumb_set PIT_CH0_IRQHandler,Default_Handler
 
    .weak    PIT_CH1_IRQHandler
    .thumb_set PIT_CH1_IRQHandler,Default_Handler
 
    .weak    KBI0_IRQHandler
    .thumb_set KBI0_IRQHandler,Default_Handler
 
    .weak    KBI1_IRQHandler
    .thumb_set KBI1_IRQHandler,Default_Handler
 
    .weak    Reserved42_IRQHandler
    .thumb_set Reserved42_IRQHandler,Default_Handler
 
    .weak    ICS_IRQHandler
    .thumb_set ICS_IRQHandler,Default_Handler
 
    .weak    WDOG_IRQHandler
    .thumb_set WDOG_IRQHandler,Default_Handler
 
    .weak    PWT_IRQHandler
    .thumb_set PWT_IRQHandler,Default_Handler
 
    .weak    MCAN_IRQHandler
    .thumb_set MCAN_IRQHandler,Default_Handler
 
    .weak    EXTI0_IRQHandler
    .thumb_set EXTI0_IRQHandler,Default_Handler
 
    .weak    EXTI1_IRQHandler
    .thumb_set EXTI1_IRQHandler,Default_Handler
 
    .weak    EXTI2_IRQHandler
    .thumb_set EXTI2_IRQHandler,Default_Handler
 
    .weak    EXTI3_IRQHandler
    .thumb_set EXTI3_IRQHandler,Default_Handler
 
    .weak    EXTI4_IRQHandler
    .thumb_set EXTI4_IRQHandler,Default_Handler
 
    .weak    EXTI5_IRQHandler
    .thumb_set EXTI5_IRQHandler,Default_Handler
 
    .weak    EXTI6_IRQHandler
    .thumb_set EXTI6_IRQHandler,Default_Handler
 
    .weak    EXTI7_IRQHandler
    .thumb_set EXTI7_IRQHandler,Default_Handler
 
    .weak    EXTI8_IRQHandler
    .thumb_set EXTI8_IRQHandler,Default_Handler
 
    .weak    EXTI9_IRQHandler
    .thumb_set EXTI9_IRQHandler,Default_Handler
 
    .weak    EXTI10_IRQHandler
    .thumb_set EXTI10_IRQHandler,Default_Handler
 
    .weak    EXTI11_IRQHandler
    .thumb_set EXTI11_IRQHandler,Default_Handler
 
    .weak    EXTI12_IRQHandler
    .thumb_set EXTI12_IRQHandler,Default_Handler
 
    .weak    EXTI13_IRQHandler
    .thumb_set EXTI13_IRQHandler,Default_Handler
 
    .weak    EXTI14_IRQHandler
    .thumb_set EXTI14_IRQHandler,Default_Handler
 
    .weak    EXTI15_IRQHandler
    .thumb_set EXTI15_IRQHandler,Default_Handler
 
    .weak    EWM_IRQHandler
    .thumb_set EWM_IRQHandler,Default_Handler
 
    .weak    Reserved21_IRQHandler
    .thumb_set Reserved21_IRQHandler,Default_Handler
 
.ifndef    RAM_TARGET
.org    0x400
/*
; <h> Flash Configuration
;   <i> 16-byte flash configuration field that stores default protection settings (loaded on reset)
;   <i> and security information that allows the MCU to restrict acces to the FTFL module.
;   <h> Backdoor Comparison Key
;     <o0>  Backdoor Key 0  <0x0-0xFF:2>
;     <o1>  Backdoor Key 1  <0x0-0xFF:2>
;     <o2>  Backdoor Key 2  <0x0-0xFF:2>
;     <o3>  Backdoor Key 3  <0x0-0xFF:2>
;     <o4>  Backdoor Key 4  <0x0-0xFF:2>
;     <o5>  Backdoor Key 5  <0x0-0xFF:2>
;     <o6>  Backdoor Key 6  <0x0-0xFF:2>
;     <o7>  Backdoor Key 7  <0x0-0xFF:2>
*/
.set BackDoorK0,    0xff
.set BackDoorK1,    0xff
.set BackDoorK2,    0xff
.set BackDoorK3,    0xff
.set BackDoorK4,    0xff
.set BackDoorK5,    0xff
.set BackDoorK6,    0xff
.set BackDoorK7,    0xff
/*
;   </h>
;     <h> FPROT
;       <i> P-Flash Protection Register
;       <o.7> FPOPEN
;         <0=> FPHDIS and FPLDIS bits define unprotected address ranges as specified by the corresponding FPHS and FPLS bits FPROT1.1
;         <1=> FPHDIS and FPLDIS bits enable protection for the address range specified by the corresponding FPHS and FPLS bits
;       <o.5> FPHDIS
;         <0=> Protection/Unprotection enabled
;         <1=> Protection/Unprotection disabled
;       <o.3..4> FPHS
;         <0=> Address range: 0x00_7C00-0x00_7FFF; protected size: 1 KB
;         <1=> Address range: 0x00_7800-0x00_7FFF; protected size: 2 KB
;         <2=> Address range: 0x00_7000-0x00_7FFF; protected size: 4 KB
;         <3=> Address range: 0x00_6000-0x00_7FFF; protected size: 8 KB
;       <o.5> FPLDIS
;         <0=> Protection/Unprotection enabled
;         <1=> Protection/Unprotection disabled
;       <o.3..4> FPLS
;         <0=> Address range: 0x00_0000-0x00_07FF; protected size: 2 KB
;         <1=> Address range: 0x00_0000-0x00_0FFF; protected size: 4 KB
;         <2=> Address range: 0x00_0000-0x00_1FFF; protected size: 8 KB
;         <3=> Address range: 0x00_0000-0x00_3FFF; protected size: 16 KB
*/
.set FPROT,    0xff
/*
;     </h>
;   </h>
;   <h> Flash security byte (FSEC)
;     <i> WARNING: If SEC field is configured as "MCU security status is secure" and MEEN field is configured as "Mass erase is disabled",
;     <i> MCU's security status cannot be set back to unsecure state since Mass erase via the debugger is blocked !!!
;     <o.0..1> SEC
;       <2=> MCU security status is unsecure
;       <3=> MCU security status is secure
;         <i> Flash Security
;         <i> This bits define the security state of the MCU.
;     <o.6..7> KEYEN
;       <2=> Backdoor key access enabled
;       <3=> Backdoor key access disabled
;         <i> Backdoor key Security Enable
;         <i> These bits enable and disable backdoor key access to the FTFL module.
*/
.set FSEC,    0xff
/*
;   </h>
;   <h> Flash Option Register (FOPT)
*/
.set FOPT,    0xff
 
    .byte    BackDoorK0
    .byte    BackDoorK1
    .byte    BackDoorK2
    .byte    BackDoorK3
    .byte    BackDoorK4
    .byte    BackDoorK5
    .byte    BackDoorK6
    .byte    BackDoorK7
    .byte    0xff
    .byte    0xff
    .byte    0xff
    .byte    0xff
    .byte    0xff
    .byte    FPROT
    .byte    FSEC
    .byte    FOPT
.endif
 
/******************* (C) COPYRIGHT 2011 CHIPWAYS *****END OF FILE****/