Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of target-mcu-k64f by
cmsis_nvic.c
00001 /* mbed Microcontroller Library 00002 * CMSIS-style functionality to support dynamic vectors 00003 ******************************************************************************* 00004 * Copyright (c) 2011 ARM Limited. All rights reserved. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions are met: 00009 * 00010 * 1. Redistributions of source code must retain the above copyright notice, 00011 * this list of conditions and the following disclaimer. 00012 * 2. Redistributions in binary form must reproduce the above copyright notice, 00013 * this list of conditions and the following disclaimer in the documentation 00014 * and/or other materials provided with the distribution. 00015 * 3. Neither the name of ARM Limited nor the names of its contributors 00016 * may be used to endorse or promote products derived from this software 00017 * without specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00021 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00022 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00023 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00024 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00025 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00026 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00027 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00028 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 ******************************************************************************* 00030 */ 00031 #include "cmsis_nvic.h" 00032 00033 #define NVIC_RAM_VECTOR_ADDRESS (0x1FFF0000) // Vectors positioned at start of RAM 00034 #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash 00035 00036 void NVIC_SetVector(IRQn_Type IRQn , uint32_t vector) { 00037 uint32_t *vectors = (uint32_t*)SCB->VTOR; 00038 uint32_t i; 00039 00040 // Copy and switch to dynamic vectors if the first time called 00041 if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) { 00042 uint32_t *old_vectors = vectors; 00043 vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS; 00044 for (i=0; i<NVIC_NUM_VECTORS; i++) { 00045 vectors[i] = old_vectors[i]; 00046 } 00047 SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS; 00048 } 00049 vectors[IRQn + 16] = vector; 00050 } 00051 00052 uint32_t NVIC_GetVector(IRQn_Type IRQn) { 00053 uint32_t *vectors = (uint32_t*)SCB->VTOR; 00054 return vectors[IRQn + 16]; 00055 }
Generated on Sat Aug 27 2022 17:08:59 by
