mbed library sources

Fork of mbed-src by mbed official

Committer:
bogdanm
Date:
Wed Aug 07 16:43:59 2013 +0300
Revision:
15:4892fe388435
Child:
358:9d7ef901f004
Added LPC4088 target and interrupt chaining code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 15:4892fe388435 1 /* mbed Microcontroller Library - cmsis_nvic for LCP407x_8x
bogdanm 15:4892fe388435 2 * Copyright (c) 2009-2011 ARM Limited. All rights reserved.
bogdanm 15:4892fe388435 3 *
bogdanm 15:4892fe388435 4 * CMSIS-style functionality to support dynamic vectors
bogdanm 15:4892fe388435 5 */
bogdanm 15:4892fe388435 6 #include "cmsis_nvic.h"
bogdanm 15:4892fe388435 7
bogdanm 15:4892fe388435 8 #define NVIC_RAM_VECTOR_ADDRESS (0x10000000) // Location of vectors in RAM
bogdanm 15:4892fe388435 9 #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
bogdanm 15:4892fe388435 10
bogdanm 15:4892fe388435 11 void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
bogdanm 15:4892fe388435 12 uint32_t *vectors = (uint32_t*)SCB->VTOR;
bogdanm 15:4892fe388435 13 uint32_t i;
bogdanm 15:4892fe388435 14
bogdanm 15:4892fe388435 15 // Copy and switch to dynamic vectors if the first time called
bogdanm 15:4892fe388435 16 if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
bogdanm 15:4892fe388435 17 uint32_t *old_vectors = vectors;
bogdanm 15:4892fe388435 18 vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
bogdanm 15:4892fe388435 19 for (i=0; i<NVIC_NUM_VECTORS; i++) {
bogdanm 15:4892fe388435 20 vectors[i] = old_vectors[i];
bogdanm 15:4892fe388435 21 }
bogdanm 15:4892fe388435 22 SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
bogdanm 15:4892fe388435 23 }
bogdanm 15:4892fe388435 24 vectors[IRQn + 16] = vector;
bogdanm 15:4892fe388435 25 }
bogdanm 15:4892fe388435 26
bogdanm 15:4892fe388435 27 uint32_t NVIC_GetVector(IRQn_Type IRQn) {
bogdanm 15:4892fe388435 28 uint32_t *vectors = (uint32_t*)SCB->VTOR;
bogdanm 15:4892fe388435 29 return vectors[IRQn + 16];
bogdanm 15:4892fe388435 30 }
bogdanm 15:4892fe388435 31