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
vendor/NXP/LPC1768/cmsis/cmsis_nvic.c@12:5fa2273de5db, 2013-07-24 (annotated)
- Committer:
- emimon01
- Date:
- Wed Jul 24 11:11:21 2013 +0100
- Revision:
- 12:5fa2273de5db
- Parent:
- 10:3bc89ef62ce7
Remove sources for toolchains unknown by the online compiler
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| emilmont | 10:3bc89ef62ce7 | 1 | /* mbed Microcontroller Library - cmsis_nvic for LCP1768 |
| emilmont | 10:3bc89ef62ce7 | 2 | * Copyright (c) 2009-2011 ARM Limited. All rights reserved. |
| emilmont | 10:3bc89ef62ce7 | 3 | * |
| emilmont | 10:3bc89ef62ce7 | 4 | * CMSIS-style functionality to support dynamic vectors |
| emilmont | 10:3bc89ef62ce7 | 5 | */ |
| emilmont | 10:3bc89ef62ce7 | 6 | #include "cmsis_nvic.h" |
| emilmont | 10:3bc89ef62ce7 | 7 | |
| emilmont | 10:3bc89ef62ce7 | 8 | #define NVIC_NUM_VECTORS (16 + 33) // CORE + MCU Peripherals |
| emilmont | 10:3bc89ef62ce7 | 9 | #define NVIC_RAM_VECTOR_ADDRESS (0x10000000) // Location of vectors in RAM |
| emilmont | 10:3bc89ef62ce7 | 10 | |
| emilmont | 10:3bc89ef62ce7 | 11 | void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) { |
| emilmont | 10:3bc89ef62ce7 | 12 | static volatile uint32_t* vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS; |
| emilmont | 10:3bc89ef62ce7 | 13 | int i; |
| emilmont | 10:3bc89ef62ce7 | 14 | // Copy and switch to dynamic vectors if first time called |
| emilmont | 10:3bc89ef62ce7 | 15 | if (SCB->VTOR != NVIC_RAM_VECTOR_ADDRESS) { |
| emilmont | 10:3bc89ef62ce7 | 16 | uint32_t *old_vectors = (uint32_t*)SCB->VTOR; |
| emilmont | 10:3bc89ef62ce7 | 17 | for (i=0; i<NVIC_NUM_VECTORS; i++) { |
| emilmont | 10:3bc89ef62ce7 | 18 | vectors[i] = old_vectors[i]; |
| emilmont | 10:3bc89ef62ce7 | 19 | } |
| emilmont | 10:3bc89ef62ce7 | 20 | SCB->VTOR = (uint32_t)vectors; |
| emilmont | 10:3bc89ef62ce7 | 21 | } |
| emilmont | 10:3bc89ef62ce7 | 22 | |
| emilmont | 10:3bc89ef62ce7 | 23 | vectors[IRQn + 16] = vector; |
| emilmont | 10:3bc89ef62ce7 | 24 | } |
| emilmont | 10:3bc89ef62ce7 | 25 | |
| emilmont | 10:3bc89ef62ce7 | 26 | uint32_t NVIC_GetVector(IRQn_Type IRQn) { |
| emilmont | 10:3bc89ef62ce7 | 27 | uint32_t *vectors = (uint32_t*)SCB->VTOR; |
| emilmont | 10:3bc89ef62ce7 | 28 | return vectors[IRQn + 16]; |
| emilmont | 10:3bc89ef62ce7 | 29 | } |
| emilmont | 10:3bc89ef62ce7 | 30 |
