PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)
mbed-pokitto/targets/cmsis/TARGET_NXP/TARGET_LPC11U6X/cmsis_nvic.c@64:6e6c6c2b664e, 2018-11-18 (annotated)
- Committer:
- spinal
- Date:
- Sun Nov 18 15:47:54 2018 +0000
- Revision:
- 64:6e6c6c2b664e
- Parent:
- 5:ea7377f3d1af
added fix for directrectangle()
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Pokitto | 5:ea7377f3d1af | 1 | /* mbed Microcontroller Library |
Pokitto | 5:ea7377f3d1af | 2 | * CMSIS-style functionality to support dynamic vectors |
Pokitto | 5:ea7377f3d1af | 3 | ******************************************************************************* |
Pokitto | 5:ea7377f3d1af | 4 | * Copyright (c) 2011 ARM Limited. All rights reserved. |
Pokitto | 5:ea7377f3d1af | 5 | * All rights reserved. |
Pokitto | 5:ea7377f3d1af | 6 | * |
Pokitto | 5:ea7377f3d1af | 7 | * Redistribution and use in source and binary forms, with or without |
Pokitto | 5:ea7377f3d1af | 8 | * modification, are permitted provided that the following conditions are met: |
Pokitto | 5:ea7377f3d1af | 9 | * |
Pokitto | 5:ea7377f3d1af | 10 | * 1. Redistributions of source code must retain the above copyright notice, |
Pokitto | 5:ea7377f3d1af | 11 | * this list of conditions and the following disclaimer. |
Pokitto | 5:ea7377f3d1af | 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
Pokitto | 5:ea7377f3d1af | 13 | * this list of conditions and the following disclaimer in the documentation |
Pokitto | 5:ea7377f3d1af | 14 | * and/or other materials provided with the distribution. |
Pokitto | 5:ea7377f3d1af | 15 | * 3. Neither the name of ARM Limited nor the names of its contributors |
Pokitto | 5:ea7377f3d1af | 16 | * may be used to endorse or promote products derived from this software |
Pokitto | 5:ea7377f3d1af | 17 | * without specific prior written permission. |
Pokitto | 5:ea7377f3d1af | 18 | * |
Pokitto | 5:ea7377f3d1af | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
Pokitto | 5:ea7377f3d1af | 20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
Pokitto | 5:ea7377f3d1af | 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Pokitto | 5:ea7377f3d1af | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
Pokitto | 5:ea7377f3d1af | 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
Pokitto | 5:ea7377f3d1af | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
Pokitto | 5:ea7377f3d1af | 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
Pokitto | 5:ea7377f3d1af | 26 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
Pokitto | 5:ea7377f3d1af | 27 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
Pokitto | 5:ea7377f3d1af | 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Pokitto | 5:ea7377f3d1af | 29 | ******************************************************************************* |
Pokitto | 5:ea7377f3d1af | 30 | */ |
Pokitto | 5:ea7377f3d1af | 31 | #include "cmsis_nvic.h" |
Pokitto | 5:ea7377f3d1af | 32 | |
Pokitto | 5:ea7377f3d1af | 33 | #define NVIC_RAM_VECTOR_ADDRESS (0x10000000) // Vectors positioned at start of RAM |
Pokitto | 5:ea7377f3d1af | 34 | #define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash |
Pokitto | 5:ea7377f3d1af | 35 | |
Pokitto | 5:ea7377f3d1af | 36 | void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) { |
Pokitto | 5:ea7377f3d1af | 37 | uint32_t *vectors = (uint32_t*)SCB->VTOR; |
Pokitto | 5:ea7377f3d1af | 38 | uint32_t i; |
Pokitto | 5:ea7377f3d1af | 39 | |
Pokitto | 5:ea7377f3d1af | 40 | // Copy and switch to dynamic vectors if the first time called |
Pokitto | 5:ea7377f3d1af | 41 | if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) { |
Pokitto | 5:ea7377f3d1af | 42 | uint32_t *old_vectors = vectors; |
Pokitto | 5:ea7377f3d1af | 43 | vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS; |
Pokitto | 5:ea7377f3d1af | 44 | for (i=0; i<NVIC_NUM_VECTORS; i++) { |
Pokitto | 5:ea7377f3d1af | 45 | vectors[i] = old_vectors[i]; |
Pokitto | 5:ea7377f3d1af | 46 | } |
Pokitto | 5:ea7377f3d1af | 47 | SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS; |
Pokitto | 5:ea7377f3d1af | 48 | } |
Pokitto | 5:ea7377f3d1af | 49 | vectors[IRQn + 16] = vector; |
Pokitto | 5:ea7377f3d1af | 50 | } |
Pokitto | 5:ea7377f3d1af | 51 | |
Pokitto | 5:ea7377f3d1af | 52 | uint32_t NVIC_GetVector(IRQn_Type IRQn) { |
Pokitto | 5:ea7377f3d1af | 53 | uint32_t *vectors = (uint32_t*)SCB->VTOR; |
Pokitto | 5:ea7377f3d1af | 54 | return vectors[IRQn + 16]; |
Pokitto | 5:ea7377f3d1af | 55 | } |