Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: FRDM-KL46Z_LCD_Test FRDM-KL46Z_LCD_Test FRDM-KL46Z_Plantilla FRDM-KL46Z_Plantilla ... more
targets/cmsis/TARGET_Freescale/TARGET_K20D50M/cmsis_nvic.c@0:6bc4ac881c8e, 2016-07-28 (annotated)
- Committer:
- ebrus
- Date:
- Thu Jul 28 15:56:34 2016 +0000
- Revision:
- 0:6bc4ac881c8e
1;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ebrus | 0:6bc4ac881c8e | 1 | /* mbed Microcontroller Library - cmsis_nvic for LPC11U24 |
| ebrus | 0:6bc4ac881c8e | 2 | * Copyright (c) 2011 ARM Limited. All rights reserved. |
| ebrus | 0:6bc4ac881c8e | 3 | * |
| ebrus | 0:6bc4ac881c8e | 4 | * CMSIS-style functionality to support dynamic vectors |
| ebrus | 0:6bc4ac881c8e | 5 | */ |
| ebrus | 0:6bc4ac881c8e | 6 | #include "cmsis_nvic.h" |
| ebrus | 0:6bc4ac881c8e | 7 | |
| ebrus | 0:6bc4ac881c8e | 8 | #define NVIC_RAM_VECTOR_ADDRESS (0x1FFFE000) // Vectors positioned at start of RAM |
| ebrus | 0:6bc4ac881c8e | 9 | #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash |
| ebrus | 0:6bc4ac881c8e | 10 | |
| ebrus | 0:6bc4ac881c8e | 11 | void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) { |
| ebrus | 0:6bc4ac881c8e | 12 | uint32_t *vectors = (uint32_t*)SCB->VTOR; |
| ebrus | 0:6bc4ac881c8e | 13 | uint32_t i; |
| ebrus | 0:6bc4ac881c8e | 14 | |
| ebrus | 0:6bc4ac881c8e | 15 | // Copy and switch to dynamic vectors if the first time called |
| ebrus | 0:6bc4ac881c8e | 16 | if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) { |
| ebrus | 0:6bc4ac881c8e | 17 | uint32_t *old_vectors = vectors; |
| ebrus | 0:6bc4ac881c8e | 18 | vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS; |
| ebrus | 0:6bc4ac881c8e | 19 | for (i=0; i<NVIC_NUM_VECTORS; i++) { |
| ebrus | 0:6bc4ac881c8e | 20 | vectors[i] = old_vectors[i]; |
| ebrus | 0:6bc4ac881c8e | 21 | } |
| ebrus | 0:6bc4ac881c8e | 22 | SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS; |
| ebrus | 0:6bc4ac881c8e | 23 | } |
| ebrus | 0:6bc4ac881c8e | 24 | vectors[IRQn + 16] = vector; |
| ebrus | 0:6bc4ac881c8e | 25 | } |
| ebrus | 0:6bc4ac881c8e | 26 | |
| ebrus | 0:6bc4ac881c8e | 27 | uint32_t NVIC_GetVector(IRQn_Type IRQn) { |
| ebrus | 0:6bc4ac881c8e | 28 | uint32_t *vectors = (uint32_t*)SCB->VTOR; |
| ebrus | 0:6bc4ac881c8e | 29 | return vectors[IRQn + 16]; |
| ebrus | 0:6bc4ac881c8e | 30 | } |