mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

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:
emilmont
Date:
Fri Jun 14 17:49:17 2013 +0100
Revision:
10:3bc89ef62ce7
Unify mbed library sources

Who changed what in which revision?

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