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.
Dependents: mbed_blinky-bmd-200 bmd-200_accel_demo firstRig
Fork of mbed-src by
targets/cmsis/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32LG_STK3600/cmsis_nvic.c@592:5e2eb8beba71, 2015-07-10 (annotated)
- Committer:
- dcnichols
- Date:
- Fri Jul 10 17:36:27 2015 +0000
- Revision:
- 592:5e2eb8beba71
- Parent:
- 529:c320967f86b9
updating to latest mbed-src
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 529:c320967f86b9 | 1 | /* mbed Microcontroller Library - cmsis_nvic for EFM32 |
mbed_official | 529:c320967f86b9 | 2 | * Copyright (c) 2011 ARM Limited. All rights reserved. |
mbed_official | 529:c320967f86b9 | 3 | * |
mbed_official | 529:c320967f86b9 | 4 | * CMSIS-style functionality to support dynamic vectors |
mbed_official | 529:c320967f86b9 | 5 | */ |
mbed_official | 529:c320967f86b9 | 6 | #include "cmsis_nvic.h" |
mbed_official | 529:c320967f86b9 | 7 | |
mbed_official | 529:c320967f86b9 | 8 | #if (defined (__GNUC__) && (!defined(__CC_ARM))) |
mbed_official | 529:c320967f86b9 | 9 | extern uint32_t __start_vector_table__; // Dynamic vector positioning in GCC |
mbed_official | 529:c320967f86b9 | 10 | #endif |
mbed_official | 529:c320967f86b9 | 11 | |
mbed_official | 529:c320967f86b9 | 12 | #define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Vectors positioned at start of RAM |
mbed_official | 529:c320967f86b9 | 13 | #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash |
mbed_official | 529:c320967f86b9 | 14 | |
mbed_official | 529:c320967f86b9 | 15 | void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) { |
mbed_official | 529:c320967f86b9 | 16 | uint32_t *vectors = (uint32_t*)SCB->VTOR; |
mbed_official | 529:c320967f86b9 | 17 | uint32_t i; |
mbed_official | 529:c320967f86b9 | 18 | |
mbed_official | 529:c320967f86b9 | 19 | // Copy and switch to dynamic vectors if the first time called |
mbed_official | 529:c320967f86b9 | 20 | // For GCC, use dynamic vector table placement since otherwise we run into an alignment conflict |
mbed_official | 529:c320967f86b9 | 21 | #if (defined (__GNUC__) && (!defined(__CC_ARM))) |
mbed_official | 529:c320967f86b9 | 22 | if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) { |
mbed_official | 529:c320967f86b9 | 23 | uint32_t *old_vectors = vectors; |
mbed_official | 529:c320967f86b9 | 24 | vectors = (uint32_t*)(&__start_vector_table__); |
mbed_official | 529:c320967f86b9 | 25 | for (i=0; i<NVIC_NUM_VECTORS; i++) { |
mbed_official | 529:c320967f86b9 | 26 | vectors[i] = old_vectors[i]; |
mbed_official | 529:c320967f86b9 | 27 | } |
mbed_official | 529:c320967f86b9 | 28 | SCB->VTOR = (uint32_t)(&__start_vector_table__); |
mbed_official | 529:c320967f86b9 | 29 | } |
mbed_official | 529:c320967f86b9 | 30 | // Other compilers don't matter as much... |
mbed_official | 529:c320967f86b9 | 31 | #else |
mbed_official | 529:c320967f86b9 | 32 | if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) { |
mbed_official | 529:c320967f86b9 | 33 | uint32_t *old_vectors = vectors; |
mbed_official | 529:c320967f86b9 | 34 | vectors = (uint32_t*)(NVIC_RAM_VECTOR_ADDRESS); |
mbed_official | 529:c320967f86b9 | 35 | for (i=0; i<NVIC_NUM_VECTORS; i++) { |
mbed_official | 529:c320967f86b9 | 36 | vectors[i] = old_vectors[i]; |
mbed_official | 529:c320967f86b9 | 37 | } |
mbed_official | 529:c320967f86b9 | 38 | SCB->VTOR = (uint32_t)(NVIC_RAM_VECTOR_ADDRESS); |
mbed_official | 529:c320967f86b9 | 39 | } |
mbed_official | 529:c320967f86b9 | 40 | #endif |
mbed_official | 529:c320967f86b9 | 41 | vectors[IRQn + 16] = vector; |
mbed_official | 529:c320967f86b9 | 42 | } |
mbed_official | 529:c320967f86b9 | 43 | |
mbed_official | 529:c320967f86b9 | 44 | uint32_t NVIC_GetVector(IRQn_Type IRQn) { |
mbed_official | 529:c320967f86b9 | 45 | uint32_t *vectors = (uint32_t*)SCB->VTOR; |
mbed_official | 529:c320967f86b9 | 46 | return vectors[IRQn + 16]; |
mbed_official | 529:c320967f86b9 | 47 | } |