Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-src by
targets/cmsis/TARGET_NXP/TARGET_LPC176X/cmsis_nvic.c@183:46ae3190e86c, 2014-05-07 (annotated)
- Committer:
- mbed_official
- Date:
- Wed May 07 17:45:07 2014 +0100
- Revision:
- 183:46ae3190e86c
- Parent:
- 15:4892fe388435
- Child:
- 358:9d7ef901f004
Synchronized with git revision 152b58673f64d18174038282d90ca97e67d44ae2
Full URL: https://github.com/mbedmicro/mbed/commit/152b58673f64d18174038282d90ca97e67d44ae2/
Ensure the NVIC table gets copied to RAM even when it is not at 0x0000
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 13:0645d8841f51 | 1 | /* mbed Microcontroller Library - cmsis_nvic for LCP1768 |
bogdanm | 13:0645d8841f51 | 2 | * Copyright (c) 2009-2011 ARM Limited. All rights reserved. |
bogdanm | 13:0645d8841f51 | 3 | * |
bogdanm | 13:0645d8841f51 | 4 | * CMSIS-style functionality to support dynamic vectors |
bogdanm | 13:0645d8841f51 | 5 | */ |
bogdanm | 13:0645d8841f51 | 6 | #include "cmsis_nvic.h" |
bogdanm | 13:0645d8841f51 | 7 | |
bogdanm | 13:0645d8841f51 | 8 | #define NVIC_RAM_VECTOR_ADDRESS (0x10000000) // Location of vectors in RAM |
bogdanm | 13:0645d8841f51 | 9 | #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash |
bogdanm | 13:0645d8841f51 | 10 | |
bogdanm | 13:0645d8841f51 | 11 | void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) { |
bogdanm | 13:0645d8841f51 | 12 | uint32_t *vectors = (uint32_t*)SCB->VTOR; |
bogdanm | 13:0645d8841f51 | 13 | uint32_t i; |
bogdanm | 13:0645d8841f51 | 14 | |
bogdanm | 13:0645d8841f51 | 15 | // Copy and switch to dynamic vectors if the first time called |
mbed_official | 183:46ae3190e86c | 16 | if (SCB->VTOR < NVIC_RAM_VECTOR_ADDRESS) { |
bogdanm | 13:0645d8841f51 | 17 | uint32_t *old_vectors = vectors; |
bogdanm | 13:0645d8841f51 | 18 | vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS; |
bogdanm | 13:0645d8841f51 | 19 | for (i=0; i<NVIC_NUM_VECTORS; i++) { |
bogdanm | 13:0645d8841f51 | 20 | vectors[i] = old_vectors[i]; |
bogdanm | 13:0645d8841f51 | 21 | } |
bogdanm | 13:0645d8841f51 | 22 | SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS; |
bogdanm | 13:0645d8841f51 | 23 | } |
bogdanm | 15:4892fe388435 | 24 | vectors[IRQn + NVIC_USER_IRQ_OFFSET] = vector; |
bogdanm | 13:0645d8841f51 | 25 | } |
bogdanm | 13:0645d8841f51 | 26 | |
bogdanm | 13:0645d8841f51 | 27 | uint32_t NVIC_GetVector(IRQn_Type IRQn) { |
bogdanm | 13:0645d8841f51 | 28 | uint32_t *vectors = (uint32_t*)SCB->VTOR; |
bogdanm | 15:4892fe388435 | 29 | return vectors[IRQn + NVIC_USER_IRQ_OFFSET]; |
bogdanm | 13:0645d8841f51 | 30 | } |
bogdanm | 13:0645d8841f51 | 31 |