mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
targets/cmsis/TARGET_NXP/TARGET_LPC15XX/TOOLCHAIN_GCC_CR/startup_LPC15xx.cpp@323:9e901b0a5aa1, 2014-09-13 (annotated)
- Committer:
- shaoziyang
- Date:
- Sat Sep 13 14:25:46 2014 +0000
- Revision:
- 323:9e901b0a5aa1
- Parent:
- 232:1e593fe58241
test with CLOCK_SETUP = 0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 232:1e593fe58241 | 1 | extern "C" { |
mbed_official | 232:1e593fe58241 | 2 | |
mbed_official | 232:1e593fe58241 | 3 | #include "LPC15xx.h" |
mbed_official | 232:1e593fe58241 | 4 | |
mbed_official | 232:1e593fe58241 | 5 | #define WEAK __attribute__ ((weak)) |
mbed_official | 232:1e593fe58241 | 6 | #define ALIAS(f) __attribute__ ((weak, alias (#f))) |
mbed_official | 232:1e593fe58241 | 7 | #define AFTER_VECTORS __attribute__ ((section(".after_vectors")))void ResetISR(void); |
mbed_official | 232:1e593fe58241 | 8 | |
mbed_official | 232:1e593fe58241 | 9 | extern unsigned int __data_section_table; |
mbed_official | 232:1e593fe58241 | 10 | extern unsigned int __data_section_table_end; |
mbed_official | 232:1e593fe58241 | 11 | extern unsigned int __bss_section_table; |
mbed_official | 232:1e593fe58241 | 12 | extern unsigned int __bss_section_table_end; |
mbed_official | 232:1e593fe58241 | 13 | |
mbed_official | 232:1e593fe58241 | 14 | |
mbed_official | 232:1e593fe58241 | 15 | extern void __libc_init_array(void); |
mbed_official | 232:1e593fe58241 | 16 | extern int main(void); |
mbed_official | 232:1e593fe58241 | 17 | extern void _vStackTop(void); |
mbed_official | 232:1e593fe58241 | 18 | extern void (* const g_pfnVectors[])(void); |
mbed_official | 232:1e593fe58241 | 19 | |
mbed_official | 232:1e593fe58241 | 20 | void ResetISR (void); |
mbed_official | 232:1e593fe58241 | 21 | WEAK void NMI_Handler(void); |
mbed_official | 232:1e593fe58241 | 22 | WEAK void HardFault_Handler(void); |
mbed_official | 232:1e593fe58241 | 23 | WEAK void MemManage_Handler(void); |
mbed_official | 232:1e593fe58241 | 24 | WEAK void BusFault_Handler(void); |
mbed_official | 232:1e593fe58241 | 25 | WEAK void UsageFault_Handler(void); |
mbed_official | 232:1e593fe58241 | 26 | WEAK void SVC_Handler(void); |
mbed_official | 232:1e593fe58241 | 27 | WEAK void DebugMon_Handler(void); |
mbed_official | 232:1e593fe58241 | 28 | WEAK void PendSV_Handler(void); |
mbed_official | 232:1e593fe58241 | 29 | WEAK void SysTick_Handler(void); |
mbed_official | 232:1e593fe58241 | 30 | WEAK void IntDefaultHandler(void); |
mbed_official | 232:1e593fe58241 | 31 | |
mbed_official | 232:1e593fe58241 | 32 | |
mbed_official | 232:1e593fe58241 | 33 | void WDT_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 34 | void BOD_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 35 | void FMC_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 36 | void EEPROM_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 37 | void DMA_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 38 | void GINT0_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 39 | void GINT1_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 40 | void PIN_INT0_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 41 | void PIN_INT1_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 42 | void PIN_INT2_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 43 | void PIN_INT3_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 44 | void PIN_INT4_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 45 | void PIN_INT5_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 46 | void PIN_INT6_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 47 | void PIN_INT7_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 48 | void RIT_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 49 | void SCT0_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 50 | void SCT1_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 51 | void SCT2_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 52 | void SCT3_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 53 | void MRT_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 54 | void UART0_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 55 | void UART1_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 56 | void UART2_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 57 | void I2C0_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 58 | void SPI0_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 59 | void SPI1_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 60 | void CAN_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 61 | void USB_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 62 | void USB_FIQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 63 | void USBWakeup_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 64 | void ADC0A_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 65 | void ADC0B_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 66 | void ADC0_THCMP_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 67 | void ADC0_OVR_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 68 | void ADC1A_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 69 | void ADC1B_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 70 | void ADC1_THCMP_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 71 | void ADC1_OVR_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 72 | void DAC_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 73 | void ACMP0_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 74 | void ACMP1_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 75 | void ACMP2_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 76 | void ACMP3_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 77 | void QEI_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 78 | void RTC_ALARM_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 79 | void RTC_WAKE_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 232:1e593fe58241 | 80 | |
mbed_official | 232:1e593fe58241 | 81 | |
mbed_official | 232:1e593fe58241 | 82 | __attribute__ ((section(".isr_vector"))) |
mbed_official | 232:1e593fe58241 | 83 | void (* const g_pfnVectors[])(void) = { |
mbed_official | 232:1e593fe58241 | 84 | // Core Level - CM3 |
mbed_official | 232:1e593fe58241 | 85 | &_vStackTop, // The initial stack pointer |
mbed_official | 232:1e593fe58241 | 86 | ResetISR, // The reset handler |
mbed_official | 232:1e593fe58241 | 87 | NMI_Handler, // The NMI handler |
mbed_official | 232:1e593fe58241 | 88 | HardFault_Handler, // The hard fault handler |
mbed_official | 232:1e593fe58241 | 89 | MemManage_Handler, // The MPU fault handler |
mbed_official | 232:1e593fe58241 | 90 | BusFault_Handler, // The bus fault handler |
mbed_official | 232:1e593fe58241 | 91 | UsageFault_Handler, // The usage fault handler |
mbed_official | 232:1e593fe58241 | 92 | 0, // Reserved |
mbed_official | 232:1e593fe58241 | 93 | 0, // Reserved |
mbed_official | 232:1e593fe58241 | 94 | 0, // Reserved |
mbed_official | 232:1e593fe58241 | 95 | 0, // Reserved |
mbed_official | 232:1e593fe58241 | 96 | SVC_Handler, // SVCall handler |
mbed_official | 232:1e593fe58241 | 97 | DebugMon_Handler, // Debug monitor handler |
mbed_official | 232:1e593fe58241 | 98 | 0, // Reserved |
mbed_official | 232:1e593fe58241 | 99 | PendSV_Handler, // The PendSV handler |
mbed_official | 232:1e593fe58241 | 100 | SysTick_Handler, // The SysTick handler |
mbed_official | 232:1e593fe58241 | 101 | |
mbed_official | 232:1e593fe58241 | 102 | // Chip Level - LPC15xx |
mbed_official | 232:1e593fe58241 | 103 | WDT_IRQHandler, // 0 - Windowed watchdog timer |
mbed_official | 232:1e593fe58241 | 104 | BOD_IRQHandler, // 1 - BOD |
mbed_official | 232:1e593fe58241 | 105 | FMC_IRQHandler, // 2 - Flash controller |
mbed_official | 232:1e593fe58241 | 106 | EEPROM_IRQHandler, // 3 - EEPROM controller |
mbed_official | 232:1e593fe58241 | 107 | DMA_IRQHandler, // 4 - DMA |
mbed_official | 232:1e593fe58241 | 108 | GINT0_IRQHandler, // 5 - GINT0 |
mbed_official | 232:1e593fe58241 | 109 | GINT1_IRQHandler, // 6 - GINT1 |
mbed_official | 232:1e593fe58241 | 110 | PIN_INT0_IRQHandler, // 7 - PIO INT0 |
mbed_official | 232:1e593fe58241 | 111 | PIN_INT1_IRQHandler, // 8 - PIO INT1 |
mbed_official | 232:1e593fe58241 | 112 | PIN_INT2_IRQHandler, // 9 - PIO INT2 |
mbed_official | 232:1e593fe58241 | 113 | PIN_INT3_IRQHandler, // 10 - PIO INT3 |
mbed_official | 232:1e593fe58241 | 114 | PIN_INT4_IRQHandler, // 11 - PIO INT4 |
mbed_official | 232:1e593fe58241 | 115 | PIN_INT5_IRQHandler, // 12 - PIO INT5 |
mbed_official | 232:1e593fe58241 | 116 | PIN_INT6_IRQHandler, // 13 - PIO INT6 |
mbed_official | 232:1e593fe58241 | 117 | PIN_INT7_IRQHandler, // 14 - PIO INT7 |
mbed_official | 232:1e593fe58241 | 118 | RIT_IRQHandler, // 15 - RIT |
mbed_official | 232:1e593fe58241 | 119 | SCT0_IRQHandler, // 16 - State configurable timer |
mbed_official | 232:1e593fe58241 | 120 | SCT1_IRQHandler, // 17 - State configurable timer |
mbed_official | 232:1e593fe58241 | 121 | SCT2_IRQHandler, // 18 - State configurable timer |
mbed_official | 232:1e593fe58241 | 122 | SCT3_IRQHandler, // 19 - State configurable timer |
mbed_official | 232:1e593fe58241 | 123 | MRT_IRQHandler, // 20 - Multi-Rate Timer |
mbed_official | 232:1e593fe58241 | 124 | UART0_IRQHandler, // 21 - UART0 |
mbed_official | 232:1e593fe58241 | 125 | UART1_IRQHandler, // 22 - UART1 |
mbed_official | 232:1e593fe58241 | 126 | UART2_IRQHandler, // 23 - UART2 |
mbed_official | 232:1e593fe58241 | 127 | I2C0_IRQHandler, // 24 - I2C0 controller |
mbed_official | 232:1e593fe58241 | 128 | SPI0_IRQHandler, // 25 - SPI0 controller |
mbed_official | 232:1e593fe58241 | 129 | SPI1_IRQHandler, // 26 - SPI1 controller |
mbed_official | 232:1e593fe58241 | 130 | CAN_IRQHandler, // 27 - C_CAN0 |
mbed_official | 232:1e593fe58241 | 131 | USB_IRQHandler, // 28 - USB IRQ |
mbed_official | 232:1e593fe58241 | 132 | USB_FIQHandler, // 29 - USB FIQ |
mbed_official | 232:1e593fe58241 | 133 | USBWakeup_IRQHandler, // 30 - USB wake-up |
mbed_official | 232:1e593fe58241 | 134 | ADC0A_IRQHandler, // 31 - ADC0 sequence A completion |
mbed_official | 232:1e593fe58241 | 135 | ADC0B_IRQHandler, // 32 - ADC0 sequence B completion |
mbed_official | 232:1e593fe58241 | 136 | ADC0_THCMP_IRQHandler, // 33 - ADC0 threshold compare |
mbed_official | 232:1e593fe58241 | 137 | ADC0_OVR_IRQHandler, // 34 - ADC0 overrun |
mbed_official | 232:1e593fe58241 | 138 | ADC1A_IRQHandler, // 35 - ADC1 sequence A completion |
mbed_official | 232:1e593fe58241 | 139 | ADC1B_IRQHandler, // 36 - ADC1 sequence B completion |
mbed_official | 232:1e593fe58241 | 140 | ADC1_THCMP_IRQHandler, // 37 - ADC1 threshold compare |
mbed_official | 232:1e593fe58241 | 141 | ADC1_OVR_IRQHandler, // 38 - ADC1 overrun |
mbed_official | 232:1e593fe58241 | 142 | DAC_IRQHandler, // 39 - DAC |
mbed_official | 232:1e593fe58241 | 143 | ACMP0_IRQHandler, // 40 - Analog Comparator 0 |
mbed_official | 232:1e593fe58241 | 144 | ACMP1_IRQHandler, // 41 - Analog Comparator 1 |
mbed_official | 232:1e593fe58241 | 145 | ACMP2_IRQHandler, // 42 - Analog Comparator 2 |
mbed_official | 232:1e593fe58241 | 146 | ACMP3_IRQHandler, // 43 - Analog Comparator 3 |
mbed_official | 232:1e593fe58241 | 147 | QEI_IRQHandler, // 44 - QEI |
mbed_official | 232:1e593fe58241 | 148 | RTC_ALARM_IRQHandler, // 45 - RTC alarm |
mbed_official | 232:1e593fe58241 | 149 | RTC_WAKE_IRQHandler, // 46 - RTC wake-up |
mbed_official | 232:1e593fe58241 | 150 | |
mbed_official | 232:1e593fe58241 | 151 | }; |
mbed_official | 232:1e593fe58241 | 152 | /* End Vector */ |
mbed_official | 232:1e593fe58241 | 153 | |
mbed_official | 232:1e593fe58241 | 154 | AFTER_VECTORS void data_init(unsigned int romstart, unsigned int start, unsigned int len) { |
mbed_official | 232:1e593fe58241 | 155 | unsigned int *pulDest = (unsigned int*) start; |
mbed_official | 232:1e593fe58241 | 156 | unsigned int *pulSrc = (unsigned int*) romstart; |
mbed_official | 232:1e593fe58241 | 157 | unsigned int loop; |
mbed_official | 232:1e593fe58241 | 158 | for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = *pulSrc++; |
mbed_official | 232:1e593fe58241 | 159 | } |
mbed_official | 232:1e593fe58241 | 160 | |
mbed_official | 232:1e593fe58241 | 161 | AFTER_VECTORS void bss_init(unsigned int start, unsigned int len) { |
mbed_official | 232:1e593fe58241 | 162 | unsigned int *pulDest = (unsigned int*) start; |
mbed_official | 232:1e593fe58241 | 163 | unsigned int loop; |
mbed_official | 232:1e593fe58241 | 164 | for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = 0; |
mbed_official | 232:1e593fe58241 | 165 | } |
mbed_official | 232:1e593fe58241 | 166 | |
mbed_official | 232:1e593fe58241 | 167 | |
mbed_official | 232:1e593fe58241 | 168 | /* Reset entry point*/ |
mbed_official | 232:1e593fe58241 | 169 | extern "C" void software_init_hook(void) __attribute__((weak)); |
mbed_official | 232:1e593fe58241 | 170 | |
mbed_official | 232:1e593fe58241 | 171 | AFTER_VECTORS void ResetISR(void) { |
mbed_official | 232:1e593fe58241 | 172 | unsigned int LoadAddr, ExeAddr, SectionLen; |
mbed_official | 232:1e593fe58241 | 173 | unsigned int *SectionTableAddr; |
mbed_official | 232:1e593fe58241 | 174 | |
mbed_official | 232:1e593fe58241 | 175 | SectionTableAddr = &__data_section_table; |
mbed_official | 232:1e593fe58241 | 176 | |
mbed_official | 232:1e593fe58241 | 177 | while (SectionTableAddr < &__data_section_table_end) { |
mbed_official | 232:1e593fe58241 | 178 | LoadAddr = *SectionTableAddr++; |
mbed_official | 232:1e593fe58241 | 179 | ExeAddr = *SectionTableAddr++; |
mbed_official | 232:1e593fe58241 | 180 | SectionLen = *SectionTableAddr++; |
mbed_official | 232:1e593fe58241 | 181 | data_init(LoadAddr, ExeAddr, SectionLen); |
mbed_official | 232:1e593fe58241 | 182 | } |
mbed_official | 232:1e593fe58241 | 183 | while (SectionTableAddr < &__bss_section_table_end) { |
mbed_official | 232:1e593fe58241 | 184 | ExeAddr = *SectionTableAddr++; |
mbed_official | 232:1e593fe58241 | 185 | SectionLen = *SectionTableAddr++; |
mbed_official | 232:1e593fe58241 | 186 | bss_init(ExeAddr, SectionLen); |
mbed_official | 232:1e593fe58241 | 187 | } |
mbed_official | 232:1e593fe58241 | 188 | |
mbed_official | 232:1e593fe58241 | 189 | SystemInit(); |
mbed_official | 232:1e593fe58241 | 190 | if (software_init_hook) |
mbed_official | 232:1e593fe58241 | 191 | software_init_hook(); |
mbed_official | 232:1e593fe58241 | 192 | else { |
mbed_official | 232:1e593fe58241 | 193 | __libc_init_array(); |
mbed_official | 232:1e593fe58241 | 194 | main(); |
mbed_official | 232:1e593fe58241 | 195 | } |
mbed_official | 232:1e593fe58241 | 196 | while (1) {;} |
mbed_official | 232:1e593fe58241 | 197 | } |
mbed_official | 232:1e593fe58241 | 198 | |
mbed_official | 232:1e593fe58241 | 199 | AFTER_VECTORS void NMI_Handler (void) {} |
mbed_official | 232:1e593fe58241 | 200 | AFTER_VECTORS void HardFault_Handler (void) {} |
mbed_official | 232:1e593fe58241 | 201 | AFTER_VECTORS void MemManage_Handler (void) {} |
mbed_official | 232:1e593fe58241 | 202 | AFTER_VECTORS void BusFault_Handler (void) {} |
mbed_official | 232:1e593fe58241 | 203 | AFTER_VECTORS void UsageFault_Handler(void) {} |
mbed_official | 232:1e593fe58241 | 204 | AFTER_VECTORS void SVC_Handler (void) {} |
mbed_official | 232:1e593fe58241 | 205 | AFTER_VECTORS void DebugMon_Handler (void) {} |
mbed_official | 232:1e593fe58241 | 206 | AFTER_VECTORS void PendSV_Handler (void) {} |
mbed_official | 232:1e593fe58241 | 207 | AFTER_VECTORS void SysTick_Handler (void) {} |
mbed_official | 232:1e593fe58241 | 208 | AFTER_VECTORS void IntDefaultHandler (void) {} |
mbed_official | 232:1e593fe58241 | 209 | |
mbed_official | 232:1e593fe58241 | 210 | int __aeabi_atexit(void *object, void (*destructor)(void *), void *dso_handle) {return 0;} |
mbed_official | 232:1e593fe58241 | 211 | } |
mbed_official | 232:1e593fe58241 | 212 | |
mbed_official | 232:1e593fe58241 | 213 | #include <stdlib.h> |
mbed_official | 232:1e593fe58241 | 214 | |
mbed_official | 232:1e593fe58241 | 215 | void *operator new(size_t size) {return malloc(size);} |
mbed_official | 232:1e593fe58241 | 216 | void *operator new[](size_t size){return malloc(size);} |
mbed_official | 232:1e593fe58241 | 217 | |
mbed_official | 232:1e593fe58241 | 218 | void operator delete(void *p) {free(p);} |
mbed_official | 232:1e593fe58241 | 219 | void operator delete[](void *p) {free(p);} |