1 /**
2  * \file
3  *
4  * \brief SAM D21 System Interrupt Driver
5  *
6  * Copyright (C) 2013-2015 Atmel Corporation. All rights reserved.
7  *
8  * \asf_license_start
9  *
10  * \page License
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions are met:
14  *
15  * 1. Redistributions of source code must retain the above copyright notice,
16  *    this list of conditions and the following disclaimer.
17  *
18  * 2. Redistributions in binary form must reproduce the above copyright notice,
19  *    this list of conditions and the following disclaimer in the documentation
20  *    and/or other materials provided with the distribution.
21  *
22  * 3. The name of Atmel may not be used to endorse or promote products derived
23  *    from this software without specific prior written permission.
24  *
25  * 4. This software may only be redistributed and used in connection with an
26  *    Atmel microcontroller product.
27  *
28  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
29  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
31  * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
32  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38  * POSSIBILITY OF SUCH DAMAGE.
39  *
40  * \asf_license_stop
41  *
42  */
43 /*
44  * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
45  */
46 
47 #ifndef SYSTEM_INTERRUPT_FEATURES_H_INCLUDED
48 #define SYSTEM_INTERRUPT_FEATURES_H_INCLUDED
49 
50 #if !defined(__DOXYGEN__)
51 
52 /* Generates a interrupt vector table enum list entry for a given module type
53    and index (e.g. "SYSTEM_INTERRUPT_MODULE_TC0 = TC0_IRQn,"). */
54 #  define _MODULE_IRQn(n, module) \
55 		SYSTEM_INTERRUPT_MODULE_##module##n = module##n##_IRQn,
56 
57 /* Generates interrupt vector table enum list entries for all instances of a
58    given module type on the selected device. */
59 #  define _SYSTEM_INTERRUPT_MODULES(name) \
60 		MREPEAT(name##_INST_NUM, _MODULE_IRQn, name)
61 
62 #  define _SYSTEM_INTERRUPT_IPSR_MASK              0x0000003f
63 #  define _SYSTEM_INTERRUPT_PRIORITY_MASK          0x00000003
64 
65 #  define _SYSTEM_INTERRUPT_EXTERNAL_VECTOR_START  0
66 
67 #  define _SYSTEM_INTERRUPT_SYSTICK_PRI_POS        30
68 #endif
69 
70 /**
71  * \addtogroup asfdoc_sam0_system_interrupt_group
72  * @{
73  */
74 
75 /**
76  * \brief Table of possible system interrupt/exception vector numbers.
77  *
78  * Table of all possible interrupt and exception vector indexes within the
79  * SAM D21 device. Check peripherals configuration in SAM D21 datasheet for
80  * available vector index for specific device.
81  *
82  */
83 #if defined(__DOXYGEN__)
84 /** \note The actual enumeration name is "system_interrupt_vector". */
85 enum system_interrupt_vector_samd21 {
86 #else
87 enum system_interrupt_vector {
88 #endif
89 	/** Interrupt vector index for a NMI interrupt */
90 	SYSTEM_INTERRUPT_NON_MASKABLE      = NonMaskableInt_IRQn,
91 	/** Interrupt vector index for a Hard Fault memory access exception */
92 	SYSTEM_INTERRUPT_HARD_FAULT        = HardFault_IRQn,
93 	/** Interrupt vector index for a Supervisor Call exception */
94 	SYSTEM_INTERRUPT_SV_CALL           = SVCall_IRQn,
95 	/** Interrupt vector index for a Pending Supervisor interrupt */
96 	SYSTEM_INTERRUPT_PENDING_SV        = PendSV_IRQn,
97 	/** Interrupt vector index for a System Tick interrupt */
98 	SYSTEM_INTERRUPT_SYSTICK           = SysTick_IRQn,
99 
100 	/** Interrupt vector index for a Power Manager peripheral interrupt */
101 	SYSTEM_INTERRUPT_MODULE_PM         = PM_IRQn,
102 	/** Interrupt vector index for a System Control peripheral interrupt */
103 	SYSTEM_INTERRUPT_MODULE_SYSCTRL    = SYSCTRL_IRQn,
104 	/** Interrupt vector index for a Watch Dog peripheral interrupt */
105 	SYSTEM_INTERRUPT_MODULE_WDT        = WDT_IRQn,
106 	/** Interrupt vector index for a Real Time Clock peripheral interrupt */
107 	SYSTEM_INTERRUPT_MODULE_RTC        = RTC_IRQn,
108 	/** Interrupt vector index for an External Interrupt peripheral interrupt */
109 	SYSTEM_INTERRUPT_MODULE_EIC        = EIC_IRQn,
110 	/** Interrupt vector index for a Non Volatile Memory Controller interrupt */
111 	SYSTEM_INTERRUPT_MODULE_NVMCTRL    = NVMCTRL_IRQn,
112 	/** Interrupt vector index for a Direct Memory Access interrupt */
113 	SYSTEM_INTERRUPT_MODULE_DMA        = DMAC_IRQn,
114 #if defined(__DOXYGEN__) || defined(ID_USB)
115 	/** Interrupt vector index for a Universal Serial Bus interrupt */
116 	SYSTEM_INTERRUPT_MODULE_USB        = USB_IRQn,
117 #endif
118 	/** Interrupt vector index for an Event System interrupt */
119 	SYSTEM_INTERRUPT_MODULE_EVSYS      = EVSYS_IRQn,
120 #if defined(__DOXYGEN__)
121 	/** Interrupt vector index for a SERCOM peripheral interrupt.
122 	 *
123 	 *  Each specific device may contain several SERCOM peripherals; each module
124 	 *  instance will have its own entry in the table, with the instance number
125 	 *  substituted for "n" in the entry name (e.g.
126 	 *  \c SYSTEM_INTERRUPT_MODULE_SERCOM0).
127 	 */
128 	SYSTEM_INTERRUPT_MODULE_SERCOMn    = SERCOMn_IRQn,
129 
130 	/** Interrupt vector index for a Timer/Counter Control peripheral interrupt.
131 	 *
132 	 *  Each specific device may contain several TCC peripherals; each module
133 	 *  instance will have its own entry in the table, with the instance number
134 	 *  substituted for "n" in the entry name (e.g.
135 	 *  \c SYSTEM_INTERRUPT_MODULE_TCC0).
136 	 */
137 	SYSTEM_INTERRUPT_MODULE_TCCn        = TCCn_IRQn,
138 
139 	/** Interrupt vector index for a Timer/Counter peripheral interrupt.
140 	 *
141 	 *  Each specific device may contain several TC peripherals; each module
142 	 *  instance will have its own entry in the table, with the instance number
143 	 *  substituted for "n" in the entry name (e.g.
144 	 *  \c SYSTEM_INTERRUPT_MODULE_TC3).
145 	 */
146 	SYSTEM_INTERRUPT_MODULE_TCn        = TCn_IRQn,
147 #else
148 	_SYSTEM_INTERRUPT_MODULES(SERCOM)
149 
150 	_SYSTEM_INTERRUPT_MODULES(TCC)
151 
152 	SYSTEM_INTERRUPT_MODULE_TC3        = TC3_IRQn,
153 	SYSTEM_INTERRUPT_MODULE_TC4        = TC4_IRQn,
154 	SYSTEM_INTERRUPT_MODULE_TC5        = TC5_IRQn,
155 #  if defined(ID_TC6)
156 	SYSTEM_INTERRUPT_MODULE_TC6        = TC6_IRQn,
157 #  endif
158 #  if defined(ID_TC7)
159 	SYSTEM_INTERRUPT_MODULE_TC7        = TC7_IRQn,
160 #  endif
161 #endif
162 
163 #if defined(__DOXYGEN__) || defined(ID_ADC)
164 	/** Interrupt vector index for an Analog-to-Digital peripheral interrupt */
165 	SYSTEM_INTERRUPT_MODULE_ADC        = ADC_IRQn,
166 #endif
167 
168 #if defined(__DOXYGEN__) || defined(ID_AC)
169 	/** Interrupt vector index for an Analog Comparator peripheral interrupt */
170 	SYSTEM_INTERRUPT_MODULE_AC         = AC_IRQn,
171 #endif
172 
173 #if defined(__DOXYGEN__) || defined(ID_DAC)
174 	/** Interrupt vector index for a Digital-to-Analog peripheral interrupt */
175 	SYSTEM_INTERRUPT_MODULE_DAC        = DAC_IRQn,
176 #endif
177 #if defined(__DOXYGEN__) || defined(ID_PTC)
178 	/** Interrupt vector index for a Peripheral Touch Controller peripheral
179 	 *  interrupt */
180 	SYSTEM_INTERRUPT_MODULE_PTC        = PTC_IRQn,
181 #endif
182 #if defined(__DOXYGEN__) || defined(ID_I2S)
183 	/** Interrupt vector index for a Inter-IC Sound Interface peripheral
184 	 *  interrupt */
185 	SYSTEM_INTERRUPT_MODULE_I2S        = I2S_IRQn,
186 #endif
187 #if defined(__DOXYGEN__) || defined(ID_AC1)
188 	/** Interrupt vector index for an Analog Comparator 1 peripheral interrupt */
189 	SYSTEM_INTERRUPT_MODULE_AC1        = AC1_IRQn,
190 #endif
191 };
192 
193 /** @} */
194 
195 #endif
196