The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_SAMD21G18A/TOOLCHAIN_ARM_MICRO/system_interrupt.h@171:3a7713b1edbc, 2018-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 08 11:45:42 2018 +0000
- Revision:
- 171:3a7713b1edbc
- Parent:
- TARGET_SAMD21J18A/TARGET_Atmel/TARGET_SAM_CortexM0P/drivers/system/interrupt/system_interrupt.h@111:4336505e4b1c
mbed library. Release version 164
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kojto | 111:4336505e4b1c | 1 | /** |
Kojto | 111:4336505e4b1c | 2 | * \file |
Kojto | 111:4336505e4b1c | 3 | * |
Kojto | 111:4336505e4b1c | 4 | * \brief SAM System Interrupt Driver |
Kojto | 111:4336505e4b1c | 5 | * |
Kojto | 111:4336505e4b1c | 6 | * Copyright (C) 2012-2015 Atmel Corporation. All rights reserved. |
Kojto | 111:4336505e4b1c | 7 | * |
Kojto | 111:4336505e4b1c | 8 | * \asf_license_start |
Kojto | 111:4336505e4b1c | 9 | * |
Kojto | 111:4336505e4b1c | 10 | * \page License |
Kojto | 111:4336505e4b1c | 11 | * |
Kojto | 111:4336505e4b1c | 12 | * Redistribution and use in source and binary forms, with or without |
Kojto | 111:4336505e4b1c | 13 | * modification, are permitted provided that the following conditions are met: |
Kojto | 111:4336505e4b1c | 14 | * |
Kojto | 111:4336505e4b1c | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
Kojto | 111:4336505e4b1c | 16 | * this list of conditions and the following disclaimer. |
Kojto | 111:4336505e4b1c | 17 | * |
Kojto | 111:4336505e4b1c | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
Kojto | 111:4336505e4b1c | 19 | * this list of conditions and the following disclaimer in the documentation |
Kojto | 111:4336505e4b1c | 20 | * and/or other materials provided with the distribution. |
Kojto | 111:4336505e4b1c | 21 | * |
Kojto | 111:4336505e4b1c | 22 | * 3. The name of Atmel may not be used to endorse or promote products derived |
Kojto | 111:4336505e4b1c | 23 | * from this software without specific prior written permission. |
Kojto | 111:4336505e4b1c | 24 | * |
Kojto | 111:4336505e4b1c | 25 | * 4. This software may only be redistributed and used in connection with an |
Kojto | 111:4336505e4b1c | 26 | * Atmel microcontroller product. |
Kojto | 111:4336505e4b1c | 27 | * |
Kojto | 111:4336505e4b1c | 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED |
Kojto | 111:4336505e4b1c | 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
Kojto | 111:4336505e4b1c | 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE |
Kojto | 111:4336505e4b1c | 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR |
Kojto | 111:4336505e4b1c | 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
Kojto | 111:4336505e4b1c | 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
Kojto | 111:4336505e4b1c | 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
Kojto | 111:4336505e4b1c | 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
Kojto | 111:4336505e4b1c | 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
Kojto | 111:4336505e4b1c | 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
Kojto | 111:4336505e4b1c | 38 | * POSSIBILITY OF SUCH DAMAGE. |
Kojto | 111:4336505e4b1c | 39 | * |
Kojto | 111:4336505e4b1c | 40 | * \asf_license_stop |
Kojto | 111:4336505e4b1c | 41 | * |
Kojto | 111:4336505e4b1c | 42 | */ |
Kojto | 111:4336505e4b1c | 43 | /* |
Kojto | 111:4336505e4b1c | 44 | * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a> |
Kojto | 111:4336505e4b1c | 45 | */ |
Kojto | 111:4336505e4b1c | 46 | #ifndef SYSTEM_INTERRUPT_H_INCLUDED |
Kojto | 111:4336505e4b1c | 47 | #define SYSTEM_INTERRUPT_H_INCLUDED |
Kojto | 111:4336505e4b1c | 48 | |
Kojto | 111:4336505e4b1c | 49 | #ifdef __cplusplus |
Kojto | 111:4336505e4b1c | 50 | extern "C" { |
Kojto | 111:4336505e4b1c | 51 | #endif |
Kojto | 111:4336505e4b1c | 52 | |
Kojto | 111:4336505e4b1c | 53 | /** |
Kojto | 111:4336505e4b1c | 54 | * \defgroup asfdoc_sam0_system_interrupt_group SAM System Interrupt Driver (SYSTEM INTERRUPT) |
Kojto | 111:4336505e4b1c | 55 | * |
Kojto | 111:4336505e4b1c | 56 | * This driver for Atmel® | SMART SAM devices provides an interface for the configuration |
Kojto | 111:4336505e4b1c | 57 | * and management of internal software and hardware interrupts/exceptions. |
Kojto | 111:4336505e4b1c | 58 | * |
Kojto | 111:4336505e4b1c | 59 | * The following peripherals are used by this module: |
Kojto | 111:4336505e4b1c | 60 | * - NVIC (Nested Vector Interrupt Controller) |
Kojto | 111:4336505e4b1c | 61 | * |
Kojto | 111:4336505e4b1c | 62 | * The following devices can use this module: |
Kojto | 111:4336505e4b1c | 63 | * - Atmel | SMART SAM D20/D21 |
Kojto | 111:4336505e4b1c | 64 | * - Atmel | SMART SAM R21 |
Kojto | 111:4336505e4b1c | 65 | * - Atmel | SMART SAM D10/D11 |
Kojto | 111:4336505e4b1c | 66 | * - Atmel | SMART SAM L21 |
Kojto | 111:4336505e4b1c | 67 | * - Atmel | SMART SAM DAx |
Kojto | 111:4336505e4b1c | 68 | * - Atmel | SMART SAM C20/C21 |
Kojto | 111:4336505e4b1c | 69 | * |
Kojto | 111:4336505e4b1c | 70 | * The outline of this documentation is as follows: |
Kojto | 111:4336505e4b1c | 71 | * - \ref asfdoc_sam0_system_interrupt_prerequisites |
Kojto | 111:4336505e4b1c | 72 | * - \ref asfdoc_sam0_system_interrupt_module_overview |
Kojto | 111:4336505e4b1c | 73 | * - \ref asfdoc_sam0_system_interrupt_special_considerations |
Kojto | 111:4336505e4b1c | 74 | * - \ref asfdoc_sam0_system_interrupt_extra_info |
Kojto | 111:4336505e4b1c | 75 | * - \ref asfdoc_sam0_system_interrupt_examples |
Kojto | 111:4336505e4b1c | 76 | * - \ref asfdoc_sam0_system_interrupt_api_overview |
Kojto | 111:4336505e4b1c | 77 | * |
Kojto | 111:4336505e4b1c | 78 | * |
Kojto | 111:4336505e4b1c | 79 | * \section asfdoc_sam0_system_interrupt_prerequisites Prerequisites |
Kojto | 111:4336505e4b1c | 80 | * |
Kojto | 111:4336505e4b1c | 81 | * There are no prerequisites for this module. |
Kojto | 111:4336505e4b1c | 82 | * |
Kojto | 111:4336505e4b1c | 83 | * |
Kojto | 111:4336505e4b1c | 84 | * \section asfdoc_sam0_system_interrupt_module_overview Module Overview |
Kojto | 111:4336505e4b1c | 85 | * |
Kojto | 111:4336505e4b1c | 86 | * The ARM® Cortex® M0+ core contains an interrupt and exception vector table, which |
Kojto | 111:4336505e4b1c | 87 | * can be used to configure the device's interrupt handlers; individual |
Kojto | 111:4336505e4b1c | 88 | * interrupts and exceptions can be enabled and disabled, as well as configured |
Kojto | 111:4336505e4b1c | 89 | * with a variable priority. |
Kojto | 111:4336505e4b1c | 90 | * |
Kojto | 111:4336505e4b1c | 91 | * This driver provides a set of wrappers around the core interrupt functions, |
Kojto | 111:4336505e4b1c | 92 | * to expose a simple API for the management of global and individual interrupts |
Kojto | 111:4336505e4b1c | 93 | * within the device. |
Kojto | 111:4336505e4b1c | 94 | * |
Kojto | 111:4336505e4b1c | 95 | * \subsection asfdoc_sam0_system_interrupt_module_overview_criticalsec Critical Sections |
Kojto | 111:4336505e4b1c | 96 | * In some applications it is important to ensure that no interrupts may be |
Kojto | 111:4336505e4b1c | 97 | * executed by the system whilst a critical portion of code is being run; for |
Kojto | 111:4336505e4b1c | 98 | * example, a buffer may be copied from one context to another - during which |
Kojto | 111:4336505e4b1c | 99 | * interrupts must be disabled to avoid corruption of the source buffer contents |
Kojto | 111:4336505e4b1c | 100 | * until the copy has completed. This driver provides a basic API to enter and |
Kojto | 111:4336505e4b1c | 101 | * exit nested critical sections, so that global interrupts can be kept disabled |
Kojto | 111:4336505e4b1c | 102 | * for as long as necessary to complete a critical application code section. |
Kojto | 111:4336505e4b1c | 103 | * |
Kojto | 111:4336505e4b1c | 104 | * \subsection asfdoc_sam0_system_interrupt_module_overview_softints Software Interrupts |
Kojto | 111:4336505e4b1c | 105 | * For some applications, it may be desirable to raise a module or core |
Kojto | 111:4336505e4b1c | 106 | * interrupt via software. For this reason, a set of APIs to set an interrupt or |
Kojto | 111:4336505e4b1c | 107 | * exception as pending are provided to the user application. |
Kojto | 111:4336505e4b1c | 108 | * |
Kojto | 111:4336505e4b1c | 109 | * \section asfdoc_sam0_system_interrupt_special_considerations Special Considerations |
Kojto | 111:4336505e4b1c | 110 | * |
Kojto | 111:4336505e4b1c | 111 | * Interrupts from peripherals in the SAM devices are on a per-module basis; |
Kojto | 111:4336505e4b1c | 112 | * an interrupt raised from any source within a module will cause a single, |
Kojto | 111:4336505e4b1c | 113 | * module-common handler to execute. It is the user application or driver's |
Kojto | 111:4336505e4b1c | 114 | * responsibility to de-multiplex the module-common interrupt to determine the |
Kojto | 111:4336505e4b1c | 115 | * exact interrupt cause. |
Kojto | 111:4336505e4b1c | 116 | * |
Kojto | 111:4336505e4b1c | 117 | * \section asfdoc_sam0_system_interrupt_extra_info Extra Information |
Kojto | 111:4336505e4b1c | 118 | * |
Kojto | 111:4336505e4b1c | 119 | * For extra information, see \ref asfdoc_sam0_system_interrupt_extra. This includes: |
Kojto | 111:4336505e4b1c | 120 | * - \ref asfdoc_sam0_system_interrupt_extra_acronyms |
Kojto | 111:4336505e4b1c | 121 | * - \ref asfdoc_sam0_system_interrupt_extra_dependencies |
Kojto | 111:4336505e4b1c | 122 | * - \ref asfdoc_sam0_system_interrupt_extra_errata |
Kojto | 111:4336505e4b1c | 123 | * - \ref asfdoc_sam0_system_interrupt_extra_history |
Kojto | 111:4336505e4b1c | 124 | * |
Kojto | 111:4336505e4b1c | 125 | * |
Kojto | 111:4336505e4b1c | 126 | * \section asfdoc_sam0_system_interrupt_examples Examples |
Kojto | 111:4336505e4b1c | 127 | * |
Kojto | 111:4336505e4b1c | 128 | * For a list of examples related to this driver, see |
Kojto | 111:4336505e4b1c | 129 | * \ref asfdoc_sam0_system_interrupt_exqsg. |
Kojto | 111:4336505e4b1c | 130 | * |
Kojto | 111:4336505e4b1c | 131 | * \section asfdoc_sam0_system_interrupt_api_overview API Overview |
Kojto | 111:4336505e4b1c | 132 | * @{ |
Kojto | 111:4336505e4b1c | 133 | */ |
Kojto | 111:4336505e4b1c | 134 | |
Kojto | 111:4336505e4b1c | 135 | #include <compiler.h> |
Kojto | 111:4336505e4b1c | 136 | #include <core_cm0plus.h> |
Kojto | 111:4336505e4b1c | 137 | #include "system_interrupt_features.h" |
Kojto | 111:4336505e4b1c | 138 | |
Kojto | 111:4336505e4b1c | 139 | /** |
Kojto | 111:4336505e4b1c | 140 | * \brief Table of possible system interrupt/exception vector priorities. |
Kojto | 111:4336505e4b1c | 141 | * |
Kojto | 111:4336505e4b1c | 142 | * Table of all possible interrupt and exception vector priorities within the |
Kojto | 111:4336505e4b1c | 143 | * device. |
Kojto | 111:4336505e4b1c | 144 | */ |
Kojto | 111:4336505e4b1c | 145 | enum system_interrupt_priority_level { |
Kojto | 111:4336505e4b1c | 146 | /** Priority level 0, the highest possible interrupt priority. */ |
Kojto | 111:4336505e4b1c | 147 | SYSTEM_INTERRUPT_PRIORITY_LEVEL_0 = 0, |
Kojto | 111:4336505e4b1c | 148 | /** Priority level 1. */ |
Kojto | 111:4336505e4b1c | 149 | SYSTEM_INTERRUPT_PRIORITY_LEVEL_1 = 1, |
Kojto | 111:4336505e4b1c | 150 | /** Priority level 2. */ |
Kojto | 111:4336505e4b1c | 151 | SYSTEM_INTERRUPT_PRIORITY_LEVEL_2 = 2, |
Kojto | 111:4336505e4b1c | 152 | /** Priority level 3, the lowest possible interrupt priority. */ |
Kojto | 111:4336505e4b1c | 153 | SYSTEM_INTERRUPT_PRIORITY_LEVEL_3 = 3, |
Kojto | 111:4336505e4b1c | 154 | }; |
Kojto | 111:4336505e4b1c | 155 | |
Kojto | 111:4336505e4b1c | 156 | /** |
Kojto | 111:4336505e4b1c | 157 | * \name Critical Section Management |
Kojto | 111:4336505e4b1c | 158 | * @{ |
Kojto | 111:4336505e4b1c | 159 | */ |
Kojto | 111:4336505e4b1c | 160 | |
Kojto | 111:4336505e4b1c | 161 | /** |
Kojto | 111:4336505e4b1c | 162 | * \brief Enters a critical section. |
Kojto | 111:4336505e4b1c | 163 | * |
Kojto | 111:4336505e4b1c | 164 | * Disables global interrupts. To support nested critical sections, an internal |
Kojto | 111:4336505e4b1c | 165 | * count of the critical section nesting will be kept, so that global interrupts |
Kojto | 111:4336505e4b1c | 166 | * are only re-enabled upon leaving the outermost nested critical section. |
Kojto | 111:4336505e4b1c | 167 | * |
Kojto | 111:4336505e4b1c | 168 | */ |
Kojto | 111:4336505e4b1c | 169 | static inline void system_interrupt_enter_critical_section(void) |
Kojto | 111:4336505e4b1c | 170 | { |
Kojto | 111:4336505e4b1c | 171 | cpu_irq_enter_critical(); |
Kojto | 111:4336505e4b1c | 172 | } |
Kojto | 111:4336505e4b1c | 173 | |
Kojto | 111:4336505e4b1c | 174 | /** |
Kojto | 111:4336505e4b1c | 175 | * \brief Leaves a critical section. |
Kojto | 111:4336505e4b1c | 176 | * |
Kojto | 111:4336505e4b1c | 177 | * Enables global interrupts. To support nested critical sections, an internal |
Kojto | 111:4336505e4b1c | 178 | * count of the critical section nesting will be kept, so that global interrupts |
Kojto | 111:4336505e4b1c | 179 | * are only re-enabled upon leaving the outermost nested critical section. |
Kojto | 111:4336505e4b1c | 180 | * |
Kojto | 111:4336505e4b1c | 181 | */ |
Kojto | 111:4336505e4b1c | 182 | static inline void system_interrupt_leave_critical_section(void) |
Kojto | 111:4336505e4b1c | 183 | { |
Kojto | 111:4336505e4b1c | 184 | cpu_irq_leave_critical(); |
Kojto | 111:4336505e4b1c | 185 | } |
Kojto | 111:4336505e4b1c | 186 | |
Kojto | 111:4336505e4b1c | 187 | /** @} */ |
Kojto | 111:4336505e4b1c | 188 | |
Kojto | 111:4336505e4b1c | 189 | /** |
Kojto | 111:4336505e4b1c | 190 | * \name Interrupt Enabling/Disabling |
Kojto | 111:4336505e4b1c | 191 | * @{ |
Kojto | 111:4336505e4b1c | 192 | */ |
Kojto | 111:4336505e4b1c | 193 | |
Kojto | 111:4336505e4b1c | 194 | /** |
Kojto | 111:4336505e4b1c | 195 | * \brief Check if global interrupts are enabled. |
Kojto | 111:4336505e4b1c | 196 | * |
Kojto | 111:4336505e4b1c | 197 | * Checks if global interrupts are currently enabled. |
Kojto | 111:4336505e4b1c | 198 | * |
Kojto | 111:4336505e4b1c | 199 | * \returns A boolean that identifies if the global interrupts are enabled or not. |
Kojto | 111:4336505e4b1c | 200 | * |
Kojto | 111:4336505e4b1c | 201 | * \retval true Global interrupts are currently enabled |
Kojto | 111:4336505e4b1c | 202 | * \retval false Global interrupts are currently disabled |
Kojto | 111:4336505e4b1c | 203 | * |
Kojto | 111:4336505e4b1c | 204 | */ |
Kojto | 111:4336505e4b1c | 205 | static inline bool system_interrupt_is_global_enabled(void) |
Kojto | 111:4336505e4b1c | 206 | { |
Kojto | 111:4336505e4b1c | 207 | return cpu_irq_is_enabled(); |
Kojto | 111:4336505e4b1c | 208 | } |
Kojto | 111:4336505e4b1c | 209 | |
Kojto | 111:4336505e4b1c | 210 | /** |
Kojto | 111:4336505e4b1c | 211 | * \brief Enables global interrupts. |
Kojto | 111:4336505e4b1c | 212 | * |
Kojto | 111:4336505e4b1c | 213 | * Enables global interrupts in the device to fire any enabled interrupt handlers. |
Kojto | 111:4336505e4b1c | 214 | */ |
Kojto | 111:4336505e4b1c | 215 | static inline void system_interrupt_enable_global(void) |
Kojto | 111:4336505e4b1c | 216 | { |
Kojto | 111:4336505e4b1c | 217 | cpu_irq_enable(); |
Kojto | 111:4336505e4b1c | 218 | } |
Kojto | 111:4336505e4b1c | 219 | |
Kojto | 111:4336505e4b1c | 220 | /** |
Kojto | 111:4336505e4b1c | 221 | * \brief Disables global interrupts. |
Kojto | 111:4336505e4b1c | 222 | * |
Kojto | 111:4336505e4b1c | 223 | * Disabled global interrupts in the device, preventing any enabled interrupt |
Kojto | 111:4336505e4b1c | 224 | * handlers from executing. |
Kojto | 111:4336505e4b1c | 225 | */ |
Kojto | 111:4336505e4b1c | 226 | static inline void system_interrupt_disable_global(void) |
Kojto | 111:4336505e4b1c | 227 | { |
Kojto | 111:4336505e4b1c | 228 | cpu_irq_disable(); |
Kojto | 111:4336505e4b1c | 229 | } |
Kojto | 111:4336505e4b1c | 230 | |
Kojto | 111:4336505e4b1c | 231 | /** |
Kojto | 111:4336505e4b1c | 232 | * \brief Checks if an interrupt vector is enabled or not. |
Kojto | 111:4336505e4b1c | 233 | * |
Kojto | 111:4336505e4b1c | 234 | * Checks if a specific interrupt vector is currently enabled. |
Kojto | 111:4336505e4b1c | 235 | * |
Kojto | 111:4336505e4b1c | 236 | * \param[in] vector Interrupt vector number to check |
Kojto | 111:4336505e4b1c | 237 | * |
Kojto | 111:4336505e4b1c | 238 | * \returns A variable identifying if the requested interrupt vector is enabled. |
Kojto | 111:4336505e4b1c | 239 | * |
Kojto | 111:4336505e4b1c | 240 | * \retval true Specified interrupt vector is currently enabled |
Kojto | 111:4336505e4b1c | 241 | * \retval false Specified interrupt vector is currently disabled |
Kojto | 111:4336505e4b1c | 242 | * |
Kojto | 111:4336505e4b1c | 243 | */ |
Kojto | 111:4336505e4b1c | 244 | static inline bool system_interrupt_is_enabled( |
Kojto | 111:4336505e4b1c | 245 | const enum system_interrupt_vector vector) |
Kojto | 111:4336505e4b1c | 246 | { |
Kojto | 111:4336505e4b1c | 247 | return (bool)((NVIC->ISER[0] >> (uint32_t)vector) & 0x00000001); |
Kojto | 111:4336505e4b1c | 248 | } |
Kojto | 111:4336505e4b1c | 249 | |
Kojto | 111:4336505e4b1c | 250 | /** |
Kojto | 111:4336505e4b1c | 251 | * \brief Enable interrupt vector. |
Kojto | 111:4336505e4b1c | 252 | * |
Kojto | 111:4336505e4b1c | 253 | * Enables execution of the software handler for the requested interrupt vector. |
Kojto | 111:4336505e4b1c | 254 | * |
Kojto | 111:4336505e4b1c | 255 | * \param[in] vector Interrupt vector to enable |
Kojto | 111:4336505e4b1c | 256 | */ |
Kojto | 111:4336505e4b1c | 257 | static inline void system_interrupt_enable( |
Kojto | 111:4336505e4b1c | 258 | const enum system_interrupt_vector vector) |
Kojto | 111:4336505e4b1c | 259 | { |
Kojto | 111:4336505e4b1c | 260 | NVIC->ISER[0] = (uint32_t)(1 << ((uint32_t)vector & 0x0000001f)); |
Kojto | 111:4336505e4b1c | 261 | } |
Kojto | 111:4336505e4b1c | 262 | |
Kojto | 111:4336505e4b1c | 263 | /** |
Kojto | 111:4336505e4b1c | 264 | * \brief Disable interrupt vector. |
Kojto | 111:4336505e4b1c | 265 | * |
Kojto | 111:4336505e4b1c | 266 | * Disables execution of the software handler for the requested interrupt vector. |
Kojto | 111:4336505e4b1c | 267 | * |
Kojto | 111:4336505e4b1c | 268 | * \param[in] vector Interrupt vector to disable |
Kojto | 111:4336505e4b1c | 269 | */ |
Kojto | 111:4336505e4b1c | 270 | static inline void system_interrupt_disable( |
Kojto | 111:4336505e4b1c | 271 | const enum system_interrupt_vector vector) |
Kojto | 111:4336505e4b1c | 272 | { |
Kojto | 111:4336505e4b1c | 273 | NVIC->ICER[0] = (uint32_t)(1 << ((uint32_t)vector & 0x0000001f)); |
Kojto | 111:4336505e4b1c | 274 | } |
Kojto | 111:4336505e4b1c | 275 | |
Kojto | 111:4336505e4b1c | 276 | /** @} */ |
Kojto | 111:4336505e4b1c | 277 | |
Kojto | 111:4336505e4b1c | 278 | /** |
Kojto | 111:4336505e4b1c | 279 | * \name Interrupt State Management |
Kojto | 111:4336505e4b1c | 280 | * @{ |
Kojto | 111:4336505e4b1c | 281 | */ |
Kojto | 111:4336505e4b1c | 282 | |
Kojto | 111:4336505e4b1c | 283 | /** |
Kojto | 111:4336505e4b1c | 284 | * \brief Get active interrupt (if any). |
Kojto | 111:4336505e4b1c | 285 | * |
Kojto | 111:4336505e4b1c | 286 | * Return the vector number for the current executing software handler, if any. |
Kojto | 111:4336505e4b1c | 287 | * |
Kojto | 111:4336505e4b1c | 288 | * \return Interrupt number that is currently executing. |
Kojto | 111:4336505e4b1c | 289 | */ |
Kojto | 111:4336505e4b1c | 290 | static inline enum system_interrupt_vector system_interrupt_get_active(void) |
Kojto | 111:4336505e4b1c | 291 | { |
Kojto | 111:4336505e4b1c | 292 | uint32_t IPSR = __get_IPSR(); |
Kojto | 111:4336505e4b1c | 293 | /* The IPSR returns the Exception number, which with an offset 16 to IRQ number. */ |
Kojto | 111:4336505e4b1c | 294 | return (enum system_interrupt_vector)((IPSR & _SYSTEM_INTERRUPT_IPSR_MASK) - 16); |
Kojto | 111:4336505e4b1c | 295 | } |
Kojto | 111:4336505e4b1c | 296 | |
Kojto | 111:4336505e4b1c | 297 | bool system_interrupt_is_pending( |
Kojto | 111:4336505e4b1c | 298 | const enum system_interrupt_vector vector); |
Kojto | 111:4336505e4b1c | 299 | |
Kojto | 111:4336505e4b1c | 300 | enum status_code system_interrupt_set_pending( |
Kojto | 111:4336505e4b1c | 301 | const enum system_interrupt_vector vector); |
Kojto | 111:4336505e4b1c | 302 | |
Kojto | 111:4336505e4b1c | 303 | enum status_code system_interrupt_clear_pending( |
Kojto | 111:4336505e4b1c | 304 | const enum system_interrupt_vector vector); |
Kojto | 111:4336505e4b1c | 305 | |
Kojto | 111:4336505e4b1c | 306 | /** @} */ |
Kojto | 111:4336505e4b1c | 307 | |
Kojto | 111:4336505e4b1c | 308 | /** |
Kojto | 111:4336505e4b1c | 309 | * \name Interrupt Priority Management |
Kojto | 111:4336505e4b1c | 310 | * @{ |
Kojto | 111:4336505e4b1c | 311 | */ |
Kojto | 111:4336505e4b1c | 312 | |
Kojto | 111:4336505e4b1c | 313 | enum status_code system_interrupt_set_priority( |
Kojto | 111:4336505e4b1c | 314 | const enum system_interrupt_vector vector, |
Kojto | 111:4336505e4b1c | 315 | const enum system_interrupt_priority_level priority_level); |
Kojto | 111:4336505e4b1c | 316 | |
Kojto | 111:4336505e4b1c | 317 | enum system_interrupt_priority_level system_interrupt_get_priority( |
Kojto | 111:4336505e4b1c | 318 | const enum system_interrupt_vector vector); |
Kojto | 111:4336505e4b1c | 319 | |
Kojto | 111:4336505e4b1c | 320 | /** @} */ |
Kojto | 111:4336505e4b1c | 321 | |
Kojto | 111:4336505e4b1c | 322 | /** @} */ |
Kojto | 111:4336505e4b1c | 323 | |
Kojto | 111:4336505e4b1c | 324 | /** |
Kojto | 111:4336505e4b1c | 325 | * \page asfdoc_sam0_system_interrupt_extra Extra Information for SYSTEM INTERRUPT Driver |
Kojto | 111:4336505e4b1c | 326 | * |
Kojto | 111:4336505e4b1c | 327 | * \section asfdoc_sam0_system_interrupt_extra_acronyms Acronyms |
Kojto | 111:4336505e4b1c | 328 | * The table below presents the acronyms used in this module: |
Kojto | 111:4336505e4b1c | 329 | * |
Kojto | 111:4336505e4b1c | 330 | * <table> |
Kojto | 111:4336505e4b1c | 331 | * <tr> |
Kojto | 111:4336505e4b1c | 332 | * <th>Acronym</th> |
Kojto | 111:4336505e4b1c | 333 | * <th>Description</th> |
Kojto | 111:4336505e4b1c | 334 | * </tr> |
Kojto | 111:4336505e4b1c | 335 | * <tr> |
Kojto | 111:4336505e4b1c | 336 | * <td>ISR</td> |
Kojto | 111:4336505e4b1c | 337 | * <td>Interrupt Service Routine</td> |
Kojto | 111:4336505e4b1c | 338 | * </tr> |
Kojto | 111:4336505e4b1c | 339 | * <tr> |
Kojto | 111:4336505e4b1c | 340 | * <td>NMI</td> |
Kojto | 111:4336505e4b1c | 341 | * <td>Non-maskable Interrupt</td> |
Kojto | 111:4336505e4b1c | 342 | * </tr> |
Kojto | 111:4336505e4b1c | 343 | * <tr> |
Kojto | 111:4336505e4b1c | 344 | * <td>SERCOM</td> |
Kojto | 111:4336505e4b1c | 345 | * <td>Serial Communication Interface</td> |
Kojto | 111:4336505e4b1c | 346 | * </tr> |
Kojto | 111:4336505e4b1c | 347 | * </table> |
Kojto | 111:4336505e4b1c | 348 | * |
Kojto | 111:4336505e4b1c | 349 | * |
Kojto | 111:4336505e4b1c | 350 | * \section asfdoc_sam0_system_interrupt_extra_dependencies Dependencies |
Kojto | 111:4336505e4b1c | 351 | * This driver has the following dependencies: |
Kojto | 111:4336505e4b1c | 352 | * |
Kojto | 111:4336505e4b1c | 353 | * - None |
Kojto | 111:4336505e4b1c | 354 | * |
Kojto | 111:4336505e4b1c | 355 | * |
Kojto | 111:4336505e4b1c | 356 | * \section asfdoc_sam0_system_interrupt_extra_errata Errata |
Kojto | 111:4336505e4b1c | 357 | * There are no errata related to this driver. |
Kojto | 111:4336505e4b1c | 358 | * |
Kojto | 111:4336505e4b1c | 359 | * |
Kojto | 111:4336505e4b1c | 360 | * \section asfdoc_sam0_system_interrupt_extra_history Module History |
Kojto | 111:4336505e4b1c | 361 | * An overview of the module history is presented in the table below, with |
Kojto | 111:4336505e4b1c | 362 | * details on the enhancements and fixes made to the module since its first |
Kojto | 111:4336505e4b1c | 363 | * release. The current version of this corresponds to the newest version in |
Kojto | 111:4336505e4b1c | 364 | * the table. |
Kojto | 111:4336505e4b1c | 365 | * |
Kojto | 111:4336505e4b1c | 366 | * <table> |
Kojto | 111:4336505e4b1c | 367 | * <tr> |
Kojto | 111:4336505e4b1c | 368 | * <th>Changelog</th> |
Kojto | 111:4336505e4b1c | 369 | * </tr> |
Kojto | 111:4336505e4b1c | 370 | * <tr> |
Kojto | 111:4336505e4b1c | 371 | * <td>Initial Release</td> |
Kojto | 111:4336505e4b1c | 372 | * </tr> |
Kojto | 111:4336505e4b1c | 373 | * </table> |
Kojto | 111:4336505e4b1c | 374 | */ |
Kojto | 111:4336505e4b1c | 375 | |
Kojto | 111:4336505e4b1c | 376 | /** |
Kojto | 111:4336505e4b1c | 377 | * \page asfdoc_sam0_system_interrupt_exqsg Examples for SYSTEM INTERRUPT Driver |
Kojto | 111:4336505e4b1c | 378 | * |
Kojto | 111:4336505e4b1c | 379 | * This is a list of the available Quick Start guides (QSGs) and example |
Kojto | 111:4336505e4b1c | 380 | * applications for \ref asfdoc_sam0_system_interrupt_group. QSGs are simple examples with |
Kojto | 111:4336505e4b1c | 381 | * step-by-step instructions to configure and use this driver in a selection of |
Kojto | 111:4336505e4b1c | 382 | * use cases. Note that QSGs can be compiled as a standalone application or be |
Kojto | 111:4336505e4b1c | 383 | * added to the user application. |
Kojto | 111:4336505e4b1c | 384 | * |
Kojto | 111:4336505e4b1c | 385 | * - \subpage asfdoc_sam0_system_interrupt_critsec_use_case |
Kojto | 111:4336505e4b1c | 386 | * - \subpage asfdoc_sam0_system_interrupt_enablemodint_use_case |
Kojto | 111:4336505e4b1c | 387 | * |
Kojto | 111:4336505e4b1c | 388 | * \page asfdoc_sam0_system_interrupt_document_revision_history Document Revision History |
Kojto | 111:4336505e4b1c | 389 | * |
Kojto | 111:4336505e4b1c | 390 | * <table> |
Kojto | 111:4336505e4b1c | 391 | * <tr> |
Kojto | 111:4336505e4b1c | 392 | * <th>Doc. Rev.</td> |
Kojto | 111:4336505e4b1c | 393 | * <th>Date</td> |
Kojto | 111:4336505e4b1c | 394 | * <th>Comments</td> |
Kojto | 111:4336505e4b1c | 395 | * </tr> |
Kojto | 111:4336505e4b1c | 396 | * <tr> |
Kojto | 111:4336505e4b1c | 397 | * <td>E</td> |
Kojto | 111:4336505e4b1c | 398 | * <td>06/2015</td> |
Kojto | 111:4336505e4b1c | 399 | * <td>Add support for SAML21, SAMDAx, and SAMC20/C21.</td> |
Kojto | 111:4336505e4b1c | 400 | * </tr> |
Kojto | 111:4336505e4b1c | 401 | * <tr> |
Kojto | 111:4336505e4b1c | 402 | * <td>D</td> |
Kojto | 111:4336505e4b1c | 403 | * <td>12/2014</td> |
Kojto | 111:4336505e4b1c | 404 | * <td>Add support for SAMR21 and SAMD10/D11.</td> |
Kojto | 111:4336505e4b1c | 405 | * </tr> |
Kojto | 111:4336505e4b1c | 406 | * <tr> |
Kojto | 111:4336505e4b1c | 407 | * <td>C</td> |
Kojto | 111:4336505e4b1c | 408 | * <td>01/2014</td> |
Kojto | 111:4336505e4b1c | 409 | * <td>Add support for SAMD21.</td> |
Kojto | 111:4336505e4b1c | 410 | * </tr> |
Kojto | 111:4336505e4b1c | 411 | * <tr> |
Kojto | 111:4336505e4b1c | 412 | * <td>B</td> |
Kojto | 111:4336505e4b1c | 413 | * <td>06/2013</td> |
Kojto | 111:4336505e4b1c | 414 | * <td>Corrected documentation typos.</td> |
Kojto | 111:4336505e4b1c | 415 | * </tr> |
Kojto | 111:4336505e4b1c | 416 | * <tr> |
Kojto | 111:4336505e4b1c | 417 | * <td>A</td> |
Kojto | 111:4336505e4b1c | 418 | * <td>06/2013</td> |
Kojto | 111:4336505e4b1c | 419 | * <td>Initial release</td> |
Kojto | 111:4336505e4b1c | 420 | * </tr> |
Kojto | 111:4336505e4b1c | 421 | * </table> |
Kojto | 111:4336505e4b1c | 422 | */ |
Kojto | 111:4336505e4b1c | 423 | |
Kojto | 111:4336505e4b1c | 424 | #ifdef __cplusplus |
Kojto | 111:4336505e4b1c | 425 | } |
Kojto | 111:4336505e4b1c | 426 | #endif |
Kojto | 111:4336505e4b1c | 427 | |
Kojto | 111:4336505e4b1c | 428 | #endif // #ifndef SYSTEM_INTERRUPT_H_INCLUDED |