raspiezo / mbed-dev

Dependents:   Nucleo_L432KC_Quadrature_Decoder_with_ADC_and_DAC

Fork of mbed-dev by mbed official

Committer:
Kojto
Date:
Tue Feb 14 14:44:10 2017 +0000
Revision:
158:b23ee177fd68
Parent:
targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F412ZG/device/cmsis_nvic.c@153:fa9ff456f731
This updates the lib to the mbed lib v136

Who changed what in which revision?

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