mbed library sources

Dependents:   Marvino mbot

Fork of mbed-src by mbed official

Committer:
bogdanm
Date:
Mon Aug 05 14:12:34 2013 +0300
Revision:
13:0645d8841f51
Parent:
vendor/NXP/LPC1768/cmsis/GCC_CR/startup_LPC17xx.cpp@10:3bc89ef62ce7
Child:
67:78dfdb5b4d9e
Update mbed sources to revision 64

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 10:3bc89ef62ce7 1 extern "C" {
emilmont 10:3bc89ef62ce7 2
emilmont 10:3bc89ef62ce7 3 #include "LPC17xx.h"
emilmont 10:3bc89ef62ce7 4
emilmont 10:3bc89ef62ce7 5 #define WEAK __attribute__ ((weak))
emilmont 10:3bc89ef62ce7 6 #define ALIAS(f) __attribute__ ((weak, alias (#f)))
emilmont 10:3bc89ef62ce7 7 #define AFTER_VECTORS __attribute__ ((section(".after_vectors")))
emilmont 10:3bc89ef62ce7 8
emilmont 10:3bc89ef62ce7 9 extern unsigned int __data_section_table;
emilmont 10:3bc89ef62ce7 10 extern unsigned int __data_section_table_end;
emilmont 10:3bc89ef62ce7 11 extern unsigned int __bss_section_table;
emilmont 10:3bc89ef62ce7 12 extern unsigned int __bss_section_table_end;
emilmont 10:3bc89ef62ce7 13
emilmont 10:3bc89ef62ce7 14 extern void __libc_init_array(void);
emilmont 10:3bc89ef62ce7 15 extern int main(void);
emilmont 10:3bc89ef62ce7 16 extern void _vStackTop(void);
emilmont 10:3bc89ef62ce7 17 extern void (* const g_pfnVectors[])(void);
emilmont 10:3bc89ef62ce7 18
emilmont 10:3bc89ef62ce7 19 void ResetISR (void);
emilmont 10:3bc89ef62ce7 20 WEAK void NMI_Handler (void);
emilmont 10:3bc89ef62ce7 21 WEAK void HardFault_Handler (void);
emilmont 10:3bc89ef62ce7 22 WEAK void MemManage_Handler (void);
emilmont 10:3bc89ef62ce7 23 WEAK void BusFault_Handler (void);
emilmont 10:3bc89ef62ce7 24 WEAK void UsageFault_Handler(void);
emilmont 10:3bc89ef62ce7 25 WEAK void SVCall_Handler (void);
emilmont 10:3bc89ef62ce7 26 WEAK void DebugMon_Handler (void);
emilmont 10:3bc89ef62ce7 27 WEAK void PendSV_Handler (void);
emilmont 10:3bc89ef62ce7 28 WEAK void SysTick_Handler (void);
emilmont 10:3bc89ef62ce7 29 WEAK void IntDefaultHandler (void);
emilmont 10:3bc89ef62ce7 30
emilmont 10:3bc89ef62ce7 31 void WDT_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 32 void TIMER0_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 33 void TIMER1_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 34 void TIMER2_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 35 void TIMER3_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 36 void UART0_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 37 void UART1_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 38 void UART2_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 39 void UART3_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 40 void PWM1_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 41 void I2C0_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 42 void I2C1_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 43 void I2C2_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 44 void SPI_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 45 void SSP0_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 46 void SSP1_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 47 void PLL0_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 48 void RTC_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 49 void EINT0_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 50 void EINT1_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 51 void EINT2_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 52 void EINT3_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 53 void ADC_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 54 void BOD_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 55 void USB_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 56 void CAN_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 57 void DMA_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 58 void I2S_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 59 void ENET_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 60 void RIT_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 61 void MCPWM_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 62 void QEI_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 63 void PLL1_IRQHandler (void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 64 void USBActivity_IRQHandler(void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 65 void CANActivity_IRQHandler(void) ALIAS(IntDefaultHandler);
emilmont 10:3bc89ef62ce7 66
emilmont 10:3bc89ef62ce7 67 __attribute__ ((section(".isr_vector")))
emilmont 10:3bc89ef62ce7 68 void (* const g_pfnVectors[])(void) = {
emilmont 10:3bc89ef62ce7 69 &_vStackTop, ResetISR, NMI_Handler,
emilmont 10:3bc89ef62ce7 70 HardFault_Handler,
emilmont 10:3bc89ef62ce7 71 MemManage_Handler,
emilmont 10:3bc89ef62ce7 72 BusFault_Handler,
emilmont 10:3bc89ef62ce7 73 UsageFault_Handler,
emilmont 10:3bc89ef62ce7 74 0,
emilmont 10:3bc89ef62ce7 75 0,
emilmont 10:3bc89ef62ce7 76 0,
emilmont 10:3bc89ef62ce7 77 0,
emilmont 10:3bc89ef62ce7 78 SVCall_Handler,
emilmont 10:3bc89ef62ce7 79 DebugMon_Handler,
emilmont 10:3bc89ef62ce7 80 0,
emilmont 10:3bc89ef62ce7 81 PendSV_Handler,
emilmont 10:3bc89ef62ce7 82 SysTick_Handler,
emilmont 10:3bc89ef62ce7 83 WDT_IRQHandler,
emilmont 10:3bc89ef62ce7 84 TIMER0_IRQHandler,
emilmont 10:3bc89ef62ce7 85 TIMER1_IRQHandler,
emilmont 10:3bc89ef62ce7 86 TIMER2_IRQHandler,
emilmont 10:3bc89ef62ce7 87 TIMER3_IRQHandler,
emilmont 10:3bc89ef62ce7 88 UART0_IRQHandler,
emilmont 10:3bc89ef62ce7 89 UART1_IRQHandler,
emilmont 10:3bc89ef62ce7 90 UART2_IRQHandler,
emilmont 10:3bc89ef62ce7 91 UART3_IRQHandler,
emilmont 10:3bc89ef62ce7 92 PWM1_IRQHandler,
emilmont 10:3bc89ef62ce7 93 I2C0_IRQHandler,
emilmont 10:3bc89ef62ce7 94 I2C1_IRQHandler,
emilmont 10:3bc89ef62ce7 95 I2C2_IRQHandler,
emilmont 10:3bc89ef62ce7 96 SPI_IRQHandler,
emilmont 10:3bc89ef62ce7 97 SSP0_IRQHandler,
emilmont 10:3bc89ef62ce7 98 SSP1_IRQHandler,
emilmont 10:3bc89ef62ce7 99 PLL0_IRQHandler,
emilmont 10:3bc89ef62ce7 100 RTC_IRQHandler,
emilmont 10:3bc89ef62ce7 101 EINT0_IRQHandler,
emilmont 10:3bc89ef62ce7 102 EINT1_IRQHandler,
emilmont 10:3bc89ef62ce7 103 EINT2_IRQHandler,
emilmont 10:3bc89ef62ce7 104 EINT3_IRQHandler,
emilmont 10:3bc89ef62ce7 105 ADC_IRQHandler,
emilmont 10:3bc89ef62ce7 106 BOD_IRQHandler,
emilmont 10:3bc89ef62ce7 107 USB_IRQHandler,
emilmont 10:3bc89ef62ce7 108 CAN_IRQHandler,
emilmont 10:3bc89ef62ce7 109 DMA_IRQHandler,
emilmont 10:3bc89ef62ce7 110 I2S_IRQHandler,
emilmont 10:3bc89ef62ce7 111 ENET_IRQHandler,
emilmont 10:3bc89ef62ce7 112 RIT_IRQHandler,
emilmont 10:3bc89ef62ce7 113 MCPWM_IRQHandler,
emilmont 10:3bc89ef62ce7 114 QEI_IRQHandler,
emilmont 10:3bc89ef62ce7 115 PLL1_IRQHandler,
emilmont 10:3bc89ef62ce7 116 USBActivity_IRQHandler,
emilmont 10:3bc89ef62ce7 117 CANActivity_IRQHandler,
emilmont 10:3bc89ef62ce7 118 };
emilmont 10:3bc89ef62ce7 119
emilmont 10:3bc89ef62ce7 120 AFTER_VECTORS void data_init(unsigned int romstart, unsigned int start, unsigned int len) {
emilmont 10:3bc89ef62ce7 121 unsigned int *pulDest = (unsigned int*) start;
emilmont 10:3bc89ef62ce7 122 unsigned int *pulSrc = (unsigned int*) romstart;
emilmont 10:3bc89ef62ce7 123 unsigned int loop;
emilmont 10:3bc89ef62ce7 124 for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = *pulSrc++;
emilmont 10:3bc89ef62ce7 125 }
emilmont 10:3bc89ef62ce7 126
emilmont 10:3bc89ef62ce7 127 AFTER_VECTORS void bss_init(unsigned int start, unsigned int len) {
emilmont 10:3bc89ef62ce7 128 unsigned int *pulDest = (unsigned int*) start;
emilmont 10:3bc89ef62ce7 129 unsigned int loop;
emilmont 10:3bc89ef62ce7 130 for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = 0;
emilmont 10:3bc89ef62ce7 131 }
emilmont 10:3bc89ef62ce7 132
emilmont 10:3bc89ef62ce7 133 AFTER_VECTORS void ResetISR(void) {
emilmont 10:3bc89ef62ce7 134 unsigned int LoadAddr, ExeAddr, SectionLen;
emilmont 10:3bc89ef62ce7 135 unsigned int *SectionTableAddr;
emilmont 10:3bc89ef62ce7 136
emilmont 10:3bc89ef62ce7 137 SectionTableAddr = &__data_section_table;
emilmont 10:3bc89ef62ce7 138
emilmont 10:3bc89ef62ce7 139 while (SectionTableAddr < &__data_section_table_end) {
emilmont 10:3bc89ef62ce7 140 LoadAddr = *SectionTableAddr++;
emilmont 10:3bc89ef62ce7 141 ExeAddr = *SectionTableAddr++;
emilmont 10:3bc89ef62ce7 142 SectionLen = *SectionTableAddr++;
emilmont 10:3bc89ef62ce7 143 data_init(LoadAddr, ExeAddr, SectionLen);
emilmont 10:3bc89ef62ce7 144 }
emilmont 10:3bc89ef62ce7 145 while (SectionTableAddr < &__bss_section_table_end) {
emilmont 10:3bc89ef62ce7 146 ExeAddr = *SectionTableAddr++;
emilmont 10:3bc89ef62ce7 147 SectionLen = *SectionTableAddr++;
emilmont 10:3bc89ef62ce7 148 bss_init(ExeAddr, SectionLen);
emilmont 10:3bc89ef62ce7 149 }
emilmont 10:3bc89ef62ce7 150
emilmont 10:3bc89ef62ce7 151 SystemInit();
emilmont 10:3bc89ef62ce7 152 __libc_init_array();
emilmont 10:3bc89ef62ce7 153 main();
emilmont 10:3bc89ef62ce7 154 while (1) {;}
emilmont 10:3bc89ef62ce7 155 }
emilmont 10:3bc89ef62ce7 156
emilmont 10:3bc89ef62ce7 157 AFTER_VECTORS void NMI_Handler (void) {}
emilmont 10:3bc89ef62ce7 158 AFTER_VECTORS void HardFault_Handler (void) {}
emilmont 10:3bc89ef62ce7 159 AFTER_VECTORS void MemManage_Handler (void) {}
emilmont 10:3bc89ef62ce7 160 AFTER_VECTORS void BusFault_Handler (void) {}
emilmont 10:3bc89ef62ce7 161 AFTER_VECTORS void UsageFault_Handler(void) {}
emilmont 10:3bc89ef62ce7 162 AFTER_VECTORS void SVCall_Handler (void) {}
emilmont 10:3bc89ef62ce7 163 AFTER_VECTORS void DebugMon_Handler (void) {}
emilmont 10:3bc89ef62ce7 164 AFTER_VECTORS void PendSV_Handler (void) {}
emilmont 10:3bc89ef62ce7 165 AFTER_VECTORS void SysTick_Handler (void) {}
emilmont 10:3bc89ef62ce7 166 AFTER_VECTORS void IntDefaultHandler (void) {}
emilmont 10:3bc89ef62ce7 167
emilmont 10:3bc89ef62ce7 168 int __aeabi_atexit(void *object, void (*destructor)(void *), void *dso_handle) {return 0;}
emilmont 10:3bc89ef62ce7 169 }
emilmont 10:3bc89ef62ce7 170
emilmont 10:3bc89ef62ce7 171 #include <stdlib.h>
emilmont 10:3bc89ef62ce7 172
emilmont 10:3bc89ef62ce7 173 void *operator new(size_t size) {return malloc(size);}
emilmont 10:3bc89ef62ce7 174 void *operator new[](size_t size){return malloc(size);}
emilmont 10:3bc89ef62ce7 175
emilmont 10:3bc89ef62ce7 176 void operator delete(void *p) {free(p);}
emilmont 10:3bc89ef62ce7 177 void operator delete[](void *p) {free(p);}