mbed library sources for GR-PEACH rev.B.
Fork of mbed-src by
targets/cmsis/TARGET_Freescale/TARGET_KL46Z/cmsis_nvic.c@33:e214068ab66c, 2013-10-07 (annotated)
- Committer:
- mbed_official
- Date:
- Mon Oct 07 09:15:08 2013 +0100
- Revision:
- 33:e214068ab66c
- Parent:
- 31:42176bc3c368
Synchronized with git revision 53edc82f7373bbfa01a161700524765f52fdb444
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 31:42176bc3c368 | 1 | /* mbed Microcontroller Library - cmsis_nvic for LPC11U24 |
mbed_official | 31:42176bc3c368 | 2 | * Copyright (c) 2011 ARM Limited. All rights reserved. |
mbed_official | 31:42176bc3c368 | 3 | * |
mbed_official | 31:42176bc3c368 | 4 | * CMSIS-style functionality to support dynamic vectors |
mbed_official | 33:e214068ab66c | 5 | */ |
mbed_official | 31:42176bc3c368 | 6 | #include "cmsis_nvic.h" |
mbed_official | 31:42176bc3c368 | 7 | |
mbed_official | 33:e214068ab66c | 8 | #define NVIC_RAM_VECTOR_ADDRESS (0x1FFFE000) // Vectors positioned at start of RAM |
mbed_official | 31:42176bc3c368 | 9 | #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash |
mbed_official | 31:42176bc3c368 | 10 | |
mbed_official | 31:42176bc3c368 | 11 | void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) { |
mbed_official | 31:42176bc3c368 | 12 | uint32_t *vectors = (uint32_t*)SCB->VTOR; |
mbed_official | 31:42176bc3c368 | 13 | uint32_t i; |
mbed_official | 31:42176bc3c368 | 14 | |
mbed_official | 31:42176bc3c368 | 15 | // Copy and switch to dynamic vectors if the first time called |
mbed_official | 31:42176bc3c368 | 16 | if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) { |
mbed_official | 31:42176bc3c368 | 17 | uint32_t *old_vectors = vectors; |
mbed_official | 31:42176bc3c368 | 18 | vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS; |
mbed_official | 31:42176bc3c368 | 19 | for (i=0; i<NVIC_NUM_VECTORS; i++) { |
mbed_official | 31:42176bc3c368 | 20 | vectors[i] = old_vectors[i]; |
mbed_official | 31:42176bc3c368 | 21 | } |
mbed_official | 31:42176bc3c368 | 22 | SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS; |
mbed_official | 31:42176bc3c368 | 23 | } |
mbed_official | 31:42176bc3c368 | 24 | vectors[IRQn + 16] = vector; |
mbed_official | 31:42176bc3c368 | 25 | } |
mbed_official | 31:42176bc3c368 | 26 | |
mbed_official | 31:42176bc3c368 | 27 | uint32_t NVIC_GetVector(IRQn_Type IRQn) { |
mbed_official | 31:42176bc3c368 | 28 | uint32_t *vectors = (uint32_t*)SCB->VTOR; |
mbed_official | 31:42176bc3c368 | 29 | return vectors[IRQn + 16]; |
mbed_official | 31:42176bc3c368 | 30 | } |