mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/cmsis_nvic.c@308:59cc78a25982, 2014-09-05 (annotated)
- Committer:
- todotani
- Date:
- Fri Sep 05 14:20:33 2014 +0000
- Revision:
- 308:59cc78a25982
- Parent:
- 82:0b31dbcd4769
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 |
---|---|---|---|
mbed_official | 82:0b31dbcd4769 | 1 | /* mbed Microcontroller Library - cmsis_nvic for KL05Z |
mbed_official | 82:0b31dbcd4769 | 2 | * Copyright (c) 2011 ARM Limited. All rights reserved. |
mbed_official | 82:0b31dbcd4769 | 3 | * |
mbed_official | 82:0b31dbcd4769 | 4 | * CMSIS-style functionality to support dynamic vectors |
mbed_official | 82:0b31dbcd4769 | 5 | */ |
mbed_official | 82:0b31dbcd4769 | 6 | #include "cmsis_nvic.h" |
mbed_official | 82:0b31dbcd4769 | 7 | |
mbed_official | 82:0b31dbcd4769 | 8 | #define NVIC_RAM_VECTOR_ADDRESS (0x1FFFFC00) // Vectors positioned at start of RAM |
mbed_official | 82:0b31dbcd4769 | 9 | #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash |
mbed_official | 82:0b31dbcd4769 | 10 | |
mbed_official | 82:0b31dbcd4769 | 11 | void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) { |
mbed_official | 82:0b31dbcd4769 | 12 | uint32_t *vectors = (uint32_t*)SCB->VTOR; |
mbed_official | 82:0b31dbcd4769 | 13 | uint32_t i; |
mbed_official | 82:0b31dbcd4769 | 14 | |
mbed_official | 82:0b31dbcd4769 | 15 | // Copy and switch to dynamic vectors if the first time called |
mbed_official | 82:0b31dbcd4769 | 16 | if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) { |
mbed_official | 82:0b31dbcd4769 | 17 | uint32_t *old_vectors = vectors; |
mbed_official | 82:0b31dbcd4769 | 18 | vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS; |
mbed_official | 82:0b31dbcd4769 | 19 | for (i=0; i<NVIC_NUM_VECTORS; i++) { |
mbed_official | 82:0b31dbcd4769 | 20 | vectors[i] = old_vectors[i]; |
mbed_official | 82:0b31dbcd4769 | 21 | } |
mbed_official | 82:0b31dbcd4769 | 22 | SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS; |
mbed_official | 82:0b31dbcd4769 | 23 | } |
mbed_official | 82:0b31dbcd4769 | 24 | vectors[IRQn + 16] = vector; |
mbed_official | 82:0b31dbcd4769 | 25 | } |
mbed_official | 82:0b31dbcd4769 | 26 | |
mbed_official | 82:0b31dbcd4769 | 27 | uint32_t NVIC_GetVector(IRQn_Type IRQn) { |
mbed_official | 82:0b31dbcd4769 | 28 | uint32_t *vectors = (uint32_t*)SCB->VTOR; |
mbed_official | 82:0b31dbcd4769 | 29 | return vectors[IRQn + 16]; |
mbed_official | 82:0b31dbcd4769 | 30 | } |