anyThing Connected Team / mbed-dev

Dependents:   BREAK_SENSOR_LED

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Tue Nov 08 17:45:16 2016 +0000
Revision:
150:02e0a0aed4ec
This updates the lib to the mbed lib v129

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 150:02e0a0aed4ec 1 /* mbed Microcontroller Library
<> 150:02e0a0aed4ec 2 * CMSIS-style functionality to support dynamic vectors
<> 150:02e0a0aed4ec 3 *******************************************************************************
<> 150:02e0a0aed4ec 4 * Copyright (c) 2011 ARM Limited. All rights reserved.
<> 150:02e0a0aed4ec 5 * All rights reserved.
<> 150:02e0a0aed4ec 6 *
<> 150:02e0a0aed4ec 7 * Redistribution and use in source and binary forms, with or without
<> 150:02e0a0aed4ec 8 * modification, are permitted provided that the following conditions are met:
<> 150:02e0a0aed4ec 9 *
<> 150:02e0a0aed4ec 10 * 1. Redistributions of source code must retain the above copyright notice,
<> 150:02e0a0aed4ec 11 * this list of conditions and the following disclaimer.
<> 150:02e0a0aed4ec 12 * 2. Redistributions in binary form must reproduce the above copyright notice,
<> 150:02e0a0aed4ec 13 * this list of conditions and the following disclaimer in the documentation
<> 150:02e0a0aed4ec 14 * and/or other materials provided with the distribution.
<> 150:02e0a0aed4ec 15 * 3. Neither the name of ARM Limited nor the names of its contributors
<> 150:02e0a0aed4ec 16 * may be used to endorse or promote products derived from this software
<> 150:02e0a0aed4ec 17 * without specific prior written permission.
<> 150:02e0a0aed4ec 18 *
<> 150:02e0a0aed4ec 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
<> 150:02e0a0aed4ec 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
<> 150:02e0a0aed4ec 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
<> 150:02e0a0aed4ec 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
<> 150:02e0a0aed4ec 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
<> 150:02e0a0aed4ec 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
<> 150:02e0a0aed4ec 25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
<> 150:02e0a0aed4ec 26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
<> 150:02e0a0aed4ec 27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
<> 150:02e0a0aed4ec 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<> 150:02e0a0aed4ec 29 *******************************************************************************
<> 150:02e0a0aed4ec 30 */
<> 150:02e0a0aed4ec 31 #include "cmsis_nvic.h"
<> 150:02e0a0aed4ec 32
<> 150:02e0a0aed4ec 33 #define NVIC_RAM_VECTOR_ADDRESS (0x01000000) // Location of vectors in RAM
<> 150:02e0a0aed4ec 34 #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
<> 150:02e0a0aed4ec 35
<> 150:02e0a0aed4ec 36 void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
<> 150:02e0a0aed4ec 37 // Space for dynamic vectors, initialised to allocate in R/W
<> 150:02e0a0aed4ec 38 static volatile uint32_t* vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
<> 150:02e0a0aed4ec 39
<> 150:02e0a0aed4ec 40 // Set the vector
<> 150:02e0a0aed4ec 41 vectors[IRQn + 16] = vector;
<> 150:02e0a0aed4ec 42 }
<> 150:02e0a0aed4ec 43
<> 150:02e0a0aed4ec 44 uint32_t NVIC_GetVector(IRQn_Type IRQn) {
<> 150:02e0a0aed4ec 45 // We can always read vectors at 0x0, as the addresses are remapped
<> 150:02e0a0aed4ec 46 uint32_t *vectors = (uint32_t*)0;
<> 150:02e0a0aed4ec 47
<> 150:02e0a0aed4ec 48 // Return the vector
<> 150:02e0a0aed4ec 49 return vectors[IRQn + 16];
<> 150:02e0a0aed4ec 50 }