mbed library sources modified for open wear
Dependents: openwear-lifelogger-example
Fork of mbed-src by
targets/cmsis/TARGET_NXP/TARGET_LPC43XX/TOOLCHAIN_GCC_CR/startup_LPC43xx.cpp@256:76fd9a263045, 2014-07-15 (annotated)
- Committer:
- mbed_official
- Date:
- Tue Jul 15 07:45:08 2014 +0100
- Revision:
- 256:76fd9a263045
- Parent:
- 67:78dfdb5b4d9e
Synchronized with git revision 2031512f69c228e1d13ea89c39409db813af949f
Full URL: https://github.com/mbedmicro/mbed/commit/2031512f69c228e1d13ea89c39409db813af949f/
[LPC4330] Updated LPC4330_M4 port
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 256:76fd9a263045 | 1 | //***************************************************************************** |
mbed_official | 256:76fd9a263045 | 2 | // +--+ |
mbed_official | 256:76fd9a263045 | 3 | // | ++----+ |
mbed_official | 256:76fd9a263045 | 4 | // +-++ | |
mbed_official | 256:76fd9a263045 | 5 | // | | |
mbed_official | 256:76fd9a263045 | 6 | // +-+--+ | |
mbed_official | 256:76fd9a263045 | 7 | // | +--+--+ |
bogdanm | 20:4263a77256ae | 8 | // +----+ Copyright (c) 2011-12 Code Red Technologies Ltd. |
bogdanm | 20:4263a77256ae | 9 | // |
bogdanm | 20:4263a77256ae | 10 | // LPC43xx Microcontroller Startup code for use with Red Suite |
bogdanm | 20:4263a77256ae | 11 | // |
bogdanm | 20:4263a77256ae | 12 | // Version : 120430 |
bogdanm | 20:4263a77256ae | 13 | // |
bogdanm | 20:4263a77256ae | 14 | // Software License Agreement |
mbed_official | 256:76fd9a263045 | 15 | // |
bogdanm | 20:4263a77256ae | 16 | // The software is owned by Code Red Technologies and/or its suppliers, and is |
mbed_official | 256:76fd9a263045 | 17 | // protected under applicable copyright laws. All rights are reserved. Any |
mbed_official | 256:76fd9a263045 | 18 | // use in violation of the foregoing restrictions may subject the user to criminal |
mbed_official | 256:76fd9a263045 | 19 | // sanctions under applicable laws, as well as to civil liability for the breach |
bogdanm | 20:4263a77256ae | 20 | // of the terms and conditions of this license. |
mbed_official | 256:76fd9a263045 | 21 | // |
bogdanm | 20:4263a77256ae | 22 | // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED |
bogdanm | 20:4263a77256ae | 23 | // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF |
bogdanm | 20:4263a77256ae | 24 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. |
bogdanm | 20:4263a77256ae | 25 | // USE OF THIS SOFTWARE FOR COMMERCIAL DEVELOPMENT AND/OR EDUCATION IS SUBJECT |
bogdanm | 20:4263a77256ae | 26 | // TO A CURRENT END USER LICENSE AGREEMENT (COMMERCIAL OR EDUCATIONAL) WITH |
mbed_official | 256:76fd9a263045 | 27 | // CODE RED TECHNOLOGIES LTD. |
bogdanm | 20:4263a77256ae | 28 | // |
mbed_official | 256:76fd9a263045 | 29 | //***************************************************************************** |
mbed_official | 256:76fd9a263045 | 30 | #if defined (__cplusplus) |
bogdanm | 20:4263a77256ae | 31 | #ifdef __REDLIB__ |
bogdanm | 20:4263a77256ae | 32 | #error Redlib does not support C++ |
bogdanm | 20:4263a77256ae | 33 | #else |
mbed_official | 256:76fd9a263045 | 34 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 35 | // |
bogdanm | 20:4263a77256ae | 36 | // The entry point for the C++ library startup |
bogdanm | 20:4263a77256ae | 37 | // |
mbed_official | 256:76fd9a263045 | 38 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 39 | extern "C" { |
mbed_official | 256:76fd9a263045 | 40 | extern void __libc_init_array(void); |
bogdanm | 20:4263a77256ae | 41 | } |
bogdanm | 20:4263a77256ae | 42 | #endif |
bogdanm | 20:4263a77256ae | 43 | #endif |
bogdanm | 20:4263a77256ae | 44 | |
bogdanm | 20:4263a77256ae | 45 | #define WEAK __attribute__ ((weak)) |
mbed_official | 256:76fd9a263045 | 46 | #define ALIAS(f) __attribute__ ((weak, alias (#f))) |
bogdanm | 20:4263a77256ae | 47 | |
mbed_official | 256:76fd9a263045 | 48 | // Code Red - if CMSIS is being used, then SystemInit() routine |
mbed_official | 256:76fd9a263045 | 49 | // will be called by startup code rather than in application's main() |
mbed_official | 256:76fd9a263045 | 50 | #if defined (__USE_CMSIS) |
bogdanm | 20:4263a77256ae | 51 | #include "LPC43xx.h" |
bogdanm | 20:4263a77256ae | 52 | #endif |
bogdanm | 20:4263a77256ae | 53 | |
mbed_official | 256:76fd9a263045 | 54 | //***************************************************************************** |
mbed_official | 256:76fd9a263045 | 55 | #if defined (__cplusplus) |
bogdanm | 20:4263a77256ae | 56 | extern "C" { |
bogdanm | 20:4263a77256ae | 57 | #endif |
bogdanm | 20:4263a77256ae | 58 | |
mbed_official | 256:76fd9a263045 | 59 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 60 | // |
bogdanm | 20:4263a77256ae | 61 | // Forward declaration of the default handlers. These are aliased. |
mbed_official | 256:76fd9a263045 | 62 | // When the application defines a handler (with the same name), this will |
bogdanm | 20:4263a77256ae | 63 | // automatically take precedence over these weak definitions |
bogdanm | 20:4263a77256ae | 64 | // |
mbed_official | 256:76fd9a263045 | 65 | //***************************************************************************** |
mbed_official | 256:76fd9a263045 | 66 | void ResetISR(void); |
bogdanm | 20:4263a77256ae | 67 | WEAK void NMI_Handler(void); |
bogdanm | 20:4263a77256ae | 68 | WEAK void HardFault_Handler(void); |
bogdanm | 20:4263a77256ae | 69 | WEAK void MemManage_Handler(void); |
bogdanm | 20:4263a77256ae | 70 | WEAK void BusFault_Handler(void); |
bogdanm | 20:4263a77256ae | 71 | WEAK void UsageFault_Handler(void); |
bogdanm | 20:4263a77256ae | 72 | WEAK void SVC_Handler(void); |
bogdanm | 20:4263a77256ae | 73 | WEAK void DebugMon_Handler(void); |
bogdanm | 20:4263a77256ae | 74 | WEAK void PendSV_Handler(void); |
bogdanm | 20:4263a77256ae | 75 | WEAK void SysTick_Handler(void); |
bogdanm | 20:4263a77256ae | 76 | WEAK void IntDefaultHandler(void); |
bogdanm | 20:4263a77256ae | 77 | |
mbed_official | 256:76fd9a263045 | 78 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 79 | // |
bogdanm | 20:4263a77256ae | 80 | // Forward declaration of the specific IRQ handlers. These are aliased |
bogdanm | 20:4263a77256ae | 81 | // to the IntDefaultHandler, which is a 'forever' loop. When the application |
mbed_official | 256:76fd9a263045 | 82 | // defines a handler (with the same name), this will automatically take |
bogdanm | 20:4263a77256ae | 83 | // precedence over these weak definitions |
bogdanm | 20:4263a77256ae | 84 | // |
mbed_official | 256:76fd9a263045 | 85 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 86 | void DAC_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 256:76fd9a263045 | 87 | void M0CORE_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 88 | void DMA_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 256:76fd9a263045 | 89 | void EZH_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 256:76fd9a263045 | 90 | void FLASH_EEPROM_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 91 | void ETH_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 92 | void SDIO_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 93 | void LCD_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 94 | void USB0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 95 | void USB1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 96 | void SCT_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 97 | void RIT_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 98 | void TIMER0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 99 | void TIMER1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 100 | void TIMER2_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 101 | void TIMER3_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 102 | void MCPWM_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 103 | void ADC0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 104 | void I2C0_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 256:76fd9a263045 | 105 | void SPI_IRQHandler (void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 106 | void I2C1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 107 | void ADC1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 108 | void SSP0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 109 | void SSP1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 110 | void UART0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 111 | void UART1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 112 | void UART2_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 113 | void UART3_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 114 | void I2S0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 115 | void I2S1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 116 | void SPIFI_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 117 | void SGPIO_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 118 | void GPIO0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 119 | void GPIO1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 120 | void GPIO2_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 121 | void GPIO3_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 122 | void GPIO4_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 123 | void GPIO5_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 124 | void GPIO6_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 125 | void GPIO7_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 126 | void GINT0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 127 | void GINT1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 128 | void EVRT_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 129 | void CAN1_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 256:76fd9a263045 | 130 | void VADC_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 131 | void ATIMER_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 132 | void RTC_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 133 | void WDT_IRQHandler(void) ALIAS(IntDefaultHandler); |
mbed_official | 256:76fd9a263045 | 134 | void M0s_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 135 | void CAN0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 136 | void QEI_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 137 | |
mbed_official | 256:76fd9a263045 | 138 | |
mbed_official | 256:76fd9a263045 | 139 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 140 | // |
bogdanm | 20:4263a77256ae | 141 | // The entry point for the application. |
bogdanm | 20:4263a77256ae | 142 | // __main() is the entry point for Redlib based applications |
bogdanm | 20:4263a77256ae | 143 | // main() is the entry point for Newlib based applications |
bogdanm | 20:4263a77256ae | 144 | // |
mbed_official | 256:76fd9a263045 | 145 | //***************************************************************************** |
mbed_official | 256:76fd9a263045 | 146 | #if defined (__REDLIB__) |
bogdanm | 20:4263a77256ae | 147 | extern void __main(void); |
bogdanm | 20:4263a77256ae | 148 | #endif |
bogdanm | 20:4263a77256ae | 149 | extern int main(void); |
mbed_official | 256:76fd9a263045 | 150 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 151 | // |
bogdanm | 20:4263a77256ae | 152 | // External declaration for the pointer to the stack top from the Linker Script |
bogdanm | 20:4263a77256ae | 153 | // |
mbed_official | 256:76fd9a263045 | 154 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 155 | extern void _vStackTop(void); |
bogdanm | 20:4263a77256ae | 156 | |
mbed_official | 256:76fd9a263045 | 157 | //***************************************************************************** |
mbed_official | 256:76fd9a263045 | 158 | #if defined (__cplusplus) |
mbed_official | 256:76fd9a263045 | 159 | } // extern "C" |
bogdanm | 20:4263a77256ae | 160 | #endif |
mbed_official | 256:76fd9a263045 | 161 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 162 | // |
bogdanm | 20:4263a77256ae | 163 | // The vector table. |
bogdanm | 20:4263a77256ae | 164 | // This relies on the linker script to place at correct location in memory. |
bogdanm | 20:4263a77256ae | 165 | // |
mbed_official | 256:76fd9a263045 | 166 | //***************************************************************************** |
mbed_official | 256:76fd9a263045 | 167 | extern void (* const g_pfnVectors[])(void); |
bogdanm | 20:4263a77256ae | 168 | __attribute__ ((section(".isr_vector"))) |
mbed_official | 256:76fd9a263045 | 169 | void (* const g_pfnVectors[])(void) = { |
mbed_official | 256:76fd9a263045 | 170 | // Core Level - CM4 |
mbed_official | 256:76fd9a263045 | 171 | &_vStackTop, // The initial stack pointer |
mbed_official | 256:76fd9a263045 | 172 | ResetISR, // The reset handler |
mbed_official | 256:76fd9a263045 | 173 | NMI_Handler, // The NMI handler |
mbed_official | 256:76fd9a263045 | 174 | HardFault_Handler, // The hard fault handler |
mbed_official | 256:76fd9a263045 | 175 | MemManage_Handler, // The MPU fault handler |
mbed_official | 256:76fd9a263045 | 176 | BusFault_Handler, // The bus fault handler |
mbed_official | 256:76fd9a263045 | 177 | UsageFault_Handler, // The usage fault handler |
mbed_official | 256:76fd9a263045 | 178 | 0, // Reserved |
mbed_official | 256:76fd9a263045 | 179 | 0, // Reserved |
mbed_official | 256:76fd9a263045 | 180 | 0, // Reserved |
mbed_official | 256:76fd9a263045 | 181 | 0, // Reserved |
mbed_official | 256:76fd9a263045 | 182 | SVC_Handler, // SVCall handler |
mbed_official | 256:76fd9a263045 | 183 | DebugMon_Handler, // Debug monitor handler |
mbed_official | 256:76fd9a263045 | 184 | 0, // Reserved |
mbed_official | 256:76fd9a263045 | 185 | PendSV_Handler, // The PendSV handler |
mbed_official | 256:76fd9a263045 | 186 | SysTick_Handler, // The SysTick handler |
bogdanm | 20:4263a77256ae | 187 | |
mbed_official | 256:76fd9a263045 | 188 | // Chip Level - LPC43 |
mbed_official | 256:76fd9a263045 | 189 | DAC_IRQHandler, // 16 |
mbed_official | 256:76fd9a263045 | 190 | M0CORE_IRQHandler, // 17 |
mbed_official | 256:76fd9a263045 | 191 | DMA_IRQHandler, // 18 |
mbed_official | 256:76fd9a263045 | 192 | EZH_IRQHandler, // 19 |
mbed_official | 256:76fd9a263045 | 193 | FLASH_EEPROM_IRQHandler, // 20 |
mbed_official | 256:76fd9a263045 | 194 | ETH_IRQHandler, // 21 |
mbed_official | 256:76fd9a263045 | 195 | SDIO_IRQHandler, // 22 |
mbed_official | 256:76fd9a263045 | 196 | LCD_IRQHandler, // 23 |
mbed_official | 256:76fd9a263045 | 197 | USB0_IRQHandler, // 24 |
mbed_official | 256:76fd9a263045 | 198 | USB1_IRQHandler, // 25 |
mbed_official | 256:76fd9a263045 | 199 | SCT_IRQHandler, // 26 |
mbed_official | 256:76fd9a263045 | 200 | RIT_IRQHandler, // 27 |
mbed_official | 256:76fd9a263045 | 201 | TIMER0_IRQHandler, // 28 |
mbed_official | 256:76fd9a263045 | 202 | TIMER1_IRQHandler, // 29 |
mbed_official | 256:76fd9a263045 | 203 | TIMER2_IRQHandler, // 30 |
mbed_official | 256:76fd9a263045 | 204 | TIMER3_IRQHandler, // 31 |
mbed_official | 256:76fd9a263045 | 205 | MCPWM_IRQHandler, // 32 |
mbed_official | 256:76fd9a263045 | 206 | ADC0_IRQHandler, // 33 |
mbed_official | 256:76fd9a263045 | 207 | I2C0_IRQHandler, // 34 |
mbed_official | 256:76fd9a263045 | 208 | I2C1_IRQHandler, // 35 |
mbed_official | 256:76fd9a263045 | 209 | SPI_IRQHandler, // 36 |
mbed_official | 256:76fd9a263045 | 210 | ADC1_IRQHandler, // 37 |
mbed_official | 256:76fd9a263045 | 211 | SSP0_IRQHandler, // 38 |
mbed_official | 256:76fd9a263045 | 212 | SSP1_IRQHandler, // 39 |
mbed_official | 256:76fd9a263045 | 213 | UART0_IRQHandler, // 40 |
mbed_official | 256:76fd9a263045 | 214 | UART1_IRQHandler, // 41 |
mbed_official | 256:76fd9a263045 | 215 | UART2_IRQHandler, // 42 |
mbed_official | 256:76fd9a263045 | 216 | UART3_IRQHandler, // 43 |
mbed_official | 256:76fd9a263045 | 217 | I2S0_IRQHandler, // 44 |
mbed_official | 256:76fd9a263045 | 218 | I2S1_IRQHandler, // 45 |
mbed_official | 256:76fd9a263045 | 219 | SPIFI_IRQHandler, // 46 |
mbed_official | 256:76fd9a263045 | 220 | SGPIO_IRQHandler, // 47 |
mbed_official | 256:76fd9a263045 | 221 | GPIO0_IRQHandler, // 48 |
mbed_official | 256:76fd9a263045 | 222 | GPIO1_IRQHandler, // 49 |
mbed_official | 256:76fd9a263045 | 223 | GPIO2_IRQHandler, // 50 |
mbed_official | 256:76fd9a263045 | 224 | GPIO3_IRQHandler, // 51 |
mbed_official | 256:76fd9a263045 | 225 | GPIO4_IRQHandler, // 52 |
mbed_official | 256:76fd9a263045 | 226 | GPIO5_IRQHandler, // 53 |
mbed_official | 256:76fd9a263045 | 227 | GPIO6_IRQHandler, // 54 |
mbed_official | 256:76fd9a263045 | 228 | GPIO7_IRQHandler, // 55 |
mbed_official | 256:76fd9a263045 | 229 | GINT0_IRQHandler, // 56 |
mbed_official | 256:76fd9a263045 | 230 | GINT1_IRQHandler, // 57 |
mbed_official | 256:76fd9a263045 | 231 | EVRT_IRQHandler, // 58 |
mbed_official | 256:76fd9a263045 | 232 | CAN1_IRQHandler, // 59 |
mbed_official | 256:76fd9a263045 | 233 | 0, // 60 |
mbed_official | 256:76fd9a263045 | 234 | VADC_IRQHandler, // 61 |
mbed_official | 256:76fd9a263045 | 235 | ATIMER_IRQHandler, // 62 |
mbed_official | 256:76fd9a263045 | 236 | RTC_IRQHandler, // 63 |
mbed_official | 256:76fd9a263045 | 237 | 0, // 64 |
mbed_official | 256:76fd9a263045 | 238 | WDT_IRQHandler, // 65 |
mbed_official | 256:76fd9a263045 | 239 | M0s_IRQHandler, // 66 |
mbed_official | 256:76fd9a263045 | 240 | CAN0_IRQHandler, // 67 |
mbed_official | 256:76fd9a263045 | 241 | QEI_IRQHandler, // 68 |
mbed_official | 256:76fd9a263045 | 242 | }; |
bogdanm | 20:4263a77256ae | 243 | |
mbed_official | 256:76fd9a263045 | 244 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 245 | // Functions to carry out the initialization of RW and BSS data sections. These |
bogdanm | 20:4263a77256ae | 246 | // are written as separate functions rather than being inlined within the |
bogdanm | 20:4263a77256ae | 247 | // ResetISR() function in order to cope with MCUs with multiple banks of |
bogdanm | 20:4263a77256ae | 248 | // memory. |
mbed_official | 256:76fd9a263045 | 249 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 250 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 251 | void data_init(unsigned int romstart, unsigned int start, unsigned int len) { |
mbed_official | 256:76fd9a263045 | 252 | unsigned int *pulDest = (unsigned int*) start; |
mbed_official | 256:76fd9a263045 | 253 | unsigned int *pulSrc = (unsigned int*) romstart; |
bogdanm | 20:4263a77256ae | 254 | unsigned int loop; |
bogdanm | 20:4263a77256ae | 255 | for (loop = 0; loop < len; loop = loop + 4) |
bogdanm | 20:4263a77256ae | 256 | *pulDest++ = *pulSrc++; |
bogdanm | 20:4263a77256ae | 257 | } |
bogdanm | 20:4263a77256ae | 258 | |
bogdanm | 20:4263a77256ae | 259 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 260 | void bss_init(unsigned int start, unsigned int len) { |
mbed_official | 256:76fd9a263045 | 261 | unsigned int *pulDest = (unsigned int*) start; |
bogdanm | 20:4263a77256ae | 262 | unsigned int loop; |
bogdanm | 20:4263a77256ae | 263 | for (loop = 0; loop < len; loop = loop + 4) |
bogdanm | 20:4263a77256ae | 264 | *pulDest++ = 0; |
bogdanm | 20:4263a77256ae | 265 | } |
bogdanm | 20:4263a77256ae | 266 | |
mbed_official | 256:76fd9a263045 | 267 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 268 | // The following symbols are constructs generated by the linker, indicating |
bogdanm | 20:4263a77256ae | 269 | // the location of various points in the "Global Section Table". This table is |
bogdanm | 20:4263a77256ae | 270 | // created by the linker via the Code Red managed linker script mechanism. It |
bogdanm | 20:4263a77256ae | 271 | // contains the load address, execution address and length of each RW data |
bogdanm | 20:4263a77256ae | 272 | // section and the execution and length of each BSS (zero initialized) section. |
mbed_official | 256:76fd9a263045 | 273 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 274 | extern unsigned int __data_section_table; |
bogdanm | 20:4263a77256ae | 275 | extern unsigned int __data_section_table_end; |
bogdanm | 20:4263a77256ae | 276 | extern unsigned int __bss_section_table; |
bogdanm | 20:4263a77256ae | 277 | extern unsigned int __bss_section_table_end; |
bogdanm | 20:4263a77256ae | 278 | |
mbed_official | 256:76fd9a263045 | 279 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 280 | // Reset entry point for your code. |
bogdanm | 20:4263a77256ae | 281 | // Sets up a simple runtime environment and initializes the C/C++ |
bogdanm | 20:4263a77256ae | 282 | // library. |
bogdanm | 20:4263a77256ae | 283 | // |
mbed_official | 256:76fd9a263045 | 284 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 285 | void |
bogdanm | 20:4263a77256ae | 286 | ResetISR(void) { |
bogdanm | 20:4263a77256ae | 287 | |
mbed_official | 256:76fd9a263045 | 288 | // ************************************************************* |
mbed_official | 256:76fd9a263045 | 289 | // The following conditional block of code manually resets as |
mbed_official | 256:76fd9a263045 | 290 | // much of the peripheral set of the LPC43 as possible. This is |
mbed_official | 256:76fd9a263045 | 291 | // done because the LPC43 does not provide a means of triggering |
mbed_official | 256:76fd9a263045 | 292 | // a full system reset under debugger control, which can cause |
mbed_official | 256:76fd9a263045 | 293 | // problems in certain circumstances when debugging. |
mbed_official | 256:76fd9a263045 | 294 | // |
mbed_official | 256:76fd9a263045 | 295 | // You can prevent this code block being included if you require |
mbed_official | 256:76fd9a263045 | 296 | // (for example when creating a final executable which you will |
mbed_official | 256:76fd9a263045 | 297 | // not debug) by setting the define 'DONT_RESET_ON_RESTART'. |
mbed_official | 256:76fd9a263045 | 298 | // |
mbed_official | 256:76fd9a263045 | 299 | #ifndef DONT_RESET_ON_RESTART |
mbed_official | 256:76fd9a263045 | 300 | |
mbed_official | 256:76fd9a263045 | 301 | // Disable interrupts |
mbed_official | 256:76fd9a263045 | 302 | __asm volatile ("cpsid i"); |
mbed_official | 256:76fd9a263045 | 303 | // equivalent to CMSIS '__disable_irq()' function |
mbed_official | 256:76fd9a263045 | 304 | |
mbed_official | 256:76fd9a263045 | 305 | unsigned int *RESET_CONTROL = (unsigned int *) 0x40053100; |
mbed_official | 256:76fd9a263045 | 306 | // LPC_RGU->RESET_CTRL0 @ 0x40053100 |
mbed_official | 256:76fd9a263045 | 307 | // LPC_RGU->RESET_CTRL1 @ 0x40053104 |
mbed_official | 256:76fd9a263045 | 308 | // Note that we do not use the CMSIS register access mechanism, |
mbed_official | 256:76fd9a263045 | 309 | // as there is no guarantee that the project has been configured |
mbed_official | 256:76fd9a263045 | 310 | // to use CMSIS. |
mbed_official | 256:76fd9a263045 | 311 | |
mbed_official | 256:76fd9a263045 | 312 | // Write to LPC_RGU->RESET_CTRL0 |
mbed_official | 256:76fd9a263045 | 313 | *(RESET_CONTROL+0) = 0x10DF0000; |
mbed_official | 256:76fd9a263045 | 314 | // GPIO_RST|AES_RST|ETHERNET_RST|SDIO_RST|DMA_RST| |
mbed_official | 256:76fd9a263045 | 315 | // USB1_RST|USB0_RST|LCD_RST |
mbed_official | 256:76fd9a263045 | 316 | |
mbed_official | 256:76fd9a263045 | 317 | // Write to LPC_RGU->RESET_CTRL1 |
mbed_official | 256:76fd9a263045 | 318 | *(RESET_CONTROL+1) = 0x01DFF7FF; |
mbed_official | 256:76fd9a263045 | 319 | // M0APP_RST|CAN0_RST|CAN1_RST|I2S_RST|SSP1_RST|SSP0_RST| |
mbed_official | 256:76fd9a263045 | 320 | // I2C1_RST|I2C0_RST|UART3_RST|UART1_RST|UART1_RST|UART0_RST| |
mbed_official | 256:76fd9a263045 | 321 | // DAC_RST|ADC1_RST|ADC0_RST|QEI_RST|MOTOCONPWM_RST|SCT_RST| |
mbed_official | 256:76fd9a263045 | 322 | // RITIMER_RST|TIMER3_RST|TIMER2_RST|TIMER1_RST|TIMER0_RST |
mbed_official | 256:76fd9a263045 | 323 | |
mbed_official | 256:76fd9a263045 | 324 | // Clear all pending interrupts in the NVIC |
mbed_official | 256:76fd9a263045 | 325 | volatile unsigned int *NVIC_ICPR = (unsigned int *) 0xE000E280; |
mbed_official | 256:76fd9a263045 | 326 | unsigned int irqpendloop; |
mbed_official | 256:76fd9a263045 | 327 | for (irqpendloop = 0; irqpendloop < 8; irqpendloop++) { |
mbed_official | 256:76fd9a263045 | 328 | *(NVIC_ICPR+irqpendloop)= 0xFFFFFFFF; |
mbed_official | 256:76fd9a263045 | 329 | } |
mbed_official | 256:76fd9a263045 | 330 | |
mbed_official | 256:76fd9a263045 | 331 | // Reenable interrupts |
mbed_official | 256:76fd9a263045 | 332 | __asm volatile ("cpsie i"); |
mbed_official | 256:76fd9a263045 | 333 | // equivalent to CMSIS '__enable_irq()' function |
mbed_official | 256:76fd9a263045 | 334 | |
mbed_official | 256:76fd9a263045 | 335 | #endif // ifndef DONT_RESET_ON_RESTART |
mbed_official | 256:76fd9a263045 | 336 | // ************************************************************* |
mbed_official | 256:76fd9a263045 | 337 | |
mbed_official | 256:76fd9a263045 | 338 | |
mbed_official | 256:76fd9a263045 | 339 | // |
mbed_official | 256:76fd9a263045 | 340 | // Copy the data sections from flash to SRAM. |
mbed_official | 256:76fd9a263045 | 341 | // |
bogdanm | 20:4263a77256ae | 342 | unsigned int LoadAddr, ExeAddr, SectionLen; |
bogdanm | 20:4263a77256ae | 343 | unsigned int *SectionTableAddr; |
bogdanm | 20:4263a77256ae | 344 | |
bogdanm | 20:4263a77256ae | 345 | // Load base address of Global Section Table |
bogdanm | 20:4263a77256ae | 346 | SectionTableAddr = &__data_section_table; |
bogdanm | 20:4263a77256ae | 347 | |
mbed_official | 256:76fd9a263045 | 348 | // Copy the data sections from flash to SRAM. |
bogdanm | 20:4263a77256ae | 349 | while (SectionTableAddr < &__data_section_table_end) { |
bogdanm | 20:4263a77256ae | 350 | LoadAddr = *SectionTableAddr++; |
bogdanm | 20:4263a77256ae | 351 | ExeAddr = *SectionTableAddr++; |
bogdanm | 20:4263a77256ae | 352 | SectionLen = *SectionTableAddr++; |
bogdanm | 20:4263a77256ae | 353 | data_init(LoadAddr, ExeAddr, SectionLen); |
bogdanm | 20:4263a77256ae | 354 | } |
bogdanm | 20:4263a77256ae | 355 | // At this point, SectionTableAddr = &__bss_section_table; |
bogdanm | 20:4263a77256ae | 356 | // Zero fill the bss segment |
bogdanm | 20:4263a77256ae | 357 | while (SectionTableAddr < &__bss_section_table_end) { |
bogdanm | 20:4263a77256ae | 358 | ExeAddr = *SectionTableAddr++; |
bogdanm | 20:4263a77256ae | 359 | SectionLen = *SectionTableAddr++; |
bogdanm | 20:4263a77256ae | 360 | bss_init(ExeAddr, SectionLen); |
bogdanm | 20:4263a77256ae | 361 | } |
bogdanm | 20:4263a77256ae | 362 | |
mbed_official | 256:76fd9a263045 | 363 | #if defined (__VFP_FP__) && !defined (__SOFTFP__) |
mbed_official | 256:76fd9a263045 | 364 | /* |
mbed_official | 256:76fd9a263045 | 365 | * Code to enable the Cortex-M4 FPU only included |
mbed_official | 256:76fd9a263045 | 366 | * if appropriate build options have been selected. |
mbed_official | 256:76fd9a263045 | 367 | * Code taken from Section 7.1, Cortex-M4 TRM (DDI0439C) |
mbed_official | 256:76fd9a263045 | 368 | */ |
mbed_official | 256:76fd9a263045 | 369 | // CPACR is located at address 0xE000ED88 |
mbed_official | 256:76fd9a263045 | 370 | asm("LDR.W R0, =0xE000ED88"); |
mbed_official | 256:76fd9a263045 | 371 | // Read CPACR |
mbed_official | 256:76fd9a263045 | 372 | asm("LDR R1, [R0]"); |
mbed_official | 256:76fd9a263045 | 373 | // Set bits 20-23 to enable CP10 and CP11 coprocessors |
mbed_official | 256:76fd9a263045 | 374 | asm(" ORR R1, R1, #(0xF << 20)"); |
mbed_official | 256:76fd9a263045 | 375 | // Write back the modified value to the CPACR |
mbed_official | 256:76fd9a263045 | 376 | asm("STR R1, [R0]"); |
mbed_official | 256:76fd9a263045 | 377 | #endif // (__VFP_FP__) && !(__SOFTFP__) |
mbed_official | 256:76fd9a263045 | 378 | |
mbed_official | 256:76fd9a263045 | 379 | // ****************************** |
mbed_official | 256:76fd9a263045 | 380 | // Check to see if we are running the code from a non-zero |
mbed_official | 256:76fd9a263045 | 381 | // address (eg RAM, external flash), in which case we need |
mbed_official | 256:76fd9a263045 | 382 | // to modify the VTOR register to tell the CPU that the |
mbed_official | 256:76fd9a263045 | 383 | // vector table is located at a non-0x0 address. |
bogdanm | 20:4263a77256ae | 384 | |
mbed_official | 256:76fd9a263045 | 385 | // Note that we do not use the CMSIS register access mechanism, |
mbed_official | 256:76fd9a263045 | 386 | // as there is no guarantee that the project has been configured |
mbed_official | 256:76fd9a263045 | 387 | // to use CMSIS. |
mbed_official | 256:76fd9a263045 | 388 | unsigned int * pSCB_VTOR = (unsigned int *) 0xE000ED08; |
mbed_official | 256:76fd9a263045 | 389 | if ((unsigned int *)g_pfnVectors!=(unsigned int *) 0x00000000) { |
mbed_official | 256:76fd9a263045 | 390 | // CMSIS : SCB->VTOR = <address of vector table> |
mbed_official | 256:76fd9a263045 | 391 | *pSCB_VTOR = (unsigned int)g_pfnVectors; |
mbed_official | 256:76fd9a263045 | 392 | } |
mbed_official | 256:76fd9a263045 | 393 | |
mbed_official | 256:76fd9a263045 | 394 | #ifdef __USE_CMSIS |
mbed_official | 256:76fd9a263045 | 395 | SystemInit(); |
mbed_official | 256:76fd9a263045 | 396 | #endif |
mbed_official | 256:76fd9a263045 | 397 | |
mbed_official | 256:76fd9a263045 | 398 | #if defined (__cplusplus) |
mbed_official | 256:76fd9a263045 | 399 | // |
mbed_official | 256:76fd9a263045 | 400 | // Call C++ library initialisation |
bogdanm | 20:4263a77256ae | 401 | // |
mbed_official | 256:76fd9a263045 | 402 | __libc_init_array(); |
mbed_official | 256:76fd9a263045 | 403 | #endif |
mbed_official | 256:76fd9a263045 | 404 | |
mbed_official | 256:76fd9a263045 | 405 | #if defined (__REDLIB__) |
mbed_official | 256:76fd9a263045 | 406 | // Call the Redlib library, which in turn calls main() |
mbed_official | 256:76fd9a263045 | 407 | __main() ; |
mbed_official | 256:76fd9a263045 | 408 | #else |
mbed_official | 256:76fd9a263045 | 409 | main(); |
mbed_official | 256:76fd9a263045 | 410 | #endif |
mbed_official | 256:76fd9a263045 | 411 | |
bogdanm | 20:4263a77256ae | 412 | // |
mbed_official | 256:76fd9a263045 | 413 | // main() shouldn't return, but if it does, we'll just enter an infinite loop |
mbed_official | 256:76fd9a263045 | 414 | // |
mbed_official | 256:76fd9a263045 | 415 | while (1) { |
mbed_official | 256:76fd9a263045 | 416 | ; |
mbed_official | 256:76fd9a263045 | 417 | } |
bogdanm | 20:4263a77256ae | 418 | } |
bogdanm | 20:4263a77256ae | 419 | |
mbed_official | 256:76fd9a263045 | 420 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 421 | // Default exception handlers. Override the ones here by defining your own |
bogdanm | 20:4263a77256ae | 422 | // handler routines in your application code. |
mbed_official | 256:76fd9a263045 | 423 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 424 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 425 | void NMI_Handler(void) |
bogdanm | 20:4263a77256ae | 426 | { |
mbed_official | 256:76fd9a263045 | 427 | while(1) |
mbed_official | 256:76fd9a263045 | 428 | { |
mbed_official | 256:76fd9a263045 | 429 | } |
bogdanm | 20:4263a77256ae | 430 | } |
bogdanm | 20:4263a77256ae | 431 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 432 | void HardFault_Handler(void) |
bogdanm | 20:4263a77256ae | 433 | { |
mbed_official | 256:76fd9a263045 | 434 | while(1) |
mbed_official | 256:76fd9a263045 | 435 | { |
mbed_official | 256:76fd9a263045 | 436 | } |
bogdanm | 20:4263a77256ae | 437 | } |
bogdanm | 20:4263a77256ae | 438 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 439 | void MemManage_Handler(void) |
bogdanm | 20:4263a77256ae | 440 | { |
mbed_official | 256:76fd9a263045 | 441 | while(1) |
mbed_official | 256:76fd9a263045 | 442 | { |
mbed_official | 256:76fd9a263045 | 443 | } |
bogdanm | 20:4263a77256ae | 444 | } |
bogdanm | 20:4263a77256ae | 445 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 446 | void BusFault_Handler(void) |
bogdanm | 20:4263a77256ae | 447 | { |
mbed_official | 256:76fd9a263045 | 448 | while(1) |
mbed_official | 256:76fd9a263045 | 449 | { |
mbed_official | 256:76fd9a263045 | 450 | } |
bogdanm | 20:4263a77256ae | 451 | } |
bogdanm | 20:4263a77256ae | 452 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 453 | void UsageFault_Handler(void) |
bogdanm | 20:4263a77256ae | 454 | { |
mbed_official | 256:76fd9a263045 | 455 | while(1) |
mbed_official | 256:76fd9a263045 | 456 | { |
mbed_official | 256:76fd9a263045 | 457 | } |
bogdanm | 20:4263a77256ae | 458 | } |
bogdanm | 20:4263a77256ae | 459 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 460 | void SVC_Handler(void) |
bogdanm | 20:4263a77256ae | 461 | { |
mbed_official | 256:76fd9a263045 | 462 | while(1) |
mbed_official | 256:76fd9a263045 | 463 | { |
mbed_official | 256:76fd9a263045 | 464 | } |
bogdanm | 20:4263a77256ae | 465 | } |
bogdanm | 20:4263a77256ae | 466 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 467 | void DebugMon_Handler(void) |
bogdanm | 20:4263a77256ae | 468 | { |
mbed_official | 256:76fd9a263045 | 469 | while(1) |
mbed_official | 256:76fd9a263045 | 470 | { |
mbed_official | 256:76fd9a263045 | 471 | } |
bogdanm | 20:4263a77256ae | 472 | } |
bogdanm | 20:4263a77256ae | 473 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 474 | void PendSV_Handler(void) |
bogdanm | 20:4263a77256ae | 475 | { |
mbed_official | 256:76fd9a263045 | 476 | while(1) |
mbed_official | 256:76fd9a263045 | 477 | { |
mbed_official | 256:76fd9a263045 | 478 | } |
bogdanm | 20:4263a77256ae | 479 | } |
bogdanm | 20:4263a77256ae | 480 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 481 | void SysTick_Handler(void) |
bogdanm | 20:4263a77256ae | 482 | { |
mbed_official | 256:76fd9a263045 | 483 | while(1) |
mbed_official | 256:76fd9a263045 | 484 | { |
mbed_official | 256:76fd9a263045 | 485 | } |
bogdanm | 20:4263a77256ae | 486 | } |
bogdanm | 20:4263a77256ae | 487 | |
mbed_official | 256:76fd9a263045 | 488 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 489 | // |
bogdanm | 20:4263a77256ae | 490 | // Processor ends up here if an unexpected interrupt occurs or a specific |
bogdanm | 20:4263a77256ae | 491 | // handler is not present in the application code. |
bogdanm | 20:4263a77256ae | 492 | // |
mbed_official | 256:76fd9a263045 | 493 | //***************************************************************************** |
bogdanm | 20:4263a77256ae | 494 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 495 | void IntDefaultHandler(void) |
bogdanm | 20:4263a77256ae | 496 | { |
mbed_official | 256:76fd9a263045 | 497 | while(1) |
mbed_official | 256:76fd9a263045 | 498 | { |
mbed_official | 256:76fd9a263045 | 499 | } |
bogdanm | 20:4263a77256ae | 500 | } |