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