]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M4F_MSP432_LaunchPad_IAR_CCS_Keil/driverlib/interrupt.h
Final V8.2.1 release ready for tagging:
[freertos] / FreeRTOS / Demo / CORTEX_M4F_MSP432_LaunchPad_IAR_CCS_Keil / driverlib / interrupt.h
1 /*
2  * -------------------------------------------
3  *    MSP432 DriverLib - v01_04_00_18 
4  * -------------------------------------------
5  *
6  * --COPYRIGHT--,BSD,BSD
7  * Copyright (c) 2015, Texas Instruments Incorporated
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * *  Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  *
17  * *  Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  *
21  * *  Neither the name of Texas Instruments Incorporated nor the names of
22  *    its contributors may be used to endorse or promote products derived
23  *    from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  * --/COPYRIGHT--*/
37 #ifndef __INTERRUPT_H__
38 #define __INTERRUPT_H__
39
40 //*****************************************************************************
41 //
42 //! \addtogroup interrupt_api
43 //! @{
44 //
45 //*****************************************************************************
46
47
48 //*****************************************************************************
49 //
50 // If building with a C++ compiler, make all of the definitions in this header
51 // have a C binding.
52 //
53 //*****************************************************************************
54 #ifdef __cplusplus
55 extern "C"
56 {
57 #endif
58
59 #include <stdint.h>
60 #include <stdbool.h>
61 #include <msp.h>
62
63 //*****************************************************************************
64 //
65 // Macro to generate an interrupt priority mask based on the number of bits
66 // of priority supported by the hardware.
67 //
68 //*****************************************************************************
69 #define INT_PRIORITY_MASK       ((0xFF << (8 - NUM_PRIORITY_BITS)) & 0xFF)
70 #define NUM_PRIORITY            8
71
72 #define NVIC_APINT_PRIGROUP_M   0x00000700  // Interrupt Priority Grouping
73 #define NVIC_APINT_PRIGROUP_7_1 0x00000000  // Priority group 7.1 split
74 #define NVIC_APINT_PRIGROUP_6_2 0x00000100  // Priority group 6.2 split
75 #define NVIC_APINT_PRIGROUP_5_3 0x00000200  // Priority group 5.3 split
76 #define NVIC_APINT_PRIGROUP_4_4 0x00000300  // Priority group 4.4 split
77 #define NVIC_APINT_PRIGROUP_3_5 0x00000400  // Priority group 3.5 split
78 #define NVIC_APINT_PRIGROUP_2_6 0x00000500  // Priority group 2.6 split
79 #define NVIC_APINT_PRIGROUP_1_7 0x00000600  // Priority group 1.7 split
80 #define NVIC_APINT_PRIGROUP_0_8 0x00000700  // Priority group 0.8 split
81 #define NVIC_SYS_PRI1_R         0xE000ED18  // System Handler Priority 1
82 #define NVIC_SYS_PRI2_R         0xE000ED1C  // System Handler Priority 2
83 #define NVIC_SYS_PRI3_R         0xE000ED20  // System Handler Priority 3
84 #define NVIC_PRI0_R             0xE000E400  // Interrupt 0-3 Priority
85 #define NVIC_PRI1_R             0xE000E404  // Interrupt 4-7 Priority
86 #define NVIC_PRI2_R             0xE000E408  // Interrupt 8-11 Priority
87 #define NVIC_PRI3_R             0xE000E40C  // Interrupt 12-15 Priority
88 #define NVIC_PRI4_R             0xE000E410  // Interrupt 16-19 Priority
89 #define NVIC_PRI5_R             0xE000E414  // Interrupt 20-23 Priority
90 #define NVIC_PRI6_R             0xE000E418  // Interrupt 24-27 Priority
91 #define NVIC_PRI7_R             0xE000E41C  // Interrupt 28-31 Priority
92 #define NVIC_PRI8_R             0xE000E420  // Interrupt 32-35 Priority
93 #define NVIC_PRI9_R             0xE000E424  // Interrupt 36-39 Priority
94 #define NVIC_PRI10_R            0xE000E428  // Interrupt 40-43 Priority
95 #define NVIC_PRI11_R            0xE000E42C  // Interrupt 44-47 Priority
96 #define NVIC_PRI12_R            0xE000E430  // Interrupt 48-51 Priority
97 #define NVIC_PRI13_R            0xE000E434  // Interrupt 52-55 Priority
98 #define NVIC_PRI14_R            0xE000E438  // Interrupt 56-59 Priority
99 #define NVIC_PRI15_R            0xE000E43C  // Interrupt 60-63 Priority
100 #define NVIC_EN0_R              0xE000E100  // Interrupt 0-31 Set Enable
101 #define NVIC_EN1_R              0xE000E104  // Interrupt 32-54 Set Enable
102 #define NVIC_DIS0_R             0xE000E180  // Interrupt 0-31 Clear Enable
103 #define NVIC_DIS1_R             0xE000E184  // Interrupt 32-54 Clear Enable
104 #define NVIC_PEND0_R            0xE000E200  // Interrupt 0-31 Set Pending
105 #define NVIC_PEND1_R            0xE000E204  // Interrupt 32-54 Set Pending
106 #define NVIC_UNPEND0_R          0xE000E280  // Interrupt 0-31 Clear Pending
107 #define NVIC_UNPEND1_R          0xE000E284  // Interrupt 32-54 Clear Pending
108 //*****************************************************************************
109 //
110 // Prototypes for the APIs.
111 //
112 //*****************************************************************************
113
114 //*****************************************************************************
115 //
116 //! Enables the processor interrupt.
117 //!
118 //! This function allows the processor to respond to interrupts.  This function
119 //! does not affect the set of interrupts enabled in the interrupt controller;
120 //! it just gates the single interrupt from the controller to the processor.
121 //!
122 //! \return Returns \b true if interrupts were disabled when the function was
123 //! called or \b false if they were initially enabled.
124 //
125 //*****************************************************************************
126 extern bool Interrupt_enableMaster(void);
127
128 //*****************************************************************************
129 //
130 //! Disables the processor interrupt.
131 //!
132 //! This function prevents the processor from receiving interrupts.  This
133 //! function does not affect the set of interrupts enabled in the interrupt
134 //! controller; it just gates the single interrupt from the controller to the
135 //! processor.
136 //!
137 //! \return Returns \b true if interrupts were already disabled when the
138 //! function was called or \b false if they were initially enabled.
139 //
140 //*****************************************************************************
141 extern bool Interrupt_disableMaster(void);
142
143 //*****************************************************************************
144 //
145 //! Registers a function to be called when an interrupt occurs.
146 //!
147 //! \param interruptNumber specifies the interrupt in question.
148 //! \param intHandler is a pointer to the function to be called.
149 //!
150 //! \note The use of this function (directly or indirectly via a peripheral
151 //! driver interrupt register function) moves the interrupt vector table from
152 //! flash to SRAM.  Therefore, care must be taken when linking the application
153 //! to ensure that the SRAM vector table is located at the beginning of SRAM;
154 //! otherwise the NVIC does not look in the correct portion of memory for the
155 //! vector table (it requires the vector table be on a 1 kB memory alignment).
156 //! Normally, the SRAM vector table is so placed via the use of linker scripts.
157 //! See the discussion of compile-time versus run-time interrupt handler
158 //! registration in the introduction to this chapter.
159 //!
160 //! See \link Interrupt_enableInterrupt \endlink for details about the interrupt
161 //! parameter
162 //!
163 //! \return None.
164 //
165 //*****************************************************************************
166 extern void Interrupt_registerInterrupt(uint32_t interruptNumber,
167         void (*intHandler)(void));
168
169 //*****************************************************************************
170 //
171 //! Unregisters the function to be called when an interrupt occurs.
172 //!
173 //! \param interruptNumber specifies the interrupt in question.
174 //!
175 //! This function is used to indicate that no handler should be called when the
176 //! given interrupt is asserted to the processor.  The interrupt source is
177 //! automatically disabled (via Interrupt_disableInterrupt()) if necessary.
178 //!
179 //! \sa Interrupt_registerInterrupt() for important information about
180 //! registering interrupt handlers.
181 //!
182 //! See \link Interrupt_enableInterrupt \endlink for details about the interrupt
183 //! parameter
184 //!
185 //! \return None.
186 //
187 //*****************************************************************************
188 extern void Interrupt_unregisterInterrupt(uint32_t interruptNumber);
189
190 //*****************************************************************************
191 //
192 //! Sets the priority grouping of the interrupt controller.
193 //!
194 //! \param bits specifies the number of bits of preemptable priority.
195 //!
196 //! This function specifies the split between preemptable priority levels and
197 //! sub-priority levels in the interrupt priority specification.  The range of
198 //! the grouping values are dependent upon the hardware implementation; on
199 //! the MSP432 family, three bits are available for hardware interrupt
200 //! prioritization and therefore priority grouping values of three through
201 //! seven have the same effect.
202 //!
203 //! \return None.
204 //
205 //*****************************************************************************
206 extern void Interrupt_setPriorityGrouping(uint32_t bits);
207
208 //*****************************************************************************
209 //
210 //! Gets the priority grouping of the interrupt controller.
211 //!
212 //! This function returns the split between preemptable priority levels and
213 //! sub-priority levels in the interrupt priority specification.
214 //!
215 //! \return The number of bits of preemptable priority.
216 //
217 //*****************************************************************************
218 extern uint32_t Interrupt_getPriorityGrouping(void);
219
220 //*****************************************************************************
221 //
222 //! Sets the priority of an interrupt.
223 //!
224 //! \param interruptNumber specifies the interrupt in question.
225 //! \param priority specifies the priority of the interrupt.
226 //!
227 //! This function is used to set the priority of an interrupt.  When multiple
228 //! interrupts are asserted simultaneously, the ones with the highest priority
229 //! are processed before the lower priority interrupts.  Smaller numbers
230 //! correspond to higher interrupt priorities; priority 0 is the highest
231 //! interrupt priority.
232 //!
233 //! The hardware priority mechanism only looks at the upper N bits of the
234 //! priority level (where N is 3 for the MSP432 family), so any
235 //! prioritization must be performed in those bits.  The remaining bits can be
236 //! used to sub-prioritize the interrupt sources, and may be used by the
237 //! hardware priority mechanism on a future part.  This arrangement allows
238 //! priorities to migrate to different NVIC implementations without changing
239 //! the gross prioritization of the interrupts.
240 //!
241 //! See \link Interrupt_enableInterrupt \endlink for details about the interrupt
242 //! parameter
243 //!
244 //! \return None.
245 //
246 //*****************************************************************************
247 extern void Interrupt_setPriority(uint32_t interruptNumber, uint8_t priority);
248
249 //*****************************************************************************
250 //
251 //! Gets the priority of an interrupt.
252 //!
253 //! \param interruptNumber specifies the interrupt in question.
254 //!
255 //! This function gets the priority of an interrupt.  See
256 //! Interrupt_setPriority() for a definition of the priority value.
257 //!
258 //! See \link Interrupt_enableInterrupt \endlink for details about the interrupt
259 //! parameter
260 //!
261 //! \return Returns the interrupt priority, or -1 if an invalid interrupt was
262 //! specified.
263 //
264 //*****************************************************************************
265 extern uint8_t Interrupt_getPriority(uint32_t interruptNumber);
266
267 //*****************************************************************************
268 //
269 //! Enables an interrupt.
270 //!
271 //! \param interruptNumber specifies the interrupt to be enabled.
272 //!
273 //! The specified interrupt is enabled in the interrupt controller.  Other
274 //! enables for the interrupt (such as at the peripheral level) are unaffected
275 //! by this function.
276 //!
277 //! Valid values will vary from part to part, so it is important to check the
278 //! device specific datasheet, however for MSP432 101 the following values can
279 //! be provided:
280 //!     - \b FAULT_NMI
281 //!     - \b FAULT_HARD
282 //!     - \b FAULT_MPU
283 //!     - \b FAULT_BUS
284 //!     - \b FAULT_USAGE
285 //!     - \b FAULT_SVCALL
286 //!     - \b FAULT_DEBUG
287 //!     - \b FAULT_PENDSV
288 //!     - \b FAULT_SYSTICK
289 //!     - \b INT_PSS
290 //!     - \b INT_CS
291 //!     - \b INT_PCM
292 //!     - \b INT_WDT_A
293 //!     - \b INT_FPU
294 //!     - \b INT_FLCTL
295 //!     - \b INT_COMP0
296 //!     - \b INT_COMP1
297 //!     - \b INT_TA0_0
298 //!     - \b INT_TA0_N
299 //!     - \b INT_TA1_0
300 //!     - \b INT_TA1_N
301 //!     - \b INT_TA2_0
302 //!     - \b INT_TA2_N
303 //!     - \b INT_TA3_0
304 //!     - \b INT_TA3_N
305 //!     - \b INT_EUSCIA0
306 //!     - \b INT_EUSCIA1
307 //!     - \b INT_EUSCIA2
308 //!     - \b INT_EUSCIA3
309 //!     - \b INT_EUSCIB0
310 //!     - \b INT_EUSCIB1
311 //!     - \b INT_EUSCIB2
312 //!     - \b INT_EUSCIB3
313 //!     - \b INT_ADC14
314 //!     - \b INT_T32_INT1
315 //!     - \b INT_T32_INT2
316 //!     - \b INT_T32_INTC
317 //!     - \b INT_AES
318 //!     - \b INT_RTCC
319 //!     - \b INT_DMA_ERR
320 //!     - \b INT_DMA_INT3
321 //!     - \b INT_DMA_INT2
322 //!     - \b INT_DMA_INT1
323 //!     - \b INT_DMA_INT0
324 //!     - \b INT_PORT1
325 //!     - \b INT_PORT2
326 //!     - \b INT_PORT3
327 //!     - \b INT_PORT4
328 //!     - \b INT_PORT5
329 //!     - \b INT_PORT6
330 //!
331 //! \return None.
332 //
333 //*****************************************************************************
334 extern void Interrupt_enableInterrupt(uint32_t interruptNumber);
335
336 //*****************************************************************************
337 //
338 //! Disables an interrupt.
339 //!
340 //! \param interruptNumber specifies the interrupt to be disabled.
341 //!
342 //! The specified interrupt is disabled in the interrupt controller.  Other
343 //! enables for the interrupt (such as at the peripheral level) are unaffected
344 //! by this function.
345 //!
346 //! See \link Interrupt_enableInterrupt \endlink for details about the interrupt
347 //! parameter
348 //!
349 //! \return None.
350 //
351 //*****************************************************************************
352 extern void Interrupt_disableInterrupt(uint32_t interruptNumber);
353
354 //*****************************************************************************
355 //
356 //! Returns if a peripheral interrupt is enabled.
357 //!
358 //! \param interruptNumber specifies the interrupt to check.
359 //!
360 //! This function checks if the specified interrupt is enabled in the interrupt
361 //! controller.
362 //!
363 //! See \link Interrupt_enableInterrupt \endlink for details about the interrupt
364 //! parameter
365 //!
366 //! \return A non-zero value if the interrupt is enabled.
367 //
368 //*****************************************************************************
369 extern bool Interrupt_isEnabled(uint32_t interruptNumber);
370
371 //*****************************************************************************
372 //
373 //! Pends an interrupt.
374 //!
375 //! \param interruptNumber specifies the interrupt to be pended.
376 //!
377 //! The specified interrupt is pended in the interrupt controller.  Pending an
378 //! interrupt causes the interrupt controller to execute the corresponding
379 //! interrupt handler at the next available time, based on the current
380 //! interrupt state priorities. For example, if called by a higher priority
381 //! interrupt handler, the specified interrupt handler is not called until
382 //! after the current interrupt handler has completed execution.  The interrupt
383 //! must have been enabled for it to be called.
384 //!
385 //! See \link Interrupt_enableInterrupt \endlink for details about the interrupt
386 //! parameter
387 //!
388 //! \return None.
389 //
390 //*****************************************************************************
391 extern void Interrupt_pendInterrupt(uint32_t interruptNumber);
392
393 //*****************************************************************************
394 //
395 //! Un-pends an interrupt.
396 //!
397 //! \param interruptNumber specifies the interrupt to be un-pended.
398 //!
399 //! The specified interrupt is un-pended in the interrupt controller.  This
400 //! will cause any previously generated interrupts that have not been handled
401 //! yet (due to higher priority interrupts or the interrupt no having been
402 //! enabled yet) to be discarded.
403 //!
404 //! See \link Interrupt_enableInterrupt \endlink for details about the interrupt
405 //! parameter
406 //!
407 //! \return None.
408 //
409 //*****************************************************************************
410 extern void Interrupt_unpendInterrupt(uint32_t interruptNumber);
411
412 //*****************************************************************************
413 //
414 //! Sets the priority masking level
415 //!
416 //! \param priorityMask is the priority level that is masked.
417 //!
418 //! This function sets the interrupt priority masking level so that all
419 //! interrupts at the specified or lesser priority level are masked.  Masking
420 //! interrupts can be used to globally disable a set of interrupts with
421 //! priority below a predetermined threshold.  A value of 0 disables priority
422 //! masking.
423 //!
424 //! Smaller numbers correspond to higher interrupt priorities.  So for example
425 //! a priority level mask of 4 allows interrupts of priority level 0-3,
426 //! and interrupts with a numerical priority of 4 and greater are blocked.
427 //!
428 //! The hardware priority mechanism only looks at the upper N bits of the
429 //! priority level (where N is 3 for the MSP432 family), so any
430 //! prioritization must be performed in those bits.
431 //!
432 //! \return None.
433 //
434 //*****************************************************************************
435 extern void Interrupt_setPriorityMask(uint8_t priorityMask);
436
437 //*****************************************************************************
438 //
439 //! Gets the priority masking level
440 //!
441 //! This function gets the current setting of the interrupt priority masking
442 //! level.  The value returned is the priority level such that all interrupts
443 //! of that and lesser priority are masked.  A value of 0 means that priority
444 //! masking is disabled.
445 //!
446 //! Smaller numbers correspond to higher interrupt priorities.  So for example
447 //! a priority level mask of 4 allows interrupts of priority level 0-3,
448 //! and interrupts with a numerical priority of 4 and greater are blocked.
449 //!
450 //! The hardware priority mechanism only looks at the upper N bits of the
451 //! priority level (where N is 3 for the MSP432 family), so any
452 //! prioritization must be performed in those bits.
453 //!
454 //! \return Returns the value of the interrupt priority level mask.
455 //
456 //*****************************************************************************
457 extern uint8_t Interrupt_getPriorityMask(void);
458
459 //*****************************************************************************
460 //
461 //! Sets the address of the vector table. This function is for advanced users
462 //! who might want to switch between multiple instances of vector tables
463 //! (perhaps between flash/ram).
464 //!
465 //! \param addr is the new address of the vector table.
466 //!
467 //! \return None.
468 //
469 //*****************************************************************************
470 extern void Interrupt_setVectorTableAddress(uint32_t addr);
471
472 //*****************************************************************************
473 //
474 //! Returns the address of the interrupt vector table.
475 //!
476 //! \return Address of the vector table.
477 //
478 //*****************************************************************************
479 extern uint32_t Interrupt_getVectorTableAddress(void);
480
481 //*****************************************************************************
482 //
483 //! Enables the processor to sleep when exiting an ISR. For low power operation,
484 //! this is ideal as power cycles are not wasted with the processing required
485 //! for waking up from an ISR and going back to sleep.
486 //!
487 //! \return Address of the vector table.
488 //
489 //*****************************************************************************
490 extern void Interrupt_enableSleepOnIsrExit(void);
491
492 //*****************************************************************************
493 //
494 //! Enables the processor to sleep when exiting an ISR. For low power operation,
495 //! this is ideal as power cycles are not wasted with the processing required
496 //! for waking up from an ISR and going back to sleep.
497 //!
498 //! \return Address of the vector table.
499 //
500 //*****************************************************************************
501 extern void Interrupt_disableSleepOnIsrExit(void);
502
503 //*****************************************************************************
504 //
505 // Mark the end of the C bindings section for C++ compilers.
506 //
507 //*****************************************************************************
508 #ifdef __cplusplus
509 }
510 #endif
511
512 //*****************************************************************************
513 //
514 // Close the Doxygen group.
515 //! @}
516 //
517 //*****************************************************************************
518
519 #endif // __INTERRUPT_H__