mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F103RB/cmsis_nvic.c@52:a51c77007319, 2013-12-02 (annotated)
- Committer:
- mbed_official
- Date:
- Mon Dec 02 11:30:05 2013 +0000
- Revision:
- 52:a51c77007319
- Child:
- 70:c1fbde68b492
Synchronized with git revision 49df530ae72ce97ccc773d1f2c13b38e868e6abd
Full URL: https://github.com/mbedmicro/mbed/commit/49df530ae72ce97ccc773d1f2c13b38e868e6abd/
Add STMicroelectronics NUCLEO_F103RB target
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 52:a51c77007319 | 1 | /* mbed Microcontroller Library - cmsis_nvic for LPC11U24 |
mbed_official | 52:a51c77007319 | 2 | * Copyright (c) 2011 ARM Limited. All rights reserved. |
mbed_official | 52:a51c77007319 | 3 | * |
mbed_official | 52:a51c77007319 | 4 | * CMSIS-style functionality to support dynamic vectors |
mbed_official | 52:a51c77007319 | 5 | */ |
mbed_official | 52:a51c77007319 | 6 | #include "cmsis_nvic.h" |
mbed_official | 52:a51c77007319 | 7 | |
mbed_official | 52:a51c77007319 | 8 | #define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Vectors positioned at start of RAM |
mbed_official | 52:a51c77007319 | 9 | #define NVIC_FLASH_VECTOR_ADDRESS (0x08000000) // Initial vector position in flash |
mbed_official | 52:a51c77007319 | 10 | |
mbed_official | 52:a51c77007319 | 11 | void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) { |
mbed_official | 52:a51c77007319 | 12 | uint32_t *vectors = (uint32_t *)SCB->VTOR; |
mbed_official | 52:a51c77007319 | 13 | uint32_t i; |
mbed_official | 52:a51c77007319 | 14 | |
mbed_official | 52:a51c77007319 | 15 | // Copy and switch to dynamic vectors if the first time called |
mbed_official | 52:a51c77007319 | 16 | if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) { |
mbed_official | 52:a51c77007319 | 17 | uint32_t *old_vectors = vectors; |
mbed_official | 52:a51c77007319 | 18 | vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS; |
mbed_official | 52:a51c77007319 | 19 | for (i=0; i<NVIC_NUM_VECTORS; i++) { |
mbed_official | 52:a51c77007319 | 20 | vectors[i] = old_vectors[i]; |
mbed_official | 52:a51c77007319 | 21 | } |
mbed_official | 52:a51c77007319 | 22 | SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS; |
mbed_official | 52:a51c77007319 | 23 | } |
mbed_official | 52:a51c77007319 | 24 | vectors[IRQn + NVIC_USER_IRQ_OFFSET] = vector; |
mbed_official | 52:a51c77007319 | 25 | } |
mbed_official | 52:a51c77007319 | 26 | |
mbed_official | 52:a51c77007319 | 27 | uint32_t NVIC_GetVector(IRQn_Type IRQn) { |
mbed_official | 52:a51c77007319 | 28 | uint32_t *vectors = (uint32_t*)SCB->VTOR; |
mbed_official | 52:a51c77007319 | 29 | return vectors[IRQn + NVIC_USER_IRQ_OFFSET]; |
mbed_official | 52:a51c77007319 | 30 | } |