mbed library sources that still uses the stm standard peripheral library

Fork of mbed-src by Reinhold Schaefer

Committer:
mbed_official
Date:
Wed Apr 02 21:00:08 2014 +0100
Revision:
146:f64d43ff0c18
Synchronized with git revision d537c51d26da35e031d537f7fc90380fc74cb207

Full URL: https://github.com/mbedmicro/mbed/commit/d537c51d26da35e031d537f7fc90380fc74cb207/

target K64F

Who changed what in which revision?

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