1/* ------------------------------------------------------------------------- */ 2/* @file: startup_MKE14Z7.s */ 3/* @purpose: CMSIS Cortex-M0P Core Device Startup File */ 4/* MKE14Z7 */ 5/* @version: 6.0 */ 6/* @date: 2016-9-20 */ 7/* @build: b230529 */ 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 __isr_vector 22__isr_vector: 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 DMA0_04_IRQHandler /* DMA channel 0 or 4 transfer complete*/ 42 .long DMA0_15_IRQHandler /* DMA channel 1 or 5 transfer complete*/ 43 .long DMA0_26_IRQHandler /* DMA channel 2 or 6 transfer complete*/ 44 .long DMA0_37_IRQHandler /* DMA channel 3 or 7 transfer complete*/ 45 .long DMA_Error_IRQHandler /* DMA error interrupt channels 0-7*/ 46 .long FTFE_IRQHandler /* Single interrupt vector for all sources*/ 47 .long LVD_LVW_IRQHandler /* Low-voltage detect, low-voltage warning*/ 48 .long PORTAE_IRQHandler /* Pin detect (Port A, E)*/ 49 .long LPI2C0_IRQHandler /* Inter-integrated circuit 0 interrupt*/ 50 .long LPI2C1_IRQHandler /* Inter-integrated circuit 1 interrupt*/ 51 .long LPSPI0_IRQHandler /* Serial peripheral Interface 0 interrupt*/ 52 .long LPSPI1_IRQHandler /* Serial peripheral Interface 1 interrupt*/ 53 .long LPUART0_IRQHandler /* Single interrupt vector for all sources*/ 54 .long LPUART1_IRQHandler /* Single interrupt vector for all sources*/ 55 .long LPUART2_IRQHandler /* Single interrupt vector for all sources*/ 56 .long ADC0_IRQHandler /* ADC0 conversion complete interrupt*/ 57 .long CMP0_IRQHandler /* CMP0 interrupt*/ 58 .long FTM0_IRQHandler /* FTM0 single interrupt vector for all sources*/ 59 .long FTM1_IRQHandler /* FTM1 single interrupt vector for all sources*/ 60 .long FTM2_IRQHandler /* FTM2 single interrupt vector for all sources*/ 61 .long RTC_IRQHandler /* Single interrupt vector for all sources*/ 62 .long CMP1_IRQHandler /* CMP1 interrupt*/ 63 .long LPIT0_IRQHandler /* LPIT interrupt*/ 64 .long FLEXIO_IRQHandler /* FLEXIO interrupt*/ 65 .long Reserved40_IRQHandler /* Reserved interrupt*/ 66 .long PDB0_IRQHandler /* Programmable delay block interrupt*/ 67 .long PORTBCD_IRQHandler /* Pin detect (Port B, C, D)*/ 68 .long SCG_IRQHandler /* System clock generator interrupt*/ 69 .long WDOG_EWM_IRQHandler /* Single interrupt vector for WDOG and EWM*/ 70 .long PWT_LPTMR0_IRQHandler /* Single interrupt vector for PWT and LPTMR0*/ 71 .long ADC1_IRQHandler /* ADC1 conversion complete interrupt*/ 72 .long RCM_IRQHandler /* RCM interrupt*/ 73 74 .size __isr_vector, . - __isr_vector 75 76/* Flash Configuration */ 77 .section .FlashConfig, "a" 78 .long 0xFFFFFFFF 79 .long 0xFFFFFFFF 80 .long 0xFFFFFFFF 81 .long 0xFFFF7DFE 82 83 .text 84 .thumb 85 86/* Reset Handler */ 87 88 .thumb_func 89 .align 2 90 .globl Reset_Handler 91 .weak Reset_Handler 92 .type Reset_Handler, %function 93Reset_Handler: 94 cpsid i /* Mask interrupts */ 95 .equ VTOR, 0xE000ED08 96 ldr r0, =VTOR 97 ldr r1, =__isr_vector 98 str r1, [r0] 99 ldr r2, [r1] 100 msr msp, r2 101#ifndef __NO_SYSTEM_INIT 102 ldr r0,=SystemInit 103 blx r0 104#endif 105/* Loop to copy data from read only memory to RAM. The ranges 106 * of copy from/to are specified by following symbols evaluated in 107 * linker script. 108 * __etext: End of code section, i.e., begin of data sections to copy from. 109 * __data_start__/__data_end__: RAM address range that data should be 110 * copied to. Both must be aligned to 4 bytes boundary. */ 111 112 ldr r1, =__etext 113 ldr r2, =__data_start__ 114 ldr r3, =__data_end__ 115 116 subs r3, r2 117 ble .LC0 118 119.LC1: 120 subs r3, 4 121 ldr r0, [r1,r3] 122 str r0, [r2,r3] 123 bgt .LC1 124.LC0: 125 126#ifdef __STARTUP_CLEAR_BSS 127/* This part of work usually is done in C library startup code. Otherwise, 128 * define this macro to enable it in this startup. 129 * 130 * Loop to zero out BSS section, which uses following symbols 131 * in linker script: 132 * __bss_start__: start of BSS section. Must align to 4 133 * __bss_end__: end of BSS section. Must align to 4 134 */ 135 ldr r1, =__bss_start__ 136 ldr r2, =__bss_end__ 137 138 subs r2, r1 139 ble .LC3 140 141 movs r0, 0 142.LC2: 143 subs r2, 4 144 str r0, [r1, r2] 145 bgt .LC2 146.LC3: 147#endif 148 cpsie i /* Unmask interrupts */ 149#ifndef __START 150#define __START _start 151#endif 152#ifndef __ATOLLIC__ 153 ldr r0,=__START 154 blx r0 155#else 156 ldr r0,=__libc_init_array 157 blx r0 158 ldr r0,=main 159 bx r0 160#endif 161 .pool 162 .size Reset_Handler, . - Reset_Handler 163 164 .align 1 165 .thumb_func 166 .weak DefaultISR 167 .type DefaultISR, %function 168DefaultISR: 169 ldr r0, =DefaultISR 170 bx r0 171 .size DefaultISR, . - DefaultISR 172 173 .align 1 174 .thumb_func 175 .weak NMI_Handler 176 .type NMI_Handler, %function 177NMI_Handler: 178 ldr r0,=NMI_Handler 179 bx r0 180 .size NMI_Handler, . - NMI_Handler 181 182 .align 1 183 .thumb_func 184 .weak HardFault_Handler 185 .type HardFault_Handler, %function 186HardFault_Handler: 187 ldr r0,=HardFault_Handler 188 bx r0 189 .size HardFault_Handler, . - HardFault_Handler 190 191 .align 1 192 .thumb_func 193 .weak SVC_Handler 194 .type SVC_Handler, %function 195SVC_Handler: 196 ldr r0,=SVC_Handler 197 bx r0 198 .size SVC_Handler, . - SVC_Handler 199 200 .align 1 201 .thumb_func 202 .weak PendSV_Handler 203 .type PendSV_Handler, %function 204PendSV_Handler: 205 ldr r0,=PendSV_Handler 206 bx r0 207 .size PendSV_Handler, . - PendSV_Handler 208 209 .align 1 210 .thumb_func 211 .weak SysTick_Handler 212 .type SysTick_Handler, %function 213SysTick_Handler: 214 ldr r0,=SysTick_Handler 215 bx r0 216 .size SysTick_Handler, . - SysTick_Handler 217 218 .align 1 219 .thumb_func 220 .weak DMA0_04_IRQHandler 221 .type DMA0_04_IRQHandler, %function 222DMA0_04_IRQHandler: 223 ldr r0,=DMA0_04_DriverIRQHandler 224 bx r0 225 .size DMA0_04_IRQHandler, . - DMA0_04_IRQHandler 226 227 .align 1 228 .thumb_func 229 .weak DMA0_15_IRQHandler 230 .type DMA0_15_IRQHandler, %function 231DMA0_15_IRQHandler: 232 ldr r0,=DMA0_15_DriverIRQHandler 233 bx r0 234 .size DMA0_15_IRQHandler, . - DMA0_15_IRQHandler 235 236 .align 1 237 .thumb_func 238 .weak DMA0_26_IRQHandler 239 .type DMA0_26_IRQHandler, %function 240DMA0_26_IRQHandler: 241 ldr r0,=DMA0_26_DriverIRQHandler 242 bx r0 243 .size DMA0_26_IRQHandler, . - DMA0_26_IRQHandler 244 245 .align 1 246 .thumb_func 247 .weak DMA0_37_IRQHandler 248 .type DMA0_37_IRQHandler, %function 249DMA0_37_IRQHandler: 250 ldr r0,=DMA0_37_DriverIRQHandler 251 bx r0 252 .size DMA0_37_IRQHandler, . - DMA0_37_IRQHandler 253 254 .align 1 255 .thumb_func 256 .weak DMA_Error_IRQHandler 257 .type DMA_Error_IRQHandler, %function 258DMA_Error_IRQHandler: 259 ldr r0,=DMA_Error_DriverIRQHandler 260 bx r0 261 .size DMA_Error_IRQHandler, . - DMA_Error_IRQHandler 262 263 .align 1 264 .thumb_func 265 .weak LPI2C0_IRQHandler 266 .type LPI2C0_IRQHandler, %function 267LPI2C0_IRQHandler: 268 ldr r0,=LPI2C0_DriverIRQHandler 269 bx r0 270 .size LPI2C0_IRQHandler, . - LPI2C0_IRQHandler 271 272 .align 1 273 .thumb_func 274 .weak LPI2C1_IRQHandler 275 .type LPI2C1_IRQHandler, %function 276LPI2C1_IRQHandler: 277 ldr r0,=LPI2C1_DriverIRQHandler 278 bx r0 279 .size LPI2C1_IRQHandler, . - LPI2C1_IRQHandler 280 281 .align 1 282 .thumb_func 283 .weak LPSPI0_IRQHandler 284 .type LPSPI0_IRQHandler, %function 285LPSPI0_IRQHandler: 286 ldr r0,=LPSPI0_DriverIRQHandler 287 bx r0 288 .size LPSPI0_IRQHandler, . - LPSPI0_IRQHandler 289 290 .align 1 291 .thumb_func 292 .weak LPSPI1_IRQHandler 293 .type LPSPI1_IRQHandler, %function 294LPSPI1_IRQHandler: 295 ldr r0,=LPSPI1_DriverIRQHandler 296 bx r0 297 .size LPSPI1_IRQHandler, . - LPSPI1_IRQHandler 298 299 .align 1 300 .thumb_func 301 .weak LPUART0_IRQHandler 302 .type LPUART0_IRQHandler, %function 303LPUART0_IRQHandler: 304 ldr r0,=LPUART0_DriverIRQHandler 305 bx r0 306 .size LPUART0_IRQHandler, . - LPUART0_IRQHandler 307 308 .align 1 309 .thumb_func 310 .weak LPUART1_IRQHandler 311 .type LPUART1_IRQHandler, %function 312LPUART1_IRQHandler: 313 ldr r0,=LPUART1_DriverIRQHandler 314 bx r0 315 .size LPUART1_IRQHandler, . - LPUART1_IRQHandler 316 317 .align 1 318 .thumb_func 319 .weak LPUART2_IRQHandler 320 .type LPUART2_IRQHandler, %function 321LPUART2_IRQHandler: 322 ldr r0,=LPUART2_DriverIRQHandler 323 bx r0 324 .size LPUART2_IRQHandler, . - LPUART2_IRQHandler 325 326 .align 1 327 .thumb_func 328 .weak FLEXIO_IRQHandler 329 .type FLEXIO_IRQHandler, %function 330FLEXIO_IRQHandler: 331 ldr r0,=FLEXIO_DriverIRQHandler 332 bx r0 333 .size FLEXIO_IRQHandler, . - FLEXIO_IRQHandler 334 335 336/* Macro to define default handlers. Default handler 337 * will be weak symbol and just dead loops. They can be 338 * overwritten by other handlers */ 339 .macro def_irq_handler handler_name 340 .weak \handler_name 341 .set \handler_name, DefaultISR 342 .endm 343/* Exception Handlers */ 344 def_irq_handler DMA0_04_DriverIRQHandler 345 def_irq_handler DMA0_15_DriverIRQHandler 346 def_irq_handler DMA0_26_DriverIRQHandler 347 def_irq_handler DMA0_37_DriverIRQHandler 348 def_irq_handler DMA_Error_DriverIRQHandler 349 def_irq_handler FTFE_IRQHandler 350 def_irq_handler LVD_LVW_IRQHandler 351 def_irq_handler PORTAE_IRQHandler 352 def_irq_handler LPI2C0_DriverIRQHandler 353 def_irq_handler LPI2C1_DriverIRQHandler 354 def_irq_handler LPSPI0_DriverIRQHandler 355 def_irq_handler LPSPI1_DriverIRQHandler 356 def_irq_handler LPUART0_DriverIRQHandler 357 def_irq_handler LPUART1_DriverIRQHandler 358 def_irq_handler LPUART2_DriverIRQHandler 359 def_irq_handler ADC0_IRQHandler 360 def_irq_handler CMP0_IRQHandler 361 def_irq_handler FTM0_IRQHandler 362 def_irq_handler FTM1_IRQHandler 363 def_irq_handler FTM2_IRQHandler 364 def_irq_handler RTC_IRQHandler 365 def_irq_handler CMP1_IRQHandler 366 def_irq_handler LPIT0_IRQHandler 367 def_irq_handler FLEXIO_DriverIRQHandler 368 def_irq_handler Reserved40_IRQHandler 369 def_irq_handler PDB0_IRQHandler 370 def_irq_handler PORTBCD_IRQHandler 371 def_irq_handler SCG_IRQHandler 372 def_irq_handler WDOG_EWM_IRQHandler 373 def_irq_handler PWT_LPTMR0_IRQHandler 374 def_irq_handler ADC1_IRQHandler 375 def_irq_handler RCM_IRQHandler 376 377 .end 378