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