mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_NXP/TARGET_LPC408X/cmsis_nvic.c@308:59cc78a25982, 2014-09-05 (annotated)
- Committer:
- todotani
- Date:
- Fri Sep 05 14:20:33 2014 +0000
- Revision:
- 308:59cc78a25982
- Parent:
- 15:4892fe388435
BLE_Health_Thermometer for mbed HRM1017 with BLE library 0.1.0
Who changed what in which revision?
User | Revision | Line number | New 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 |