]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_KLXX/TARGET_KL43Z/cmsis_nvic.c
remove experimental return, cleanup slash_question key
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_Freescale / TARGET_KLXX / TARGET_KL43Z / cmsis_nvic.c
1 /* mbed Microcontroller Library - cmsis_nvic for LPC11U24
2 * Copyright (c) 2011 ARM Limited. All rights reserved.
3 *
4 * CMSIS-style functionality to support dynamic vectors
5 */
6 #include "cmsis_nvic.h"
7
8 #define NVIC_RAM_VECTOR_ADDRESS (0x1FFFE000) // Vectors positioned at start of RAM
9 #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
10
11 void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
12 uint32_t *vectors = (uint32_t*)SCB->VTOR;
13 uint32_t i;
14
15 // Copy and switch to dynamic vectors if the first time called
16 if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
17 uint32_t *old_vectors = vectors;
18 vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
19 for (i=0; i<NVIC_NUM_VECTORS; i++) {
20 vectors[i] = old_vectors[i];
21 }
22 SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
23 }
24 vectors[IRQn + 16] = vector;
25 }
26
27 uint32_t NVIC_GetVector(IRQn_Type IRQn) {
28 uint32_t *vectors = (uint32_t*)SCB->VTOR;
29 return vectors[IRQn + 16];
30 }
Imprint / Impressum