mbed library sources, include can_api for nucleo-f091rc

Dependents:   CanNucleoF0_example

Fork of mbed-src by mbed official

Committer:
ptpaterson
Date:
Thu Jan 07 05:49:05 2016 +0000
Revision:
645:13c87cbecd54
Parent:
624:83778a75d1b4
corrected freeze on CAN_RECEIVE_IT

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 624:83778a75d1b4 1 /* mbed Microcontroller Library - cmsis_nvic for LCP1768
mbed_official 624:83778a75d1b4 2 * Copyright (c) 2009-2011 ARM Limited. All rights reserved.
mbed_official 624:83778a75d1b4 3 *
mbed_official 624:83778a75d1b4 4 * CMSIS-style functionality to support dynamic vectors
mbed_official 624:83778a75d1b4 5 */
mbed_official 624:83778a75d1b4 6 #include "cmsis_nvic.h"
mbed_official 624:83778a75d1b4 7
mbed_official 624:83778a75d1b4 8 #define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Location of vectors in RAM
mbed_official 624:83778a75d1b4 9 #define NVIC_FLASH_VECTOR_ADDRESS (0x00000000) // Initial vector position in flash
mbed_official 624:83778a75d1b4 10
mbed_official 624:83778a75d1b4 11 void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
mbed_official 624:83778a75d1b4 12 uint32_t *vectors = (uint32_t*)SCB->VTOR;
mbed_official 624:83778a75d1b4 13 uint32_t i;
mbed_official 624:83778a75d1b4 14
mbed_official 624:83778a75d1b4 15 // Copy and switch to dynamic vectors if the first time called
mbed_official 624:83778a75d1b4 16 if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
mbed_official 624:83778a75d1b4 17 uint32_t *old_vectors = vectors;
mbed_official 624:83778a75d1b4 18 vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
mbed_official 624:83778a75d1b4 19 for (i=0; i<NVIC_NUM_VECTORS; i++) {
mbed_official 624:83778a75d1b4 20 vectors[i] = old_vectors[i];
mbed_official 624:83778a75d1b4 21 }
mbed_official 624:83778a75d1b4 22 SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
mbed_official 624:83778a75d1b4 23 }
mbed_official 624:83778a75d1b4 24 vectors[IRQn + NVIC_USER_IRQ_OFFSET] = vector;
mbed_official 624:83778a75d1b4 25 }
mbed_official 624:83778a75d1b4 26
mbed_official 624:83778a75d1b4 27 uint32_t NVIC_GetVector(IRQn_Type IRQn) {
mbed_official 624:83778a75d1b4 28 uint32_t *vectors = (uint32_t*)SCB->VTOR;
mbed_official 624:83778a75d1b4 29 return vectors[IRQn + NVIC_USER_IRQ_OFFSET];
mbed_official 624:83778a75d1b4 30 }