1 /****************************************************************************
5 * Copyright 2015 Nathael Pajani <nathael.pajani@ed3l.fr>
7 * This file is derived from Work covered by the Apache 2.0 licence.
8 * http://www.apache.org/licenses/LICENSE-2.0
9 * Original sources should be found there :
10 * https://github.com/mbedmicro/CMSIS-DAP.git
11 * Original file name is bootloader/hal/TARGET_NXP/TARGET_LPC11U35/vector_table.c
13 * Original copyright notice :
14 * CMSIS-DAP Interface Firmware
15 * Copyright (c) 2009-2013 ARM Limited
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 *****************************************************************************/
33 #include "core/lpc_regs_11u3x.h"
36 #define NVIC_NUM_VECTORS (16 + 32) /* CORE + MCU Peripherals */
37 #define NVIC_RAM_VECTOR_ADDRESS (0x10000000) /* Vectors positioned at start of RAM */
39 void relocate_vector_table(void)
41 struct lpc_sys_control* sysctrl = LPC_SYS_CONTROL;
43 /* Space for dynamic vectors, initialised to allocate in R/W */
44 static volatile uint32_t * vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
46 /* Copy and switch to dynamic vectors if first time called */
47 if((sysctrl->sys_mem_remap & 0x3) != 0x1) {
48 uint32_t *old_vectors = (uint32_t *)START_APP_ADDRESS;
49 for(i = 0; i < NVIC_NUM_VECTORS; i++) {
50 vectors[i] = old_vectors[i];
52 sysctrl->sys_mem_remap = 0x1;