mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
bogdanm
Date:
Tue Sep 10 15:14:19 2013 +0300
Revision:
20:4263a77256ae
Child:
358:9d7ef901f004
Sync with git revision 171dda705c947bf910926a0b73d6a4797802554d

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 20:4263a77256ae 1 /* mbed Microcontroller Library - cmsis_nvic for LCP43xx
bogdanm 20:4263a77256ae 2 * Copyright (c) 2009-2011 ARM Limited. All rights reserved.
bogdanm 20:4263a77256ae 3 *
bogdanm 20:4263a77256ae 4 * CMSIS-style functionality to support dynamic vectors
bogdanm 20:4263a77256ae 5 */
bogdanm 20:4263a77256ae 6 #include "cmsis_nvic.h"
bogdanm 20:4263a77256ae 7
bogdanm 20:4263a77256ae 8 #define NVIC_RAM_VECTOR_ADDRESS (0x10000000) // Location of vectors in RAM
bogdanm 20:4263a77256ae 9
bogdanm 20:4263a77256ae 10 // The LPC43xx can boot from multiple memories (internal Flash, external NOR,
bogdanm 20:4263a77256ae 11 // external SPIFI) so we don't know the initial value of VTOR. Thus we use
bogdanm 20:4263a77256ae 12 // a variable to keep track if the vector table was relocated or not
bogdanm 20:4263a77256ae 13 static unsigned char vtor_relocated;
bogdanm 20:4263a77256ae 14
bogdanm 20:4263a77256ae 15 void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
bogdanm 20:4263a77256ae 16 uint32_t *vectors = (uint32_t*)SCB->VTOR;
bogdanm 20:4263a77256ae 17 uint32_t i;
bogdanm 20:4263a77256ae 18
bogdanm 20:4263a77256ae 19 // Copy and switch to dynamic vectors if first time called
bogdanm 20:4263a77256ae 20 if (!vtor_relocated) {
bogdanm 20:4263a77256ae 21 uint32_t *old_vectors = vectors;
bogdanm 20:4263a77256ae 22 vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
bogdanm 20:4263a77256ae 23 for (i=0; i<NVIC_NUM_VECTORS; i++) {
bogdanm 20:4263a77256ae 24 vectors[i] = old_vectors[i];
bogdanm 20:4263a77256ae 25 }
bogdanm 20:4263a77256ae 26 SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
bogdanm 20:4263a77256ae 27 vtor_relocated = 1;
bogdanm 20:4263a77256ae 28 }
bogdanm 20:4263a77256ae 29 vectors[IRQn + 16] = vector;
bogdanm 20:4263a77256ae 30 }
bogdanm 20:4263a77256ae 31
bogdanm 20:4263a77256ae 32 uint32_t NVIC_GetVector(IRQn_Type IRQn) {
bogdanm 20:4263a77256ae 33 uint32_t *vectors = (uint32_t*)SCB->VTOR;
bogdanm 20:4263a77256ae 34 return vectors[IRQn + 16];
bogdanm 20:4263a77256ae 35 }
bogdanm 20:4263a77256ae 36