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