]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/Core/src/Ref_NVIC.txt
Scatter file for RTOS_Faults example added. Corrections in CMSIS-Core documentation
[cmsis] / CMSIS / DoxyGen / Core / src / Ref_NVIC.txt
1 /**
2 \defgroup   NVIC_gr  Interrupts and Exceptions (NVIC)
3   @{
4 \brief      Functions to access the Nested Vector Interrupt Controller (NVIC).
5 \details
6 This section explains how to use interrupts and exceptions and access functions for the Nested Vector Interrupt Controller (NVIC).
7
8 ARM provides a template file <strong>startup_<em>device</em></strong> for each supported
9 compiler. The file must be adapted by the silicon vendor to include interrupt vectors for all device-specific 
10 interrupt handlers. Each interrupt handler is defined as a <strong><em>weak</em></strong> function 
11 to an dummy handler. These interrupt handlers can be used directly in application software 
12 without being adapted by the programmer.
13
14 The table below lists the core exception vectors of the various Cortex-M processors.
15
16 <table class="cmtable" summary="Core Exception Name">
17     <tr>
18       <th>Exception Vector</th>
19       <th>IRQn<br/>Value</th>
20       <th>M0</th>
21       <th>M0+</th>
22       <th>M3</th>
23       <th>M4</th>
24       <th>M7</th>
25       <th>SC000</th>
26       <th>SC300</th>
27       <th>ARMv8-M<br/>Baseline</th>
28       <th>ARMv8-M<br/>Mainline</th>
29       <th>Description</th>
30     </tr>
31     <tr>
32       <td><b>NonMaskableInt_IRQn</b></td>
33       <td>-14</td>
34       <td><img src="check.png" alt="available"></td>
35       <td><img src="check.png" alt="available"></td>
36       <td><img src="check.png" alt="available"></td>
37       <td><img src="check.png" alt="available"></td>
38       <td><img src="check.png" alt="available"></td>
39       <td><img src="check.png" alt="available"></td>
40       <td><img src="check.png" alt="available"></td>
41       <td><img src="check.png" alt="available"></td>
42       <td><img src="check.png" alt="available"></td>
43       <td>Non Maskable Interrupt</td>
44     </tr>
45     <tr>
46       <td><b>HardFault_IRQn</b></td>
47       <td>-13</td>
48       <td><img src="check.png" alt="available"></td>
49       <td><img src="check.png" alt="available"></td>
50       <td><img src="check.png" alt="available"></td>
51       <td><img src="check.png" alt="available"></td>
52       <td><img src="check.png" alt="available"></td>
53       <td><img src="check.png" alt="available"></td>
54       <td><img src="check.png" alt="available"></td>
55       <td><img src="check.png" alt="available"></td>
56       <td><img src="check.png" alt="available"></td>
57       <td>Hard Fault Interrupt</td>
58     </tr>
59     <tr>
60       <td><b>MemoryManagement_IRQn</b></td>
61       <td>-12</td>
62       <td>&nbsp;</td>
63       <td>&nbsp;</td>
64       <td><img src="check.png" alt="available"></td>
65       <td><img src="check.png" alt="available"></td>
66       <td><img src="check.png" alt="available"></td>
67       <td>&nbsp;</td>
68       <td><img src="check.png" alt="available"></td>
69       <td>&nbsp;</td>
70       <td><img src="check.png" alt="available"></td>
71       <td>Memory Management Interrupt</td>
72     </tr>
73     <tr>
74       <td><b>BusFault_IRQn</b></td>
75       <td>-11</td>
76       <td>&nbsp;</td>
77       <td>&nbsp;</td>
78       <td><img src="check.png" alt="available"></td>
79       <td><img src="check.png" alt="available"></td>
80       <td><img src="check.png" alt="available"></td>
81       <td>&nbsp;</td>
82       <td><img src="check.png" alt="available"></td>
83       <td>&nbsp;</td>
84       <td><img src="check.png" alt="available"></td>
85       <td>Bus Fault Interrupt</td>
86     </tr>
87     <tr>
88       <td><b>UsageFault_IRQn</b></td>
89       <td>-10</td>
90       <td>&nbsp;</td>
91       <td>&nbsp;</td>
92       <td><img src="check.png" alt="available"></td>
93       <td><img src="check.png" alt="available"></td>
94       <td><img src="check.png" alt="available"></td>
95       <td>&nbsp;</td>
96       <td><img src="check.png" alt="available"></td>
97       <td>&nbsp;</td>
98       <td><img src="check.png" alt="available"></td>
99       <td>Usage Fault Interrupt</td>
100     </tr>
101     <tr>
102       <td><b>SecureFault_IRQn</b></td>
103       <td>-9</td>
104       <td>&nbsp;</td>
105       <td>&nbsp;</td>
106       <td>&nbsp;</td>
107       <td>&nbsp;</td>
108       <td>&nbsp;</td>
109       <td>&nbsp;</td>
110       <td>&nbsp;</td>
111       <td><img src="check.png" alt="available"></td>
112       <td><img src="check.png" alt="available"></td>
113       <td>Secure Fault Interrupt</td>
114     </tr>
115     <tr>
116       <td><b>SVCall_IRQn</b></td>
117       <td>-5</td>
118       <td><img src="check.png" alt="available"></td>
119       <td><img src="check.png" alt="available"></td>
120       <td><img src="check.png" alt="available"></td>
121       <td><img src="check.png" alt="available"></td>
122       <td><img src="check.png" alt="available"></td>
123       <td><img src="check.png" alt="available"></td>
124       <td><img src="check.png" alt="available"></td>
125       <td><img src="check.png" alt="available"></td>
126       <td><img src="check.png" alt="available"></td>
127       <td>SV Call Interrupt </td>
128     </tr>
129     <tr>
130       <td><b>DebugMonitor_IRQn</b></td>
131       <td>-4</td>
132       <td>&nbsp;</td>
133       <td>&nbsp;</td>
134       <td><img src="check.png" alt="available"></td>
135       <td><img src="check.png" alt="available"></td>
136       <td><img src="check.png" alt="available"></td>
137       <td>&nbsp;</td>
138       <td><img src="check.png" alt="available"></td>
139       <td>&nbsp;</td>
140       <td><img src="check.png" alt="available"></td>
141       <td>Debug Monitor Interrupt</td>
142     </tr>
143     <tr>
144       <td><b>PendSV_IRQn</b></td>
145       <td>-2</td>
146       <td><img src="check.png" alt="available"></td>
147       <td><img src="check.png" alt="available"></td>
148       <td><img src="check.png" alt="available"></td>
149       <td><img src="check.png" alt="available"></td>
150       <td><img src="check.png" alt="available"></td>
151       <td><img src="check.png" alt="available"></td>
152       <td><img src="check.png" alt="available"></td>
153       <td><img src="check.png" alt="available"></td>
154       <td><img src="check.png" alt="available"></td>
155       <td>Pend SV Interrupt</td>
156     </tr>
157     <tr>
158       <td><b>SysTick_IRQn</b></td>
159       <td>-1</td>
160       <td><img src="check.png" alt="available"></td>
161       <td><img src="check.png" alt="available"></td>
162       <td><img src="check.png" alt="available"></td>
163       <td><img src="check.png" alt="available"></td>
164       <td><img src="check.png" alt="available"></td>
165       <td><img src="check.png" alt="available"></td>
166       <td><img src="check.png" alt="available"></td>
167       <td><img src="check.png" alt="available"></td>
168       <td><img src="check.png" alt="available"></td>
169       <td>System Tick Interrupt</td>
170     </tr>
171 </table>
172
173
174 Vector Table 
175 ============
176 The Vector Table defines the entry addresses of the processor exceptions and the
177 device specific interrupts.  It is typically located at the beginning of the 
178 program memory, however \ref using_VTOR_pg it can be relocated to RAM.  The symbol 
179 <b>__Vectors</b> is the address of the vector table in the startup code and the
180 register <b>SCB->VTOR</b> holds the start address of the vector table. 
181
182 An ARMv8-M implementation with TrustZone provides two vector tables: 
183   - vector table for Secure handlers
184   - vector table for Non-Secure handlers
185
186 Refer to \ref Model_TrustZone for more information.
187
188 Processor Exceptions
189 --------------------
190 At the beginning of the vector table, the initial stack value and the 
191 exception vectors of the processor are defined. The vector table below 
192 shows the exception vectors of a ARMv8-M Mainline processor. Other processor
193 variants may have fewer vectors.
194
195 \code
196 __Vectors       DCD     __initial_sp              ; Top of Stack initialization
197                 DCD     Reset_Handler             ; Reset Handler
198                 DCD     NMI_Handler               ; NMI Handler
199                 DCD     HardFault_Handler         ; Hard Fault Handler
200                 DCD     MemManage_Handler         ; MPU Fault Handler
201                 DCD     BusFault_Handler          ; Bus Fault Handler
202                 DCD     UsageFault_Handler        ; Usage Fault Handler
203                 DCD     SecureFault_Handler       ; Secure Fault Handler
204                 DCD     0                         ; Reserved
205                 DCD     0                         ; Reserved
206                 DCD     0                         ; Reserved
207                 DCD     SVC_Handler               ; SVCall Handler
208                 DCD     DebugMon_Handler          ; Debug Monitor Handler
209                 DCD     0                         ; Reserved
210                 DCD     PendSV_Handler            ; PendSV Handler
211                 DCD     SysTick_Handler           ; SysTick Handler
212 \endcode
213
214
215 Device Specific Vectors
216 -----------------------
217 Following the processor exception vectors, the vector table contains also the
218 device specific interrupt vectors.
219
220 \code
221 ; device specific interrupts
222                 DCD     WWDG_IRQHandler           ; Window Watchdog
223                 DCD     PVD_IRQHandler            ; PVD through EXTI Line detect
224                 DCD     TAMPER_IRQHandler         ; Tamper
225 \endcode
226
227 All device specific interrupts should have a default interrupt handler function that can 
228 be overwritten in user code. Below is an example for this default handler function.
229
230 \code
231 Default_Handler PROC
232                 EXPORT WWDG_IRQHandler   [WEAK]
233                 EXPORT PVD_IRQHandler    [WEAK]
234                 EXPORT TAMPER_IRQHandler [WEAK]
235                 :
236                 :
237                 WWDG_IRQHandler
238                 PVD_IRQHandler
239                 TAMPER_IRQHandler
240                 :
241                 :
242                 B .
243                 ENDP
244 \endcode
245                 
246
247 The user application may simply define an interrupt handler function by using the handler name
248 as shown below.
249
250 \code
251 void WWDG_IRQHandler(void)
252 {
253   ...
254 }
255 \endcode
256
257 NVIC Function Usage
258 ===================
259 The code below shows the usage of various CMSIS NVIC functions with an LPC1700 device.
260
261 Code Example 1
262 --------------  
263 \code
264 #include "LPC17xx.h"
265  
266 uint32_t priorityGroup;                                     /* Variables to store priority group and priority */
267 uint32_t priority;
268 uint32_t preemptPriority;
269 uint32_t subPriority;
270  
271 int main (void)  {
272   NVIC_SetPriorityGrouping(5);                              /* Set priority group to 5:
273                                                                Bit[7..6] preempt priority Bits, 
274                                                                Bit[5..3] subpriority Bits 
275                                                                (valid for five priority bits) */
276      
277   priorityGroup =  NVIC_GetPriorityGrouping();              /* Get used priority grouping */
278  
279   priority = NVIC_EncodePriority(priorityGroup, 1, 6);      /* Encode priority with 6 for subpriority and 1 for preempt priority
280                                                                Note: priority depends on the used priority grouping */
281   NVIC_SetPriority(UART0_IRQn, priority);                   /* Set new priority */
282  
283   priority =  NVIC_GetPriority(UART0_IRQn);                 /* Retrieve priority again */    
284   NVIC_DecodePriority(priority, priorityGroup, &preemptPriority, &subPriority);
285  
286   while(1);
287 }
288 \endcode
289
290
291 Code Example 2
292 --------------
293 \code
294 #include "LPC17xx.h"
295  
296 uint32_t active;                                            /* Variable to store interrupt active state */
297  
298 void TIMER0_IRQHandler(void)  {                             /* Timer 0 interrupt handler  */
299  
300   if (LPC_TIM0->IR & (1 << 0))  {                           /* Check if interrupt for match channel 0 occured */ 
301     LPC_TIM0->IR |= (1 << 0);                               /* Acknowledge interrupt for match channel 0 occured */
302   }
303   active = NVIC_GetActive(TIMER0_IRQn);                     /* Get interrupt active state of timer 0 */
304 }
305  
306 int main (void) {
307                                                             /* Set match channel register MR0 to 1 millisecond */
308   LPC_TIM0->MR0 = (((SystemCoreClock / 1000) / 4) - 1);     /* 1 ms? */
309    
310   LPC_TIM0->MCR = (3 << 0);                                 /* Enable interrupt and reset for match channel MR0 */
311   NVIC_EnableIRQ(TIMER0_IRQn);                              /* Enable NVIC interrupt for timer 0 */
312   LPC_TIM0->TCR = (1 << 0);                                 /* Enable timer 0 */
313  
314   while(1);
315 }
316 \endcode
317
318
319 NVIC API Virtualization
320 =======================
321 The CMSIS-Core has provisions for overriding NVIC APIs as required for implementing
322 secure systems that control access to peripherals and related interrupts.
323 These overrides allow an operating system to control the access privileges of
324 application code to critical interrupts.
325
326 The NVIC function virtualization is enabled with the following \#define symbols:
327   - \ref CMSIS_NVIC_VIRTUAL enables overriding the CMSIS-CORE NVIC functions.
328   - \ref CMSIS_VECTAB_VIRTUAL enables overriding the CMSIS-CORE interrupt vector table access functions.
329
330 */     
331
332 #define CMSIS_NVIC_VIRTUAL   ///< Virtualization of the NVIC API
333 /**
334 \def CMSIS_NVIC_VIRTUAL
335 When \ref CMSIS_NVIC_VIRTUAL is defined, the NVIC access functions in the table below must be implemented
336 for virtualizing NVIC access.  These functions should be implemented
337 in a separate source module.
338 The original CMSIS-Core __NVIC functions are always available independent of \ref CMSIS_NVIC_VIRTUAL.
339
340 NVIC Access Functions     | CMSIS-Core Functions
341 --------------------------|---------------------------------------------
342 NVIC_EnableIRQ            | __NVIC_EnableIRQ
343 NVIC_GetEnableIRQ         | __NVIC_GetEnableIRQ
344 NVIC_DisableIRQ           | __NVIC_DisableIRQ
345 NVIC_GetPendingIRQ        | __NVIC_GetPendingIRQ
346 NVIC_SetPendingIRQ        | __NVIC_SetPendingIRQ
347 NVIC_ClearPendingIRQ      | __NVIC_ClearPendingIRQ
348 NVIC_GetActive            | __NVIC_GetActive
349 NVIC_SetPriority          | __NVIC_SetPriority
350 NVIC_GetPriority          | __NVIC_GetPriority
351 NVIC_SetPriorityGrouping  | __NVIC_SetPriorityGrouping
352 NVIC_GetPriorityGrouping  | __NVIC_GetPriorityGrouping
353 */     
354
355 #define CMSIS_VECTAB_VIRTUAL   ///< Virtualization of interrupt vector table access functions
356 /**
357
358 \def CMSIS_VECTAB_VIRTUAL
359 When \ref CMSIS_NVIC_VIRTUAL is defined, the functions in the table below must be replaced 
360 to virtualize the API access functions to the interrupt vector table. The NVIC vector table API should be implemented
361 in a separate source module. This allows, for example, alternate implementations to relocate the vector table from flash to RAM on the first vector table update.
362
363 The original CMSIS-Core functions are always available, but prefixed with __NVIC.
364
365 Interrupt Vector Table Access  | CMSIS-Core Functions
366 -------------------------------|---------------------------------------------
367 NVIC_GetVector                 | __NVIC_GetVector
368 NVIC_SetVector                 | __NVIC_SetVector
369
370 */     
371
372
373 /**************************************************************************************************/
374 /** \brief  Definition of IRQn numbers
375
376
377 The core exception enumeration names for IRQn values are defined in the file \b device.h.
378
379  - Negative IRQn values represent processor core exceptions (internal interrupts).
380  - Positive IRQn values represent device-specific exceptions (external interrupts). 
381  - The first device-specific interrupt has the IRQn value 0.
382
383 The table below describes the core exception names and their availability in various Cortex-M cores.
384 */
385 typedef enum IRQn
386 {
387 /******  Cortex-M3 Processor Exceptions/Interrupt Numbers     **************************/
388   NonMaskableInt_IRQn      = -14,      ///<  Exception 2: Non Maskable Interrupt
389   HardFault_IRQn           = -13,      ///<  Exception 3: Hard Fault Interrupt
390   MemoryManagement_IRQn    = -12,      ///<  Exception 4: Memory Management Interrupt [not on Cortex-M0 variants]
391   BusFault_IRQn            = -11,      ///<  Exception 5: Bus Fault Interrupt [not on Cortex-M0 variants]
392   UsageFault_IRQn          = -10,      ///<  Exception 6: Usage Fault Interrupt [not on Cortex-M0 variants]
393   SecureFault_IRQn         = -9,       ///<  Exception 7: Secure Fault Interrupt [only on ARMv8-M]
394   SVCall_IRQn              = -5,       ///<  Exception 11: SV Call Interrupt
395   DebugMonitor_IRQn        = -4,       ///<  Exception 12: Debug Monitor Interrupt [not on Cortex-M0 variants]
396   PendSV_IRQn              = -2,       ///<  Exception 14: Pend SV Interrupt [not on Cortex-M0 variants]
397   SysTick_IRQn             = -1,       ///<  Exception 15: System Tick Interrupt
398 /******  Device-specific Interrupt Numbers     *****************************************/
399   WWDG_STM_IRQn            = 0,        ///<  Device Interrupt 0: Window WatchDog Interrupt
400   PVD_STM_IRQn             = 1,        ///<  Device Interrupt 1: PVD through EXTI Line detection Interrupt
401  } IRQn_Type;
402
403 /**************************************************************************************************/
404 /** \brief  Set priority grouping [not for Cortex-M0, Cortex-M0+, or SC000]
405
406   The function sets the priority grouping \em PriorityGroup using the required unlock sequence.
407   \em PriorityGroup is assigned to the field PRIGROUP (register AIRCR[10:8]). This field
408   determines the split of group priority from subpriority.
409   Only values from 0..7 are used.
410   In case of a conflict between priority grouping and available
411   priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set.
412
413     \param [in]      PriorityGroup  Priority group
414     
415     \remarks
416         - not for Cortex-M0, Cortex-M0+, or SC000.
417         - By default, priority group setting is zero.
418         
419     \sa 
420         - \ref NVIC_GetPriorityGrouping; NVIC_SetPriority; SCB_Type
421         - \ref ref_man_sec
422 */
423 void NVIC_SetPriorityGrouping(uint32_t PriorityGroup);
424
425
426 /**************************************************************************************************/
427 /** 
428     \brief  Read the priority grouping [not for Cortex-M0, Cortex-M0+, or SC000]
429
430   This function returns the priority grouping (flag PRIGROUP in AIRCR[10:8]).
431
432     \return                Priority grouping field
433
434     \remarks
435         - not for Cortex-M0, Cortex-M0+, or SC000.
436         - By default, priority group setting is zero.
437         
438     \sa 
439         - \ref NVIC_SetPriorityGrouping; NVIC_GetPriority; SCB_Type
440         - \ref ref_man_sec
441     
442 */
443 uint32_t NVIC_GetPriorityGrouping(void);
444
445
446 /**************************************************************************************************/
447 /** 
448     \brief  Enable a device specific interrupt
449
450     This function enables the specified device specific interrupt \em IRQn. 
451     \em IRQn cannot be a negative value. 
452
453     \param [in]      IRQn  Interrupt number
454
455     \remarks
456         - IRQn must not be negative.
457         - The registers that control the enabling and disabling of interrupts are called
458         SETENA and CLRENA.
459         - The number of supported interrupts depends on the implementation of the chip designer
460         and can be read form the Interrupt Controller Type Register (ICTR) in granularities of 32: 
461         \n ICTR[4:0] 
462                 - 0 - 32 interrupts supported
463                 - 1 - 64 interrupts supported
464                 - ...
465         
466     \sa     
467         - \ref NVIC_DisableIRQ; SCnSCB_Type;
468         - \ref ref_man_sec
469 */
470 void NVIC_EnableIRQ(IRQn_Type IRQn);
471
472
473 /**************************************************************************************************/
474 /** 
475     \brief  Get a device specific interrupt enable status
476
477     This function returns the interrupt enable status for the specified device specific interrupt \em IRQn. 
478     \em IRQn cannot be a negative value. 
479
480     \param [in]      IRQn  Interrupt number
481     
482     \returns    
483             - 0  Interrupt is not enabled
484             - 1  Interrupt is pending
485
486     \remarks
487         - IRQn must not be negative.
488         - The registers that control the enabling and disabling of interrupts are called SETENA and CLRENA.
489         
490     \sa     
491         - \ref NVIC_EnableIRQ; NVIC_DisableIRQ;
492         - \ref ref_man_sec
493 */
494 uint32_t NVIC_GetEnableIRQ(IRQn_Type IRQn);
495
496
497 /**************************************************************************************************/
498 /** 
499     \brief  Disable a device specific interrupt
500
501     This function disables the specified device specific interrupt \em IRQn. 
502     \em IRQn cannot be a negative value. 
503
504     \param [in]      IRQn  Number of the external interrupt to disable
505
506     \remarks
507         - IRQn must not be negative.
508         - The registers that control the enabling and disabling of interrupts are called
509         SETENA and CLRENA.
510         
511     \sa     
512         - \ref NVIC_EnableIRQ
513         - \ref ref_man_sec
514 */
515 void NVIC_DisableIRQ(IRQn_Type IRQn);
516
517
518 /**************************************************************************************************/
519 /** 
520     \brief  Get the pending device specific interrupt
521
522     This function returns the pending status of the specified device specific interrupt \em IRQn. 
523
524     \param [in]      IRQn  Interrupt number
525     
526     \returns    
527             - 0  Interrupt is not pending
528             - 1  Interrupt is pending
529             
530     \remarks
531         - IRQn must not be negative.
532         - The registers that control the status of interrupts are called SETPEND and CLRPEND.
533
534     \sa     
535         - \ref NVIC_SetPendingIRQ; NVIC_ClearPendingIRQ
536         - \ref ref_man_sec
537 */
538 uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn);
539
540
541 /**************************************************************************************************/
542 /** 
543     \brief  Set a device specific interrupt to pending
544
545     This function sets the pending bit for the specified device specific interrupt \em IRQn.
546     \em IRQn cannot be a negative value.
547
548     \param [in]      IRQn  Interrupt number 
549     
550     \remarks
551         - IRQn must not be negative.
552         - The registers that control the status of interrupts are called SETPEND and CLRPEND.
553
554     \sa     
555         - \ref NVIC_GetPendingIRQ; NVIC_ClearPendingIRQ
556         - \ref ref_man_sec
557 */
558 void NVIC_SetPendingIRQ(IRQn_Type IRQn);
559
560
561 /**************************************************************************************************/
562 /** 
563     \brief  Clear a device specific interrupt from pending  
564     
565     This function removes the pending state of the specified device specific interrupt \em IRQn. 
566     \em IRQn cannot be a negative number.
567
568     \param [in]      IRQn  Interrupt number
569     
570     \remarks
571         - IRQn must not be negative.
572         - The registers that control the status of interrupts are called SETPEND and CLRPEND.
573         - An interrupt can have the status pending though it is not active.
574         
575     \sa     
576         - \ref NVIC_SetPendingIRQ; NVIC_GetPendingIRQ
577         - \ref ref_man_sec
578 */
579 void NVIC_ClearPendingIRQ(IRQn_Type IRQn);
580
581
582 /**************************************************************************************************/
583 /** 
584     \brief  Get the device specific interrupt active status [not for Cortex-M0, Cortex-M0+, or SC000]
585
586     This function reads the Interrupt Active Register (NVIC_IABR0-NVIC_IABR7) in NVIC and 
587     returns the active bit of the interrupt \em IRQn.
588     
589     \param [in]      IRQn  Interrupt number
590
591     \returns            
592         - 0  Interrupt is not active
593         - 1  Interrupt is active, or active and pending
594     
595     \remarks
596         - not for Cortex-M0, Cortex-M0+, or SC000.
597         - IRQn must not be negative.
598         - Each external interrupt has an active status bit. When the processor starts the interrupt 
599         handler the bit is set to 1 and cleared when the interrupt return is executed.
600         - When an ISR is preempted and the processor executes anohter interrupt handler, the 
601         previous interrupt is still defined as active.
602     
603     \sa     
604         - \ref ref_man_sec
605     
606 */
607 uint32_t NVIC_GetActive(IRQn_Type IRQn);
608
609
610 /**************************************************************************************************/
611 /** 
612     \brief  Set the priority for an interrupt
613
614     Sets the priority for the interrupt specified by \em IRQn.\em IRQn can can specify any 
615     device specific interrupt, or processor exception. The \em priority specifies 
616     the interrupt priority value, whereby lower values indicate a higher priority. The default 
617     priority is 0 for every interrupt. This is the highest possible priority.
618
619     The priority cannot be set for every core interrupt. HardFault and NMI have a fixed (negative) 
620     priority that is higher than any configurable exception or interrupt.
621
622     \param [in]      IRQn  Interrupt Number
623     \param [in]  priority  Priority to set
624
625     \remarks   
626     - The number of priority levels is configurable and depends on the implementation of the 
627     chip designer. To determine the number of bits implemented for interrupt priority-level 
628     registers, write \em 0xFF to one of the priority-level register, then read back the value. For 
629     example, if the minimum number of 3 bits have been implemented, the read-back value is \em 0xE0.
630     - Writes to unimplemented bits are ignored.
631     - <b>For Cortex-M0</b>: 
632         - Dynamic switching of interrupt priority levels is not supported. The priority level of 
633         an interrupt should not be changed after it has been enabled. 
634         - Supports 0 to 192 priority levels.
635         - Priority-level registers are 2 bit wide, occupying the two MSBs. 
636         Each Interrupt Priority Level Register is 1-byte wide.
637     - <b>For Cortex-M3, Cortex-M4, and Cortex-M7</b>: 
638         - Dynamic switching of interrupt priority levels is supported.
639         - Supports 0 to 255 priority levels.
640         - Priority-level registers have a maximum width of 8 bits and a minumum of 3 bits.
641         Each register can be further devided into preempt priority level and subpriority level.
642         
643     \sa     
644         - \ref NVIC_GetPriority;  NVIC_SetPriorityGrouping; __set_BASEPRI;
645         - \ref ref_man_sec
646 */
647 void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority);
648
649
650 /**************************************************************************************************/
651 /** 
652     \brief  Get the priority of an interrupt
653
654     This function reads the priority for the specified interrupt \em IRQn. \em IRQn can can specify 
655     any device specific interrupt, or processor exception.
656
657     The returned priority value is automatically aligned to the implemented
658     priority bits of the microcontroller.
659
660     \param [in]   IRQn  Interrupt number
661     
662     \returns            Interrupt priority
663
664     \remarks
665     - Each external interrupt has an associated priority-level register. 
666     - Unimplemented bits are read as zero.
667
668     \sa     
669         - \ref NVIC_SetPriority;  NVIC_GetPriorityGrouping; __get_BASEPRI;
670         - \ref ref_man_sec
671 */
672 uint32_t NVIC_GetPriority(IRQn_Type IRQn);
673
674
675 /**************************************************************************************************/
676 /** 
677     \brief  Encodes Priority [not for Cortex-M0, Cortex-M0+, or SC000]
678
679     This function encodes the priority for an interrupt with the priority group \em PriorityGroup,
680     preemptive priority value \em PreemptPriority, and subpriority value \em SubPriority.
681     In case of a conflict between priority grouping and available
682     priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.
683  
684     \param [in]     PriorityGroup  Priority group
685     \param [in]   PreemptPriority  Preemptive priority value (starting from 0)
686     \param [in]       SubPriority  Subpriority value (starting from 0)
687
688     \returns                        Encoded priority for the interrupt
689
690     
691     \remarks
692     - not for Cortex-M0, Cortex-M0+, or SC000.
693     
694     \sa     
695         - \ref NVIC_DecodePriority;  NVIC_SetPriority; 
696         - \ref ref_man_sec
697 */
698 uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority);
699
700
701 /**************************************************************************************************/
702 /** 
703     \brief  Decode the interrupt priority [not for Cortex-M0, Cortex-M0+, or SC000]
704
705     This function decodes an interrupt priority value with the priority group \em PriorityGroup to 
706     preemptive priority value \em pPreemptPriority and subpriority value \em pSubPriority.
707     In case of a conflict between priority grouping and available
708     priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.
709  
710     \param [in]         Priority    Priority 
711     \param [in]     PriorityGroup   Priority group
712     \param [out] *pPreemptPriority  Preemptive priority value (starting from 0)
713     \param [out]     *pSubPriority  Subpriority value (starting from 0)
714
715     
716     \remarks
717     - not for Cortex-M0, Cortex-M0+, or SC000.
718     
719     \sa     
720         - \ref NVIC_EncodePriority;  NVIC_GetPriority; NVIC_GetPriorityGrouping;
721         - \ref ref_man_sec
722 */
723 void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority);
724
725
726 /**************************************************************************************************/
727 /** 
728     \brief  Read Interrupt Vector [not for Cortex-M0, SC000]
729
730     This function allows to read the address of an interrupt handler function.
731
732     \param [in]      IRQn  Interrupt number
733
734     \returns               Address of interrupt handler function
735     
736     \remarks
737                 - For using this function with Cortex-M0+ processor based devices, the SBC->VTOR register must be implemented.
738         
739     \sa     
740         - \ref NVIC_SetVector
741         - \ref ref_man_sec
742 */
743 uint32_t NVIC_GetVector(IRQn_Type IRQn);
744
745
746 /**************************************************************************************************/
747 /** 
748     \brief  Modify Interrupt Vector [not for Cortex-M0, SC000]
749
750     This function allows to change the address of an interrupt handler function.
751
752     \param [in]      IRQn  Interrupt number
753     \param [in]    vector  Address of new interrupt handler function
754     
755     \remarks
756         - Usage of this function requires vector relocation to RAM. Refer to \ref using_VTOR_pg for more information.
757                 - For using this function with Cortex-M0+ processor based devices, the SBC->VTOR register must be implemented.
758         
759     \sa     
760         - \ref NVIC_GetVector
761         - \ref ref_man_sec
762 */
763 void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
764
765
766 /**************************************************************************************************/
767 /** 
768     \brief  Reset the system
769
770     This function requests a system reset by setting the SYSRESETREQ flag in the AIRCR register.
771     
772     \remarks
773         - In most microcontroller designs, setting the SYSRESETREQ flag resets the processor and 
774         most parts of the system, but should not affect the debug system.
775         
776     \sa     
777         - \ref ref_man_sec
778 */
779 void NVIC_SystemReset (void);
780
781
782 /**
783   \brief   Get Interrupt Target State
784   \details Reads the interrupt target field from the non-secure NVIC when in secure state.
785   \param [in]      IRQn  External interrupt number. Value cannot be negative.
786     \returns            
787         - 0  if interrupt is assigned to Secure
788         - 1  if interrupt is assigned to Non Secure
789     \remarks
790         - Only available for ARMv8-M in secure state.
791         
792     \sa     
793         - \ref NVIC_ClearTargetState; NVIC_SetTargetState;
794  */
795 uint32_t NVIC_GetTargetState(IRQn_Type IRQn);
796
797 /**
798   \brief   Set Interrupt Target State
799   \details Sets the interrupt target field in the non-secure NVIC when in secure state.
800   \param [in]      IRQn  External interrupt number. Value cannot be negative.
801     \returns            
802         - 0  if interrupt is assigned to Secure
803         - 1  if interrupt is assigned to Non Secure
804     \remarks
805         - Only available for ARMv8-M in secure state.
806         
807     \sa     
808         - \ref NVIC_ClearTargetState; NVIC_GetTargetState;
809  */
810 uint32_t NVIC_SetTargetState(IRQn_Type IRQn);
811
812 /**
813   \brief   Clear Interrupt Target State
814   \details Clears the interrupt target field in the non-secure NVIC when in secure state.
815   \param [in]      IRQn  External interrupt number. Value cannot be negative.
816     \returns            
817         - 0  if interrupt is assigned to Secure
818         - 1  if interrupt is assigned to Non Secure
819     \remarks
820         - Only available for ARMv8-M in secure state.
821         
822     \sa     
823         - \ref NVIC_GetTargetState; NVIC_SetTargetState;
824  */
825 uint32_t NVIC_ClearTargetState(IRQn_Type IRQn);
826
827
828 /*@} end of NVIC_gr */
829
830