1/* ------------------------------------------------------------------------- */ 2/* @file: startup_LPC864.s */ 3/* @purpose: CMSIS Cortex-M0P Core Device Startup File */ 4/* LPC864 */ 5/* @version: 1.0 */ 6/* @date: 2022-3-15 */ 7/* @build: b231018 */ 8/* ------------------------------------------------------------------------- */ 9/* */ 10/* Copyright 1997-2016 Freescale Semiconductor, Inc. */ 11/* Copyright 2016-2023 NXP */ 12/* SPDX-License-Identifier: BSD-3-Clause */ 13/*****************************************************************************/ 14/* Version: GCC for ARM Embedded Processors */ 15/*****************************************************************************/ 16 .syntax unified 17 .arch armv6-m 18 19 .section .isr_vector, "a" 20 .align 2 21 .globl __Vectors 22__Vectors: 23 .long __StackTop /* Top of Stack */ 24 .long Reset_Handler /* Reset Handler */ 25 .long NMI_Handler /* NMI Handler*/ 26 .long HardFault_Handler /* Hard Fault Handler*/ 27 .long 0 /* Reserved*/ 28 .long 0 /* Reserved*/ 29 .long 0 /* Reserved*/ 30 .long 0 /* Reserved*/ 31 .long 0 /* Reserved*/ 32 .long 0 /* Reserved*/ 33 .long 0 /* Reserved*/ 34 .long SVC_Handler /* SVCall Handler*/ 35 .long 0 /* Reserved*/ 36 .long 0 /* Reserved*/ 37 .long PendSV_Handler /* PendSV Handler*/ 38 .long SysTick_Handler /* SysTick Handler*/ 39 40 /* External Interrupts*/ 41 .long SPI0_IRQHandler /* SPI0 interrupt*/ 42 .long SPI1_IRQHandler /* SPI1 interrupt*/ 43 .long Reserved18_IRQHandler /* Reserved interrupt*/ 44 .long USART0_IRQHandler /* USART0 interrupt*/ 45 .long USART1_IRQHandler /* USART1 interrupt*/ 46 .long USART2_IRQHandler /* USART2 interrupt*/ 47 .long FTM0_IRQHandler /* FlexTimer0 interrupt*/ 48 .long FTM1_IRQHandler /* FlexTimer1 interrupt*/ 49 .long I2C0_IRQHandler /* I2C0 interrupt*/ 50 .long Reserved25_IRQHandler /* Reserved interrupt*/ 51 .long MRT0_IRQHandler /* Multi-rate timer interrupt*/ 52 .long ACMP_IRQHandler /* Analog comparator interrupt*/ 53 .long WDT_IRQHandler /* Windowed watchdog timer interrupt*/ 54 .long BOD_IRQHandler /* BOD interrupts*/ 55 .long FLASH_IRQHandler /* flash interrupt*/ 56 .long WKT_IRQHandler /* Self-wake-up timer interrupt*/ 57 .long ADC0_SEQA_IRQHandler /* ADC0 sequence A completion.*/ 58 .long ADC0_SEQB_IRQHandler /* ADC0 sequence B completion.*/ 59 .long ADC0_THCMP_IRQHandler /* ADC0 threshold compare and error.*/ 60 .long ADC0_OVR_IRQHandler /* ADC0 overrun*/ 61 .long DMA0_IRQHandler /* DMA0 interrupt*/ 62 .long I3C0_IRQHandler /* I3C0 interrupt*/ 63 .long GPIO_HS_IRQ0_IRQHandler /* GPIO group A interrupt*/ 64 .long GPIO_HS_IRQ1_IRQHandler /* GPIO group B interrupt*/ 65 .long PIN_INT0_IRQHandler /* Pin interrupt 0 or pattern match engine slice 0 interrupt*/ 66 .long PIN_INT1_IRQHandler /* Pin interrupt 1 or pattern match engine slice 1 interrupt*/ 67 .long PIN_INT2_IRQHandler /* Pin interrupt 2 or pattern match engine slice 2 interrupt*/ 68 .long PIN_INT3_IRQHandler /* Pin interrupt 3 or pattern match engine slice 3 interrupt*/ 69 .long PIN_INT4_IRQHandler /* Pin interrupt 4 or pattern match engine slice 4 interrupt*/ 70 .long PIN_INT5_IRQHandler /* Pin interrupt 5 or pattern match engine slice 5 interrupt*/ 71 .long PIN_INT6_IRQHandler /* Pin interrupt 6 or pattern match engine slice 6 interrupt*/ 72 .long PIN_INT7_IRQHandler /* Pin interrupt 7 or pattern match engine slice 7 interrupt*/ 73 74 .size __Vectors, . - __Vectors 75 76/* Variable to store CRP value in. No code read protection enabled by default 77 * Code Read Protection level (CRP) 78 * CRP_Level: 79 * <0xFFFFFFFF=> Disabled 80 * <0x536AAC95=> NO_ISP 81 * <0x5963A69C=> CRP1 82 * <0x963569CA=> CRP2 83 * <0x63599CA6=> CRP3 84 */ 85 #ifndef NO_CRP 86 .section .crp, "a" 87 .long 0xFFFFFFFF 88 #endif 89 90 .text 91 .thumb 92 93#if defined (__cplusplus) 94#ifdef __REDLIB__ 95#error Redlib does not support C++ 96#endif 97#endif 98/* Reset Handler */ 99 100 .thumb_func 101 .align 2 102 .globl Reset_Handler 103 .weak Reset_Handler 104 .type Reset_Handler, %function 105Reset_Handler: 106 cpsid i /* Mask interrupts */ 107 .equ VTOR, 0xE000ED08 108 ldr r0, =VTOR 109 ldr r1, =__Vectors 110 str r1, [r0] 111 ldr r2, [r1] 112 msr msp, r2 113#ifndef __NO_SYSTEM_INIT 114 ldr r0,=SystemInit 115 blx r0 116#endif 117/* Loop to copy data from read only memory to RAM. The ranges 118 * of copy from/to are specified by following symbols evaluated in 119 * linker script. 120 * __etext: End of code section, i.e., begin of data sections to copy from. 121 * __data_start__/__data_end__: RAM address range that data should be 122 * copied to. Both must be aligned to 4 bytes boundary. */ 123 124 ldr r1, =__etext 125 ldr r2, =__data_start__ 126 ldr r3, =__data_end__ 127 128 subs r3, r2 129 ble .LC0 130 131.LC1: 132 subs r3, 4 133 ldr r0, [r1,r3] 134 str r0, [r2,r3] 135 bgt .LC1 136.LC0: 137 138#ifdef __STARTUP_CLEAR_BSS 139/* This part of work usually is done in C library startup code. Otherwise, 140 * define this macro to enable it in this startup. 141 * 142 * Loop to zero out BSS section, which uses following symbols 143 * in linker script: 144 * __bss_start__: start of BSS section. Must align to 4 145 * __bss_end__: end of BSS section. Must align to 4 146 */ 147 ldr r1, =__bss_start__ 148 ldr r2, =__bss_end__ 149 150 subs r2, r1 151 ble .LC3 152 153 movs r0, 0 154.LC2: 155 subs r2, 4 156 str r0, [r1, r2] 157 bgt .LC2 158.LC3: 159#endif 160 cpsie i /* Unmask interrupts */ 161#ifndef __START 162#ifdef __REDLIB__ 163#define __START __main 164#else 165#define __START _start 166#endif 167#endif 168#ifndef __ATOLLIC__ 169 ldr r0,=__START 170 blx r0 171#else 172 ldr r0,=__libc_init_array 173 blx r0 174 ldr r0,=main 175 bx r0 176#endif 177 .pool 178 .size Reset_Handler, . - Reset_Handler 179 180 .align 1 181 .thumb_func 182 .weak DefaultISR 183 .type DefaultISR, %function 184DefaultISR: 185 ldr r0, =DefaultISR 186 bx r0 187 .size DefaultISR, . - DefaultISR 188 189 .align 1 190 .thumb_func 191 .weak NMI_Handler 192 .type NMI_Handler, %function 193NMI_Handler: 194 ldr r0,=NMI_Handler 195 bx r0 196 .size NMI_Handler, . - NMI_Handler 197 198 .align 1 199 .thumb_func 200 .weak HardFault_Handler 201 .type HardFault_Handler, %function 202HardFault_Handler: 203 ldr r0,=HardFault_Handler 204 bx r0 205 .size HardFault_Handler, . - HardFault_Handler 206 207 .align 1 208 .thumb_func 209 .weak SVC_Handler 210 .type SVC_Handler, %function 211SVC_Handler: 212 ldr r0,=SVC_Handler 213 bx r0 214 .size SVC_Handler, . - SVC_Handler 215 216 .align 1 217 .thumb_func 218 .weak PendSV_Handler 219 .type PendSV_Handler, %function 220PendSV_Handler: 221 ldr r0,=PendSV_Handler 222 bx r0 223 .size PendSV_Handler, . - PendSV_Handler 224 225 .align 1 226 .thumb_func 227 .weak SysTick_Handler 228 .type SysTick_Handler, %function 229SysTick_Handler: 230 ldr r0,=SysTick_Handler 231 bx r0 232 .size SysTick_Handler, . - SysTick_Handler 233 234 .align 1 235 .thumb_func 236 .weak SPI0_IRQHandler 237 .type SPI0_IRQHandler, %function 238SPI0_IRQHandler: 239 ldr r0,=SPI0_DriverIRQHandler 240 bx r0 241 .size SPI0_IRQHandler, . - SPI0_IRQHandler 242 243 .align 1 244 .thumb_func 245 .weak SPI1_IRQHandler 246 .type SPI1_IRQHandler, %function 247SPI1_IRQHandler: 248 ldr r0,=SPI1_DriverIRQHandler 249 bx r0 250 .size SPI1_IRQHandler, . - SPI1_IRQHandler 251 252 .align 1 253 .thumb_func 254 .weak Reserved18_IRQHandler 255 .type Reserved18_IRQHandler, %function 256Reserved18_IRQHandler: 257 ldr r0,=Reserved18_DriverIRQHandler 258 bx r0 259 .size Reserved18_IRQHandler, . - Reserved18_IRQHandler 260 261 .align 1 262 .thumb_func 263 .weak USART0_IRQHandler 264 .type USART0_IRQHandler, %function 265USART0_IRQHandler: 266 ldr r0,=USART0_DriverIRQHandler 267 bx r0 268 .size USART0_IRQHandler, . - USART0_IRQHandler 269 270 .align 1 271 .thumb_func 272 .weak USART1_IRQHandler 273 .type USART1_IRQHandler, %function 274USART1_IRQHandler: 275 ldr r0,=USART1_DriverIRQHandler 276 bx r0 277 .size USART1_IRQHandler, . - USART1_IRQHandler 278 279 .align 1 280 .thumb_func 281 .weak USART2_IRQHandler 282 .type USART2_IRQHandler, %function 283USART2_IRQHandler: 284 ldr r0,=USART2_DriverIRQHandler 285 bx r0 286 .size USART2_IRQHandler, . - USART2_IRQHandler 287 288 .align 1 289 .thumb_func 290 .weak FTM0_IRQHandler 291 .type FTM0_IRQHandler, %function 292FTM0_IRQHandler: 293 ldr r0,=FTM0_DriverIRQHandler 294 bx r0 295 .size FTM0_IRQHandler, . - FTM0_IRQHandler 296 297 .align 1 298 .thumb_func 299 .weak FTM1_IRQHandler 300 .type FTM1_IRQHandler, %function 301FTM1_IRQHandler: 302 ldr r0,=FTM1_DriverIRQHandler 303 bx r0 304 .size FTM1_IRQHandler, . - FTM1_IRQHandler 305 306 .align 1 307 .thumb_func 308 .weak I2C0_IRQHandler 309 .type I2C0_IRQHandler, %function 310I2C0_IRQHandler: 311 ldr r0,=I2C0_DriverIRQHandler 312 bx r0 313 .size I2C0_IRQHandler, . - I2C0_IRQHandler 314 315 .align 1 316 .thumb_func 317 .weak Reserved25_IRQHandler 318 .type Reserved25_IRQHandler, %function 319Reserved25_IRQHandler: 320 ldr r0,=Reserved25_DriverIRQHandler 321 bx r0 322 .size Reserved25_IRQHandler, . - Reserved25_IRQHandler 323 324 .align 1 325 .thumb_func 326 .weak MRT0_IRQHandler 327 .type MRT0_IRQHandler, %function 328MRT0_IRQHandler: 329 ldr r0,=MRT0_DriverIRQHandler 330 bx r0 331 .size MRT0_IRQHandler, . - MRT0_IRQHandler 332 333 .align 1 334 .thumb_func 335 .weak ACMP_IRQHandler 336 .type ACMP_IRQHandler, %function 337ACMP_IRQHandler: 338 ldr r0,=ACMP_DriverIRQHandler 339 bx r0 340 .size ACMP_IRQHandler, . - ACMP_IRQHandler 341 342 .align 1 343 .thumb_func 344 .weak WDT_IRQHandler 345 .type WDT_IRQHandler, %function 346WDT_IRQHandler: 347 ldr r0,=WDT_DriverIRQHandler 348 bx r0 349 .size WDT_IRQHandler, . - WDT_IRQHandler 350 351 .align 1 352 .thumb_func 353 .weak BOD_IRQHandler 354 .type BOD_IRQHandler, %function 355BOD_IRQHandler: 356 ldr r0,=BOD_DriverIRQHandler 357 bx r0 358 .size BOD_IRQHandler, . - BOD_IRQHandler 359 360 .align 1 361 .thumb_func 362 .weak FLASH_IRQHandler 363 .type FLASH_IRQHandler, %function 364FLASH_IRQHandler: 365 ldr r0,=FLASH_DriverIRQHandler 366 bx r0 367 .size FLASH_IRQHandler, . - FLASH_IRQHandler 368 369 .align 1 370 .thumb_func 371 .weak WKT_IRQHandler 372 .type WKT_IRQHandler, %function 373WKT_IRQHandler: 374 ldr r0,=WKT_DriverIRQHandler 375 bx r0 376 .size WKT_IRQHandler, . - WKT_IRQHandler 377 378 .align 1 379 .thumb_func 380 .weak ADC0_SEQA_IRQHandler 381 .type ADC0_SEQA_IRQHandler, %function 382ADC0_SEQA_IRQHandler: 383 ldr r0,=ADC0_SEQA_DriverIRQHandler 384 bx r0 385 .size ADC0_SEQA_IRQHandler, . - ADC0_SEQA_IRQHandler 386 387 .align 1 388 .thumb_func 389 .weak ADC0_SEQB_IRQHandler 390 .type ADC0_SEQB_IRQHandler, %function 391ADC0_SEQB_IRQHandler: 392 ldr r0,=ADC0_SEQB_DriverIRQHandler 393 bx r0 394 .size ADC0_SEQB_IRQHandler, . - ADC0_SEQB_IRQHandler 395 396 .align 1 397 .thumb_func 398 .weak ADC0_THCMP_IRQHandler 399 .type ADC0_THCMP_IRQHandler, %function 400ADC0_THCMP_IRQHandler: 401 ldr r0,=ADC0_THCMP_DriverIRQHandler 402 bx r0 403 .size ADC0_THCMP_IRQHandler, . - ADC0_THCMP_IRQHandler 404 405 .align 1 406 .thumb_func 407 .weak ADC0_OVR_IRQHandler 408 .type ADC0_OVR_IRQHandler, %function 409ADC0_OVR_IRQHandler: 410 ldr r0,=ADC0_OVR_DriverIRQHandler 411 bx r0 412 .size ADC0_OVR_IRQHandler, . - ADC0_OVR_IRQHandler 413 414 .align 1 415 .thumb_func 416 .weak DMA0_IRQHandler 417 .type DMA0_IRQHandler, %function 418DMA0_IRQHandler: 419 ldr r0,=DMA0_DriverIRQHandler 420 bx r0 421 .size DMA0_IRQHandler, . - DMA0_IRQHandler 422 423 .align 1 424 .thumb_func 425 .weak I3C0_IRQHandler 426 .type I3C0_IRQHandler, %function 427I3C0_IRQHandler: 428 ldr r0,=I3C0_DriverIRQHandler 429 bx r0 430 .size I3C0_IRQHandler, . - I3C0_IRQHandler 431 432 .align 1 433 .thumb_func 434 .weak GPIO_HS_IRQ0_IRQHandler 435 .type GPIO_HS_IRQ0_IRQHandler, %function 436GPIO_HS_IRQ0_IRQHandler: 437 ldr r0,=GPIO_HS_IRQ0_DriverIRQHandler 438 bx r0 439 .size GPIO_HS_IRQ0_IRQHandler, . - GPIO_HS_IRQ0_IRQHandler 440 441 .align 1 442 .thumb_func 443 .weak GPIO_HS_IRQ1_IRQHandler 444 .type GPIO_HS_IRQ1_IRQHandler, %function 445GPIO_HS_IRQ1_IRQHandler: 446 ldr r0,=GPIO_HS_IRQ1_DriverIRQHandler 447 bx r0 448 .size GPIO_HS_IRQ1_IRQHandler, . - GPIO_HS_IRQ1_IRQHandler 449 450 .align 1 451 .thumb_func 452 .weak PIN_INT0_IRQHandler 453 .type PIN_INT0_IRQHandler, %function 454PIN_INT0_IRQHandler: 455 ldr r0,=PIN_INT0_DriverIRQHandler 456 bx r0 457 .size PIN_INT0_IRQHandler, . - PIN_INT0_IRQHandler 458 459 .align 1 460 .thumb_func 461 .weak PIN_INT1_IRQHandler 462 .type PIN_INT1_IRQHandler, %function 463PIN_INT1_IRQHandler: 464 ldr r0,=PIN_INT1_DriverIRQHandler 465 bx r0 466 .size PIN_INT1_IRQHandler, . - PIN_INT1_IRQHandler 467 468 .align 1 469 .thumb_func 470 .weak PIN_INT2_IRQHandler 471 .type PIN_INT2_IRQHandler, %function 472PIN_INT2_IRQHandler: 473 ldr r0,=PIN_INT2_DriverIRQHandler 474 bx r0 475 .size PIN_INT2_IRQHandler, . - PIN_INT2_IRQHandler 476 477 .align 1 478 .thumb_func 479 .weak PIN_INT3_IRQHandler 480 .type PIN_INT3_IRQHandler, %function 481PIN_INT3_IRQHandler: 482 ldr r0,=PIN_INT3_DriverIRQHandler 483 bx r0 484 .size PIN_INT3_IRQHandler, . - PIN_INT3_IRQHandler 485 486 .align 1 487 .thumb_func 488 .weak PIN_INT4_IRQHandler 489 .type PIN_INT4_IRQHandler, %function 490PIN_INT4_IRQHandler: 491 ldr r0,=PIN_INT4_DriverIRQHandler 492 bx r0 493 .size PIN_INT4_IRQHandler, . - PIN_INT4_IRQHandler 494 495 .align 1 496 .thumb_func 497 .weak PIN_INT5_IRQHandler 498 .type PIN_INT5_IRQHandler, %function 499PIN_INT5_IRQHandler: 500 ldr r0,=PIN_INT5_DriverIRQHandler 501 bx r0 502 .size PIN_INT5_IRQHandler, . - PIN_INT5_IRQHandler 503 504 .align 1 505 .thumb_func 506 .weak PIN_INT6_IRQHandler 507 .type PIN_INT6_IRQHandler, %function 508PIN_INT6_IRQHandler: 509 ldr r0,=PIN_INT6_DriverIRQHandler 510 bx r0 511 .size PIN_INT6_IRQHandler, . - PIN_INT6_IRQHandler 512 513 .align 1 514 .thumb_func 515 .weak PIN_INT7_IRQHandler 516 .type PIN_INT7_IRQHandler, %function 517PIN_INT7_IRQHandler: 518 ldr r0,=PIN_INT7_DriverIRQHandler 519 bx r0 520 .size PIN_INT7_IRQHandler, . - PIN_INT7_IRQHandler 521 522 523/* Macro to define default handlers. Default handler 524 * will be weak symbol and just dead loops. They can be 525 * overwritten by other handlers */ 526 .macro def_irq_handler handler_name 527 .weak \handler_name 528 .set \handler_name, DefaultISR 529 .endm 530/* Exception Handlers */ 531 def_irq_handler SPI0_DriverIRQHandler 532 def_irq_handler SPI1_DriverIRQHandler 533 def_irq_handler Reserved18_DriverIRQHandler 534 def_irq_handler USART0_DriverIRQHandler 535 def_irq_handler USART1_DriverIRQHandler 536 def_irq_handler USART2_DriverIRQHandler 537 def_irq_handler FTM0_DriverIRQHandler 538 def_irq_handler FTM1_DriverIRQHandler 539 def_irq_handler I2C0_DriverIRQHandler 540 def_irq_handler Reserved25_DriverIRQHandler 541 def_irq_handler MRT0_DriverIRQHandler 542 def_irq_handler ACMP_DriverIRQHandler 543 def_irq_handler WDT_DriverIRQHandler 544 def_irq_handler BOD_DriverIRQHandler 545 def_irq_handler FLASH_DriverIRQHandler 546 def_irq_handler WKT_DriverIRQHandler 547 def_irq_handler ADC0_SEQA_DriverIRQHandler 548 def_irq_handler ADC0_SEQB_DriverIRQHandler 549 def_irq_handler ADC0_THCMP_DriverIRQHandler 550 def_irq_handler ADC0_OVR_DriverIRQHandler 551 def_irq_handler DMA0_DriverIRQHandler 552 def_irq_handler I3C0_DriverIRQHandler 553 def_irq_handler GPIO_HS_IRQ0_DriverIRQHandler 554 def_irq_handler GPIO_HS_IRQ1_DriverIRQHandler 555 def_irq_handler PIN_INT0_DriverIRQHandler 556 def_irq_handler PIN_INT1_DriverIRQHandler 557 def_irq_handler PIN_INT2_DriverIRQHandler 558 def_irq_handler PIN_INT3_DriverIRQHandler 559 def_irq_handler PIN_INT4_DriverIRQHandler 560 def_irq_handler PIN_INT5_DriverIRQHandler 561 def_irq_handler PIN_INT6_DriverIRQHandler 562 def_irq_handler PIN_INT7_DriverIRQHandler 563 564 .end 565