CC26xx Driver Library |

- Main Page
- Related Pages
- CC26xx APIs
- Register Descriptions
- Online Resources

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
interrupt.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: interrupt.h
3 * Revised: 2015-01-14 12:12:44 +0100 (on, 14 jan 2015)
4 * Revision: 42373
5 *
6 * Description: Defines and prototypes for the NVIC Interrupt Controller
7 *
8 * Copyright (c) 2015, Texas Instruments Incorporated
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1) Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * 2) Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
22 * be used to endorse or promote products derived from this software without
23 * 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, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 ******************************************************************************/
38
39 //*****************************************************************************
40 //
43 //
44 //*****************************************************************************
45
46 #ifndef __INTERRUPT_H__
47 #define __INTERRUPT_H__
48
49 //*****************************************************************************
50 //
51 // If building with a C++ compiler, make all of the definitions in this header
52 // have a C binding.
53 //
54 //*****************************************************************************
55 #ifdef __cplusplus
56 extern "C"
57 {
58 #endif
59
60 #include <stdbool.h>
61 #include <stdint.h>
62 #include <inc/hw_ints.h>
63 #include <inc/hw_types.h>
64 #include <inc/hw_nvic.h>
65 #include <driverlib/debug.h>
66 #include <driverlib/cpu.h>
67
68 //*****************************************************************************
69 //
70 // Support for DriverLib in ROM:
71 // This section renames all functions that are not "static inline", so that
72 // calling these functions will default to implementation in flash. At the end
73 // of this file a second renaming will change the defaults to implementation in
74 // ROM for available functions.
75 //
76 // To force use of the implementation in flash, e.g. for debugging:
77 // - Globally: Define DRIVERLIB_NOROM at project level
78 // - Per function: Use prefix "NOROM_" when calling the function
79 //
80 // Do not define DRIVERLIB_GENERATE_ROM!
81 //
82 //*****************************************************************************
83 #ifndef DRIVERLIB_GENERATE_ROM
84 #define IntRegister NOROM_IntRegister
85 #define IntUnregister NOROM_IntUnregister
86 #define IntPriorityGroupingSet NOROM_IntPriorityGroupingSet
87 #define IntPriorityGroupingGet NOROM_IntPriorityGroupingGet
88 #define IntPrioritySet NOROM_IntPrioritySet
89 #define IntPriorityGet NOROM_IntPriorityGet
90 #define IntEnable NOROM_IntEnable
91 #define IntDisable NOROM_IntDisable
92 #define IntPendSet NOROM_IntPendSet
93 #define IntPendGet NOROM_IntPendGet
94 #define IntPendClear NOROM_IntPendClear
95 #endif
96
97 //*****************************************************************************
98 //
99 // Macro to generate an interrupt priority mask based on the number of bits
100 // of priority supported by the hardware. For CC26xx the number of priority
101 // bit is 3 as defifined in <tt>hw_types.h</tt>. The priority mask is
102 // defined as
103 //
104 // INT_PRIORITY_MASK = ((0xFF << (8 - NUM_PRIORITY_BITS)) & 0xFF)
105 //
106 //*****************************************************************************
107 #define INT_PRIORITY_MASK 0x000000E0
108 #define INT_PRI_LEVEL0 0x00000000
109 #define INT_PRI_LEVEL1 0x00000020
110 #define INT_PRI_LEVEL2 0x00000040
111 #define INT_PRI_LEVEL3 0x00000060
112 #define INT_PRI_LEVEL4 0x00000080
113 #define INT_PRI_LEVEL5 0x000000A0
114 #define INT_PRI_LEVEL6 0x000000C0
115 #define INT_PRI_LEVEL7 0x000000E0
116
117 //*****************************************************************************
118 //
119 // API Functions and prototypes
120 //
121 //*****************************************************************************
122
123 //*****************************************************************************
124 //
134 //
135 //*****************************************************************************
136 __STATIC_INLINE bool
137 IntMasterEnable(void)
138 {
139 //
140 // Enable processor interrupts.
141 //
142 return(CPUcpsie());
143 }
144
145 //*****************************************************************************
146 //
156 //
157 //*****************************************************************************
158 __STATIC_INLINE bool
159 IntMasterDisable(void)
160 {
161 //
162 // Disable processor interrupts.
163 //
164 return(CPUcpsid());
165 }
166
167 //*****************************************************************************
168 //
190 //
191 //*****************************************************************************
192 extern void IntRegister(uint32_t ui32Interrupt, void (*pfnHandler)(void));
193
194 //*****************************************************************************
195 //
208 //
209 //*****************************************************************************
210 extern void IntUnregister(uint32_t ui32Interrupt);
211
212 //*****************************************************************************
213 //
226 //
227 //*****************************************************************************
228 extern void IntPriorityGroupingSet(uint32_t ui32Bits);
229
230 //*****************************************************************************
231 //
238 //
239 //*****************************************************************************
240 extern uint32_t IntPriorityGroupingGet(void);
241
242 //*****************************************************************************
243 //
272 //
273 //*****************************************************************************
274 extern void IntPrioritySet(uint32_t ui32Interrupt, uint8_t ui8Priority);
275
276 //*****************************************************************************
277 //
294 //
295 //*****************************************************************************
296 extern int32_t IntPriorityGet(uint32_t ui32Interrupt);
297
298 //*****************************************************************************
299 //
309 //
310 //*****************************************************************************
311 extern void IntEnable(uint32_t ui32Interrupt);
312
313 //*****************************************************************************
314 //
324 //
325 //*****************************************************************************
326 extern void IntDisable(uint32_t ui32Interrupt);
327
328 //*****************************************************************************
329 //
343 //
344 //*****************************************************************************
345 extern void IntPendSet(uint32_t ui32Interrupt);
346
347 //*****************************************************************************
348 //
364 //
365 //*****************************************************************************
366 extern bool IntPendGet(uint32_t ui32Interrupt);
367
368 //*****************************************************************************
369 //
380 //
381 //*****************************************************************************
382 extern void IntPendClear(uint32_t ui32Interrupt);
383
384 //*****************************************************************************
385 //
405 //
406 //*****************************************************************************
407 __STATIC_INLINE void
408 IntPriorityMaskSet(uint32_t ui32PriorityMask)
409 {
410 CPUbasepriSet(ui32PriorityMask);
411 }
412
413 //*****************************************************************************
414 //
431 //
432 //*****************************************************************************
433 __STATIC_INLINE uint32_t
434 IntPriorityMaskGet(void)
435 {
436 return(CPUbasepriGet());
437 }
438
439 //*****************************************************************************
440 //
441 // Support for DriverLib in ROM:
442 // Redirect to implementation in ROM when available.
443 //
444 //*****************************************************************************
445 #ifndef DRIVERLIB_NOROM
446 #include <driverlib/rom.h>
447 #ifdef ROM_IntRegister
448 #undef IntRegister
449 #define IntRegister ROM_IntRegister
450 #endif
451 #ifdef ROM_IntUnregister
452 #undef IntUnregister
453 #define IntUnregister ROM_IntUnregister
454 #endif
455 #ifdef ROM_IntPriorityGroupingSet
456 #undef IntPriorityGroupingSet
457 #define IntPriorityGroupingSet ROM_IntPriorityGroupingSet
458 #endif
459 #ifdef ROM_IntPriorityGroupingGet
460 #undef IntPriorityGroupingGet
461 #define IntPriorityGroupingGet ROM_IntPriorityGroupingGet
462 #endif
463 #ifdef ROM_IntPrioritySet
464 #undef IntPrioritySet
465 #define IntPrioritySet ROM_IntPrioritySet
466 #endif
467 #ifdef ROM_IntPriorityGet
468 #undef IntPriorityGet
469 #define IntPriorityGet ROM_IntPriorityGet
470 #endif
471 #ifdef ROM_IntEnable
472 #undef IntEnable
473 #define IntEnable ROM_IntEnable
474 #endif
475 #ifdef ROM_IntDisable
476 #undef IntDisable
477 #define IntDisable ROM_IntDisable
478 #endif
479 #ifdef ROM_IntPendSet
480 #undef IntPendSet
481 #define IntPendSet ROM_IntPendSet
482 #endif
483 #ifdef ROM_IntPendGet
484 #undef IntPendGet
485 #define IntPendGet ROM_IntPendGet
486 #endif
487 #ifdef ROM_IntPendClear
488 #undef IntPendClear
489 #define IntPendClear ROM_IntPendClear
490 #endif
491 #endif
492
493 //*****************************************************************************
494 //
495 // Mark the end of the C bindings section for C++ compilers.
496 //
497 //*****************************************************************************
498 #ifdef __cplusplus
499 }
500 #endif
501
502 #endif // __INTERRUPT_H__
503
504 //*****************************************************************************
505 //
508 //
509 //*****************************************************************************
IntMasterEnable
__STATIC_INLINE bool IntMasterEnable(void)
Enables the processor interrupt.
Definition: interrupt.h:137
IntPriorityMaskGet
__STATIC_INLINE uint32_t IntPriorityMaskGet(void)
Gets the priority masking level.
Definition: interrupt.h:434
IntPriorityGet
int32_t IntPriorityGet(uint32_t ui32Interrupt)
Gets the priority of an interrupt.
Definition: interrupt.c:303
debug.h
IntPendClear
void IntPendClear(uint32_t ui32Interrupt)
Unpends an interrupt.
Definition: interrupt.c:539
IntPriorityGroupingSet
void IntPriorityGroupingSet(uint32_t ui32Bits)
Sets the priority grouping of the interrupt controller.
Definition: interrupt.c:224
IntPriorityGroupingGet
uint32_t IntPriorityGroupingGet(void)
Gets the priority grouping of the interrupt controller.
Definition: interrupt.c:243
IntPendSet
void IntPendSet(uint32_t ui32Interrupt)
Pends an interrupt.
Definition: interrupt.c:443
CPUcpsid
uint32_t CPUcpsid(void)
Disable all external interrupts.
Definition: cpu.c:91
cpu.h
IntUnregister
void IntUnregister(uint32_t ui32Interrupt)
Unregisters the function to be called when an interrupt occurs.
Definition: interrupt.c:205
IntPrioritySet
void IntPrioritySet(uint32_t ui32Interrupt, uint8_t ui8Priority)
Sets the priority of an interrupt.
Definition: interrupt.c:278
IntPriorityMaskSet
__STATIC_INLINE void IntPriorityMaskSet(uint32_t ui32PriorityMask)
Sets the priority masking level.
Definition: interrupt.h:408
CPUcpsie
uint32_t CPUcpsie(void)
Enable all external interrupts.
Definition: cpu.c:249
rom.h
CPUbasepriSet
__STATIC_INLINE void CPUbasepriSet(uint32_t ui32NewBasepri)
Update the interrupt priority disable level.
Definition: cpu.h:317
IntPendGet
bool IntPendGet(uint32_t ui32Interrupt)
Query whether an interrupt is pending.
Definition: interrupt.c:496
CPUbasepriGet
uint32_t CPUbasepriGet(void)
Get the interrupt priority disable level.
Definition: cpu.c:329
IntMasterDisable
__STATIC_INLINE bool IntMasterDisable(void)
Disables the processor interrupt.
Definition: interrupt.h:159
IntDisable
void IntDisable(uint32_t ui32Interrupt)
Disables an interrupt.
Definition: interrupt.c:383
IntRegister
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Registers a function to be called when an interrupt occurs.
Definition: interrupt.c:157
IntEnable
void IntEnable(uint32_t ui32Interrupt)
Enables an interrupt.
Definition: interrupt.c:323