mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
targets/cmsis/TARGET_NXP/TARGET_LPC11XX_11CXX/TOOLCHAIN_GCC_CR/TARGET_LPC11XX/startup_LPC11xx.cpp@323:9e901b0a5aa1, 2014-09-13 (annotated)
- Committer:
- shaoziyang
- Date:
- Sat Sep 13 14:25:46 2014 +0000
- Revision:
- 323:9e901b0a5aa1
- Parent:
- 120:3e3b6882f22a
test with CLOCK_SETUP = 0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 120:3e3b6882f22a | 1 | extern "C" { |
mbed_official | 120:3e3b6882f22a | 2 | |
mbed_official | 120:3e3b6882f22a | 3 | #include "LPC11xx.h" |
mbed_official | 120:3e3b6882f22a | 4 | |
mbed_official | 120:3e3b6882f22a | 5 | #define WEAK __attribute__ ((weak)) |
mbed_official | 120:3e3b6882f22a | 6 | #define ALIAS(f) __attribute__ ((weak, alias (#f))) |
mbed_official | 120:3e3b6882f22a | 7 | #define AFTER_VECTORS __attribute__ ((section(".after_vectors"))) |
mbed_official | 120:3e3b6882f22a | 8 | |
mbed_official | 120:3e3b6882f22a | 9 | void ResetISR (void); |
mbed_official | 120:3e3b6882f22a | 10 | WEAK void NMI_Handler (void); |
mbed_official | 120:3e3b6882f22a | 11 | WEAK void HardFault_Handler (void); |
mbed_official | 120:3e3b6882f22a | 12 | WEAK void SVC_Handler (void); |
mbed_official | 120:3e3b6882f22a | 13 | WEAK void PendSV_Handler (void); |
mbed_official | 120:3e3b6882f22a | 14 | WEAK void SysTick_Handler (void); |
mbed_official | 120:3e3b6882f22a | 15 | WEAK void IntDefaultHandler (void); |
mbed_official | 120:3e3b6882f22a | 16 | void FLEX_INT0_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 17 | void FLEX_INT1_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 18 | void FLEX_INT2_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 19 | void FLEX_INT3_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 20 | void FLEX_INT4_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 21 | void FLEX_INT5_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 22 | void FLEX_INT6_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 23 | void FLEX_INT7_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 24 | void GINT0_IRQHandler (void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 25 | void GINT1_IRQHandler (void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 26 | void SSP1_IRQHandler (void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 27 | void I2C_IRQHandler (void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 28 | void TIMER16_0_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 29 | void TIMER16_1_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 30 | void TIMER32_0_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 31 | void TIMER32_1_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 32 | void SSP0_IRQHandler (void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 33 | void UART_IRQHandler (void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 34 | void USB_IRQHandler (void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 35 | void USB_FIQHandler (void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 36 | void ADC_IRQHandler (void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 37 | void WDT_IRQHandler (void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 38 | void BOD_IRQHandler (void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 39 | void FMC_IRQHandler (void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 40 | void USBWakeup_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 120:3e3b6882f22a | 41 | |
mbed_official | 120:3e3b6882f22a | 42 | extern void __libc_init_array(void); |
mbed_official | 120:3e3b6882f22a | 43 | extern int main(void); |
mbed_official | 120:3e3b6882f22a | 44 | extern void _vStackTop(void); |
mbed_official | 120:3e3b6882f22a | 45 | |
mbed_official | 120:3e3b6882f22a | 46 | extern void (* const g_pfnVectors[])(void); |
mbed_official | 120:3e3b6882f22a | 47 | __attribute__ ((section(".isr_vector"))) |
mbed_official | 120:3e3b6882f22a | 48 | void (* const g_pfnVectors[])(void) = { |
mbed_official | 120:3e3b6882f22a | 49 | &_vStackTop, |
mbed_official | 120:3e3b6882f22a | 50 | ResetISR, |
mbed_official | 120:3e3b6882f22a | 51 | NMI_Handler, |
mbed_official | 120:3e3b6882f22a | 52 | HardFault_Handler, |
mbed_official | 120:3e3b6882f22a | 53 | 0, |
mbed_official | 120:3e3b6882f22a | 54 | 0, |
mbed_official | 120:3e3b6882f22a | 55 | 0, |
mbed_official | 120:3e3b6882f22a | 56 | 0, |
mbed_official | 120:3e3b6882f22a | 57 | 0, |
mbed_official | 120:3e3b6882f22a | 58 | 0, |
mbed_official | 120:3e3b6882f22a | 59 | 0, |
mbed_official | 120:3e3b6882f22a | 60 | SVC_Handler, |
mbed_official | 120:3e3b6882f22a | 61 | 0, |
mbed_official | 120:3e3b6882f22a | 62 | 0, |
mbed_official | 120:3e3b6882f22a | 63 | PendSV_Handler, |
mbed_official | 120:3e3b6882f22a | 64 | SysTick_Handler, |
mbed_official | 120:3e3b6882f22a | 65 | FLEX_INT0_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 66 | FLEX_INT1_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 67 | FLEX_INT2_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 68 | FLEX_INT3_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 69 | FLEX_INT4_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 70 | FLEX_INT5_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 71 | FLEX_INT6_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 72 | FLEX_INT7_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 73 | GINT0_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 74 | GINT1_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 75 | 0, |
mbed_official | 120:3e3b6882f22a | 76 | 0, |
mbed_official | 120:3e3b6882f22a | 77 | 0, |
mbed_official | 120:3e3b6882f22a | 78 | 0, |
mbed_official | 120:3e3b6882f22a | 79 | SSP1_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 80 | I2C_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 81 | TIMER16_0_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 82 | TIMER16_1_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 83 | TIMER32_0_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 84 | TIMER32_1_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 85 | SSP0_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 86 | UART_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 87 | USB_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 88 | USB_FIQHandler, |
mbed_official | 120:3e3b6882f22a | 89 | ADC_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 90 | WDT_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 91 | BOD_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 92 | FMC_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 93 | 0, |
mbed_official | 120:3e3b6882f22a | 94 | 0, |
mbed_official | 120:3e3b6882f22a | 95 | USBWakeup_IRQHandler, |
mbed_official | 120:3e3b6882f22a | 96 | 0, |
mbed_official | 120:3e3b6882f22a | 97 | }; |
mbed_official | 120:3e3b6882f22a | 98 | |
mbed_official | 120:3e3b6882f22a | 99 | AFTER_VECTORS void data_init(unsigned int romstart, unsigned int start, unsigned int len) { |
mbed_official | 120:3e3b6882f22a | 100 | unsigned int *pulDest = (unsigned int*) start; |
mbed_official | 120:3e3b6882f22a | 101 | unsigned int *pulSrc = (unsigned int*) romstart; |
mbed_official | 120:3e3b6882f22a | 102 | unsigned int loop; |
mbed_official | 120:3e3b6882f22a | 103 | for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = *pulSrc++; |
mbed_official | 120:3e3b6882f22a | 104 | } |
mbed_official | 120:3e3b6882f22a | 105 | |
mbed_official | 120:3e3b6882f22a | 106 | AFTER_VECTORS void bss_init(unsigned int start, unsigned int len) { |
mbed_official | 120:3e3b6882f22a | 107 | unsigned int *pulDest = (unsigned int*) start; |
mbed_official | 120:3e3b6882f22a | 108 | unsigned int loop; |
mbed_official | 120:3e3b6882f22a | 109 | for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = 0; |
mbed_official | 120:3e3b6882f22a | 110 | } |
mbed_official | 120:3e3b6882f22a | 111 | |
mbed_official | 120:3e3b6882f22a | 112 | extern unsigned int __data_section_table; |
mbed_official | 120:3e3b6882f22a | 113 | extern unsigned int __data_section_table_end; |
mbed_official | 120:3e3b6882f22a | 114 | extern unsigned int __bss_section_table_end; |
mbed_official | 120:3e3b6882f22a | 115 | |
mbed_official | 120:3e3b6882f22a | 116 | extern "C" void software_init_hook(void) __attribute__((weak)); |
mbed_official | 120:3e3b6882f22a | 117 | |
mbed_official | 120:3e3b6882f22a | 118 | AFTER_VECTORS void ResetISR(void) { |
mbed_official | 120:3e3b6882f22a | 119 | unsigned int LoadAddr, ExeAddr, SectionLen; |
mbed_official | 120:3e3b6882f22a | 120 | unsigned int *SectionTableAddr; |
mbed_official | 120:3e3b6882f22a | 121 | |
mbed_official | 120:3e3b6882f22a | 122 | // Data Init |
mbed_official | 120:3e3b6882f22a | 123 | SectionTableAddr = &__data_section_table; |
mbed_official | 120:3e3b6882f22a | 124 | while (SectionTableAddr < &__data_section_table_end) { |
mbed_official | 120:3e3b6882f22a | 125 | LoadAddr = *SectionTableAddr++; |
mbed_official | 120:3e3b6882f22a | 126 | ExeAddr = *SectionTableAddr++; |
mbed_official | 120:3e3b6882f22a | 127 | SectionLen = *SectionTableAddr++; |
mbed_official | 120:3e3b6882f22a | 128 | data_init(LoadAddr, ExeAddr, SectionLen); |
mbed_official | 120:3e3b6882f22a | 129 | } |
mbed_official | 120:3e3b6882f22a | 130 | |
mbed_official | 120:3e3b6882f22a | 131 | // BSS Init |
mbed_official | 120:3e3b6882f22a | 132 | while (SectionTableAddr < &__bss_section_table_end) { |
mbed_official | 120:3e3b6882f22a | 133 | ExeAddr = *SectionTableAddr++; |
mbed_official | 120:3e3b6882f22a | 134 | SectionLen = *SectionTableAddr++; |
mbed_official | 120:3e3b6882f22a | 135 | bss_init(ExeAddr, SectionLen); |
mbed_official | 120:3e3b6882f22a | 136 | } |
mbed_official | 120:3e3b6882f22a | 137 | |
mbed_official | 120:3e3b6882f22a | 138 | SystemInit(); |
mbed_official | 120:3e3b6882f22a | 139 | if (software_init_hook) // give control to the RTOS |
mbed_official | 120:3e3b6882f22a | 140 | software_init_hook(); // this will also call __libc_init_array |
mbed_official | 120:3e3b6882f22a | 141 | else { |
mbed_official | 120:3e3b6882f22a | 142 | __libc_init_array(); |
mbed_official | 120:3e3b6882f22a | 143 | main(); |
mbed_official | 120:3e3b6882f22a | 144 | } |
mbed_official | 120:3e3b6882f22a | 145 | while (1) {;} |
mbed_official | 120:3e3b6882f22a | 146 | } |
mbed_official | 120:3e3b6882f22a | 147 | |
mbed_official | 120:3e3b6882f22a | 148 | AFTER_VECTORS void NMI_Handler (void) {while(1){}} |
mbed_official | 120:3e3b6882f22a | 149 | AFTER_VECTORS void HardFault_Handler(void) {while(1){}} |
mbed_official | 120:3e3b6882f22a | 150 | AFTER_VECTORS void SVC_Handler (void) {while(1){}} |
mbed_official | 120:3e3b6882f22a | 151 | AFTER_VECTORS void PendSV_Handler (void) {while(1){}} |
mbed_official | 120:3e3b6882f22a | 152 | AFTER_VECTORS void SysTick_Handler (void) {while(1){}} |
mbed_official | 120:3e3b6882f22a | 153 | AFTER_VECTORS void IntDefaultHandler(void) {while(1){}} |
mbed_official | 120:3e3b6882f22a | 154 | |
mbed_official | 120:3e3b6882f22a | 155 | #include <stdlib.h> |
mbed_official | 120:3e3b6882f22a | 156 | |
mbed_official | 120:3e3b6882f22a | 157 | void *operator new (size_t size) {return malloc(size);} |
mbed_official | 120:3e3b6882f22a | 158 | void *operator new[](size_t size) {return malloc(size);} |
mbed_official | 120:3e3b6882f22a | 159 | |
mbed_official | 120:3e3b6882f22a | 160 | void operator delete (void *p) {free(p);} |
mbed_official | 120:3e3b6882f22a | 161 | void operator delete[](void *p) {free(p);} |
mbed_official | 120:3e3b6882f22a | 162 | |
mbed_official | 120:3e3b6882f22a | 163 | int __aeabi_atexit(void *object, void (*destructor)(void *), void *dso_handle) { |
mbed_official | 120:3e3b6882f22a | 164 | return 0; |
mbed_official | 120:3e3b6882f22a | 165 | } |
mbed_official | 120:3e3b6882f22a | 166 | |
mbed_official | 120:3e3b6882f22a | 167 | } |