mbed SDK library sources

Fork of mbed-src by mbed official

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Wed Sep 25 11:30:05 2013 +0100
Revision:
31:42176bc3c368
Child:
66:64ad953ee6c3
Synchronized with git revision f580c008b139a952d38ac5c7c53bbae375739c67

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 31:42176bc3c368 1 /* KL25Z startup ARM GCC
mbed_official 31:42176bc3c368 2 * Purpose: startup file for Cortex-M0 devices. Should use with
mbed_official 31:42176bc3c368 3 * GCC for ARM Embedded Processors
mbed_official 31:42176bc3c368 4 * Version: V1.2
mbed_official 31:42176bc3c368 5 * Date: 15 Nov 2011
mbed_official 31:42176bc3c368 6 *
mbed_official 31:42176bc3c368 7 * Copyright (c) 2011, ARM Limited
mbed_official 31:42176bc3c368 8 * All rights reserved.
mbed_official 31:42176bc3c368 9 *
mbed_official 31:42176bc3c368 10 * Redistribution and use in source and binary forms, with or without
mbed_official 31:42176bc3c368 11 * modification, are permitted provided that the following conditions are met:
mbed_official 31:42176bc3c368 12 * Redistributions of source code must retain the above copyright
mbed_official 31:42176bc3c368 13 notice, this list of conditions and the following disclaimer.
mbed_official 31:42176bc3c368 14 * Redistributions in binary form must reproduce the above copyright
mbed_official 31:42176bc3c368 15 notice, this list of conditions and the following disclaimer in the
mbed_official 31:42176bc3c368 16 documentation and/or other materials provided with the distribution.
mbed_official 31:42176bc3c368 17 * Neither the name of the ARM Limited nor the
mbed_official 31:42176bc3c368 18 names of its contributors may be used to endorse or promote products
mbed_official 31:42176bc3c368 19 derived from this software without specific prior written permission.
mbed_official 31:42176bc3c368 20 *
mbed_official 31:42176bc3c368 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mbed_official 31:42176bc3c368 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mbed_official 31:42176bc3c368 23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 31:42176bc3c368 24 * DISCLAIMED. IN NO EVENT SHALL ARM LIMITED BE LIABLE FOR ANY
mbed_official 31:42176bc3c368 25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mbed_official 31:42176bc3c368 26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 31:42176bc3c368 27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
mbed_official 31:42176bc3c368 28 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 31:42176bc3c368 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mbed_official 31:42176bc3c368 30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 31:42176bc3c368 31 */
mbed_official 31:42176bc3c368 32 .syntax unified
mbed_official 31:42176bc3c368 33 .arch armv6-m
mbed_official 31:42176bc3c368 34
mbed_official 31:42176bc3c368 35 /* Memory Model
mbed_official 31:42176bc3c368 36 The HEAP starts at the end of the DATA section and grows upward.
mbed_official 31:42176bc3c368 37
mbed_official 31:42176bc3c368 38 The STACK starts at the end of the RAM and grows downward.
mbed_official 31:42176bc3c368 39
mbed_official 31:42176bc3c368 40 The HEAP and stack STACK are only checked at compile time:
mbed_official 31:42176bc3c368 41 (DATA_SIZE + HEAP_SIZE + STACK_SIZE) < RAM_SIZE
mbed_official 31:42176bc3c368 42
mbed_official 31:42176bc3c368 43 This is just a check for the bare minimum for the Heap+Stack area before
mbed_official 31:42176bc3c368 44 aborting compilation, it is not the run time limit:
mbed_official 31:42176bc3c368 45 Heap_Size + Stack_Size = 0x80 + 0x80 = 0x100
mbed_official 31:42176bc3c368 46 */
mbed_official 31:42176bc3c368 47 .section .stack
mbed_official 31:42176bc3c368 48 .align 3
mbed_official 31:42176bc3c368 49 #ifdef __STACK_SIZE
mbed_official 31:42176bc3c368 50 .equ Stack_Size, __STACK_SIZE
mbed_official 31:42176bc3c368 51 #else
mbed_official 31:42176bc3c368 52 .equ Stack_Size, 0x400
mbed_official 31:42176bc3c368 53 #endif
mbed_official 31:42176bc3c368 54 .globl __StackTop
mbed_official 31:42176bc3c368 55 .globl __StackLimit
mbed_official 31:42176bc3c368 56 __StackLimit:
mbed_official 31:42176bc3c368 57 .space Stack_Size
mbed_official 31:42176bc3c368 58 .size __StackLimit, . - __StackLimit
mbed_official 31:42176bc3c368 59 __StackTop:
mbed_official 31:42176bc3c368 60 .size __StackTop, . - __StackTop
mbed_official 31:42176bc3c368 61
mbed_official 31:42176bc3c368 62 .section .heap
mbed_official 31:42176bc3c368 63 .align 3
mbed_official 31:42176bc3c368 64 #ifdef __HEAP_SIZE
mbed_official 31:42176bc3c368 65 .equ Heap_Size, __HEAP_SIZE
mbed_official 31:42176bc3c368 66 #else
mbed_official 31:42176bc3c368 67 .equ Heap_Size, 0x80
mbed_official 31:42176bc3c368 68 #endif
mbed_official 31:42176bc3c368 69 .globl __HeapBase
mbed_official 31:42176bc3c368 70 .globl __HeapLimit
mbed_official 31:42176bc3c368 71 __HeapBase:
mbed_official 31:42176bc3c368 72 .space Heap_Size
mbed_official 31:42176bc3c368 73 .size __HeapBase, . - __HeapBase
mbed_official 31:42176bc3c368 74 __HeapLimit:
mbed_official 31:42176bc3c368 75 .size __HeapLimit, . - __HeapLimit
mbed_official 31:42176bc3c368 76
mbed_official 31:42176bc3c368 77 .section .vector_table,"a",%progbits
mbed_official 31:42176bc3c368 78 .align 2
mbed_official 31:42176bc3c368 79 .globl __isr_vector
mbed_official 31:42176bc3c368 80 __isr_vector:
mbed_official 31:42176bc3c368 81 .long __StackTop /* Top of Stack */
mbed_official 31:42176bc3c368 82 .long Reset_Handler /* Reset Handler */
mbed_official 31:42176bc3c368 83 .long NMI_Handler /* NMI Handler */
mbed_official 31:42176bc3c368 84 .long HardFault_Handler /* Hard Fault Handler */
mbed_official 31:42176bc3c368 85 .long 0 /* Reserved */
mbed_official 31:42176bc3c368 86 .long 0 /* Reserved */
mbed_official 31:42176bc3c368 87 .long 0 /* Reserved */
mbed_official 31:42176bc3c368 88 .long 0 /* Reserved */
mbed_official 31:42176bc3c368 89 .long 0 /* Reserved */
mbed_official 31:42176bc3c368 90 .long 0 /* Reserved */
mbed_official 31:42176bc3c368 91 .long 0 /* Reserved */
mbed_official 31:42176bc3c368 92 .long SVC_Handler /* SVCall Handler */
mbed_official 31:42176bc3c368 93 .long 0 /* Reserved */
mbed_official 31:42176bc3c368 94 .long 0 /* Reserved */
mbed_official 31:42176bc3c368 95 .long PendSV_Handler /* PendSV Handler */
mbed_official 31:42176bc3c368 96 .long SysTick_Handler /* SysTick Handler */
mbed_official 31:42176bc3c368 97
mbed_official 31:42176bc3c368 98 /* External interrupts */
mbed_official 31:42176bc3c368 99 .long DMA0_IRQHandler /* DMA channel 0 transfer complete interrupt */
mbed_official 31:42176bc3c368 100 .long DMA1_IRQHandler /* DMA channel 1 transfer complete interrupt */
mbed_official 31:42176bc3c368 101 .long DMA2_IRQHandler /* DMA channel 2 transfer complete interrupt */
mbed_official 31:42176bc3c368 102 .long DMA3_IRQHandler /* DMA channel 3 transfer complete interrupt */
mbed_official 31:42176bc3c368 103 .long Default_Handler /* Reserved interrupt 20 */
mbed_official 31:42176bc3c368 104 .long FTFA_IRQHandler /* FTFA interrupt */
mbed_official 31:42176bc3c368 105 .long LVD_LVW_IRQHandler /* Low Voltage Detect, Low Voltage Warning */
mbed_official 31:42176bc3c368 106 .long LLW_IRQHandler /* Low Leakage Wakeup */
mbed_official 31:42176bc3c368 107 .long I2C0_IRQHandler /* I2C0 interrupt */
mbed_official 31:42176bc3c368 108 .long I2C1_IRQHandler /* I2C0 interrupt 25 */
mbed_official 31:42176bc3c368 109 .long SPI0_IRQHandler /* SPI0 interrupt */
mbed_official 31:42176bc3c368 110 .long SPI1_IRQHandler /* SPI1 interrupt */
mbed_official 31:42176bc3c368 111 .long UART0_IRQHandler /* UART0 status/error interrupt */
mbed_official 31:42176bc3c368 112 .long UART1_IRQHandler /* UART1 status/error interrupt */
mbed_official 31:42176bc3c368 113 .long UART2_IRQHandler /* UART2 status/error interrupt */
mbed_official 31:42176bc3c368 114 .long ADC0_IRQHandler /* ADC0 interrupt */
mbed_official 31:42176bc3c368 115 .long CMP0_IRQHandler /* CMP0 interrupt */
mbed_official 31:42176bc3c368 116 .long TPM0_IRQHandler /* TPM0 fault, overflow and channels interrupt */
mbed_official 31:42176bc3c368 117 .long TPM1_IRQHandler /* TPM1 fault, overflow and channels interrupt */
mbed_official 31:42176bc3c368 118 .long TPM2_IRQHandler /* TPM2 fault, overflow and channels interrupt */
mbed_official 31:42176bc3c368 119 .long RTC_IRQHandler /* RTC interrupt */
mbed_official 31:42176bc3c368 120 .long RTC_Seconds_IRQHandler /* RTC seconds interrupt */
mbed_official 31:42176bc3c368 121 .long PIT_IRQHandler /* PIT timer interrupt */
mbed_official 31:42176bc3c368 122 .long I2S_IRQHandler /* I2S transmit interrupt */
mbed_official 31:42176bc3c368 123 .long USB0_IRQHandler /* USB0 interrupt */
mbed_official 31:42176bc3c368 124 .long DAC0_IRQHandler /* DAC interrupt */
mbed_official 31:42176bc3c368 125 .long TSI0_IRQHandler /* TSI0 interrupt */
mbed_official 31:42176bc3c368 126 .long MCG_IRQHandler /* MCG interrupt */
mbed_official 31:42176bc3c368 127 .long LPTimer_IRQHandler /* LPTimer interrupt */
mbed_official 31:42176bc3c368 128 .long LCD_IRQHandler /* Segment LCD Interrupt*/
mbed_official 31:42176bc3c368 129 .long PORTA_IRQHandler /* Port A interrupt */
mbed_official 31:42176bc3c368 130 .long PORTD_IRQHandler /* Port D interrupt */
mbed_official 31:42176bc3c368 131
mbed_official 31:42176bc3c368 132 .size __isr_vector, . - __isr_vector
mbed_official 31:42176bc3c368 133
mbed_official 31:42176bc3c368 134 .section .text.Reset_Handler
mbed_official 31:42176bc3c368 135 .thumb
mbed_official 31:42176bc3c368 136 .thumb_func
mbed_official 31:42176bc3c368 137 .align 2
mbed_official 31:42176bc3c368 138 .globl Reset_Handler
mbed_official 31:42176bc3c368 139 .type Reset_Handler, %function
mbed_official 31:42176bc3c368 140 Reset_Handler:
mbed_official 31:42176bc3c368 141 /* Loop to copy data from read only memory to RAM. The ranges
mbed_official 31:42176bc3c368 142 * of copy from/to are specified by following symbols evaluated in
mbed_official 31:42176bc3c368 143 * linker script.
mbed_official 31:42176bc3c368 144 * __etext: End of code section, i.e., begin of data sections to copy from.
mbed_official 31:42176bc3c368 145 * __data_start__/__data_end__: RAM address range that data should be
mbed_official 31:42176bc3c368 146 * copied to. Both must be aligned to 4 bytes boundary. */
mbed_official 31:42176bc3c368 147
mbed_official 31:42176bc3c368 148 ldr r1, =__etext
mbed_official 31:42176bc3c368 149 ldr r2, =__data_start__
mbed_official 31:42176bc3c368 150 ldr r3, =__data_end__
mbed_official 31:42176bc3c368 151
mbed_official 31:42176bc3c368 152 subs r3, r2
mbed_official 31:42176bc3c368 153 ble .flash_to_ram_loop_end
mbed_official 31:42176bc3c368 154
mbed_official 31:42176bc3c368 155 movs r4, 0
mbed_official 31:42176bc3c368 156 .flash_to_ram_loop:
mbed_official 31:42176bc3c368 157 ldr r0, [r1,r4]
mbed_official 31:42176bc3c368 158 str r0, [r2,r4]
mbed_official 31:42176bc3c368 159 adds r4, 4
mbed_official 31:42176bc3c368 160 cmp r4, r3
mbed_official 31:42176bc3c368 161 blt .flash_to_ram_loop
mbed_official 31:42176bc3c368 162 .flash_to_ram_loop_end:
mbed_official 31:42176bc3c368 163
mbed_official 31:42176bc3c368 164 ldr r0, =SystemInit
mbed_official 31:42176bc3c368 165 blx r0
mbed_official 31:42176bc3c368 166 ldr r0, =_start
mbed_official 31:42176bc3c368 167 bx r0
mbed_official 31:42176bc3c368 168 .pool
mbed_official 31:42176bc3c368 169 .size Reset_Handler, . - Reset_Handler
mbed_official 31:42176bc3c368 170
mbed_official 31:42176bc3c368 171 .text
mbed_official 31:42176bc3c368 172 /* Macro to define default handlers. Default handler
mbed_official 31:42176bc3c368 173 * will be weak symbol and just dead loops. They can be
mbed_official 31:42176bc3c368 174 * overwritten by other handlers */
mbed_official 31:42176bc3c368 175 .macro def_default_handler handler_name
mbed_official 31:42176bc3c368 176 .align 1
mbed_official 31:42176bc3c368 177 .thumb_func
mbed_official 31:42176bc3c368 178 .weak \handler_name
mbed_official 31:42176bc3c368 179 .type \handler_name, %function
mbed_official 31:42176bc3c368 180 \handler_name :
mbed_official 31:42176bc3c368 181 b .
mbed_official 31:42176bc3c368 182 .size \handler_name, . - \handler_name
mbed_official 31:42176bc3c368 183 .endm
mbed_official 31:42176bc3c368 184
mbed_official 31:42176bc3c368 185 def_default_handler NMI_Handler
mbed_official 31:42176bc3c368 186 def_default_handler HardFault_Handler
mbed_official 31:42176bc3c368 187 def_default_handler SVC_Handler
mbed_official 31:42176bc3c368 188 def_default_handler PendSV_Handler
mbed_official 31:42176bc3c368 189 def_default_handler SysTick_Handler
mbed_official 31:42176bc3c368 190 def_default_handler Default_Handler
mbed_official 31:42176bc3c368 191
mbed_official 31:42176bc3c368 192 def_default_handler DMA0_IRQHandler
mbed_official 31:42176bc3c368 193 def_default_handler DMA1_IRQHandler
mbed_official 31:42176bc3c368 194 def_default_handler DMA2_IRQHandler
mbed_official 31:42176bc3c368 195 def_default_handler DMA3_IRQHandler
mbed_official 31:42176bc3c368 196 def_default_handler FTFA_IRQHandler
mbed_official 31:42176bc3c368 197 def_default_handler LVD_LVW_IRQHandler
mbed_official 31:42176bc3c368 198 def_default_handler LLW_IRQHandler
mbed_official 31:42176bc3c368 199 def_default_handler I2C0_IRQHandler
mbed_official 31:42176bc3c368 200 def_default_handler I2C1_IRQHandler
mbed_official 31:42176bc3c368 201 def_default_handler SPI0_IRQHandler
mbed_official 31:42176bc3c368 202 def_default_handler SPI1_IRQHandler
mbed_official 31:42176bc3c368 203 def_default_handler UART0_IRQHandler
mbed_official 31:42176bc3c368 204 def_default_handler UART1_IRQHandler
mbed_official 31:42176bc3c368 205 def_default_handler UART2_IRQHandler
mbed_official 31:42176bc3c368 206 def_default_handler ADC0_IRQHandler
mbed_official 31:42176bc3c368 207 def_default_handler CMP0_IRQHandler
mbed_official 31:42176bc3c368 208 def_default_handler TPM0_IRQHandler
mbed_official 31:42176bc3c368 209 def_default_handler TPM1_IRQHandler
mbed_official 31:42176bc3c368 210 def_default_handler TPM2_IRQHandler
mbed_official 31:42176bc3c368 211 def_default_handler RTC_IRQHandler
mbed_official 31:42176bc3c368 212 def_default_handler RTC_Seconds_IRQHandler
mbed_official 31:42176bc3c368 213 def_default_handler PIT_IRQHandler
mbed_official 31:42176bc3c368 214 def_default_handler I2S_IRQHandler
mbed_official 31:42176bc3c368 215 def_default_handler USB0_IRQHandler
mbed_official 31:42176bc3c368 216 def_default_handler DAC0_IRQHandler
mbed_official 31:42176bc3c368 217 def_default_handler TSI0_IRQHandler
mbed_official 31:42176bc3c368 218 def_default_handler MCG_IRQHandler
mbed_official 31:42176bc3c368 219 def_default_handler LPTimer_IRQHandler
mbed_official 31:42176bc3c368 220 def_default_handler LCD_IRQHandler
mbed_official 31:42176bc3c368 221 def_default_handler PORTA_IRQHandler
mbed_official 31:42176bc3c368 222 def_default_handler PORTD_IRQHandler
mbed_official 31:42176bc3c368 223
mbed_official 31:42176bc3c368 224
mbed_official 31:42176bc3c368 225
mbed_official 31:42176bc3c368 226 .weak DEF_IRQHandler
mbed_official 31:42176bc3c368 227 .set DEF_IRQHandler, Default_Handler
mbed_official 31:42176bc3c368 228
mbed_official 31:42176bc3c368 229 /* Flash protection region, placed at 0x400 */
mbed_official 31:42176bc3c368 230 .text
mbed_official 31:42176bc3c368 231 .thumb
mbed_official 31:42176bc3c368 232 .align 2
mbed_official 31:42176bc3c368 233 .section .kinetis_flash_config_field,"a",%progbits
mbed_official 31:42176bc3c368 234 kinetis_flash_config:
mbed_official 31:42176bc3c368 235 .long 0xffffffff
mbed_official 31:42176bc3c368 236 .long 0xffffffff
mbed_official 31:42176bc3c368 237 .long 0xffffffff
mbed_official 31:42176bc3c368 238 .long 0xfffffffe
mbed_official 31:42176bc3c368 239
mbed_official 31:42176bc3c368 240 .end