Commit | Line | Data |
---|---|---|
172d42d9 AG |
1 | /* mbed Microcontroller Library - cmsis_nvic for LCP1768 |
2 | * Copyright (c) 2009-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_NUM_VECTORS (16 + 33) // CORE + MCU Peripherals | |
9 | #define NVIC_RAM_VECTOR_ADDRESS (0x10000000) // Location of vectors in RAM | |
10 | ||
11 | void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) { | |
12 | static volatile uint32_t* vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS; | |
13 | int i; | |
14 | // Copy and switch to dynamic vectors if first time called | |
15 | if (SCB->VTOR != NVIC_RAM_VECTOR_ADDRESS) { | |
16 | uint32_t *old_vectors = (uint32_t*)SCB->VTOR; | |
17 | for (i=0; i<NVIC_NUM_VECTORS; i++) { | |
18 | vectors[i] = old_vectors[i]; | |
19 | } | |
20 | SCB->VTOR = (uint32_t)vectors; | |
21 | } | |
22 | ||
23 | vectors[IRQn + 16] = vector; | |
24 | } | |
25 | ||
26 | uint32_t NVIC_GetVector(IRQn_Type IRQn) { | |
27 | uint32_t *vectors = (uint32_t*)SCB->VTOR; | |
28 | return vectors[IRQn + 16]; | |
29 | } | |
30 |