CC26xx Driver Library
interrupt.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: interrupt.h
3 * Revised: 2016-06-30 09:21:03 +0200 (Thu, 30 Jun 2016)
4 * Revision: 46799
5 *
6 * Description: Defines and prototypes for the NVIC Interrupt Controller
7 *
8 * Copyright (c) 2015 - 2016, 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 //
45 //
46 //*****************************************************************************
47 
48 #ifndef __INTERRUPT_H__
49 #define __INTERRUPT_H__
50 
51 //*****************************************************************************
52 //
53 // If building with a C++ compiler, make all of the definitions in this header
54 // have a C binding.
55 //
56 //*****************************************************************************
57 #ifdef __cplusplus
58 extern "C"
59 {
60 #endif
61 
62 #include <stdbool.h>
63 #include <stdint.h>
64 #include <inc/hw_ints.h>
65 #include <inc/hw_types.h>
66 #include <inc/hw_nvic.h>
67 #include <driverlib/debug.h>
68 #include <driverlib/cpu.h>
69 
70 //*****************************************************************************
71 //
72 // Support for DriverLib in ROM:
73 // This section renames all functions that are not "static inline", so that
74 // calling these functions will default to implementation in flash. At the end
75 // of this file a second renaming will change the defaults to implementation in
76 // ROM for available functions.
77 //
78 // To force use of the implementation in flash, e.g. for debugging:
79 // - Globally: Define DRIVERLIB_NOROM at project level
80 // - Per function: Use prefix "NOROM_" when calling the function
81 //
82 //*****************************************************************************
83 #if !defined(DOXYGEN)
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 defined 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
138 {
139  //
140  // Enable processor interrupts.
141  //
142  return(CPUcpsie());
143 }
144 
145 //*****************************************************************************
146 //
156 //
157 //*****************************************************************************
158 __STATIC_INLINE bool
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
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 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
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 //
509 //
510 //*****************************************************************************
int32_t IntPriorityGet(uint32_t ui32Interrupt)
Gets the priority of an interrupt.
Definition: interrupt.c:298
void IntPendClear(uint32_t ui32Interrupt)
Unpends an interrupt.
Definition: interrupt.c:534
void IntPriorityGroupingSet(uint32_t ui32Bits)
Sets the priority grouping of the interrupt controller.
Definition: interrupt.c:219
uint32_t IntPriorityGroupingGet(void)
Gets the priority grouping of the interrupt controller.
Definition: interrupt.c:238
void IntPendSet(uint32_t ui32Interrupt)
Pends an interrupt.
Definition: interrupt.c:438
static void CPUbasepriSet(uint32_t ui32NewBasepri)
Update the interrupt priority disable level.
Definition: cpu.h:315
static bool IntMasterEnable(void)
Enables the processor interrupt.
Definition: interrupt.h:137
uint32_t CPUcpsid(void)
Disable all external interrupts.
Definition: cpu.c:97
static uint32_t IntPriorityMaskGet(void)
Gets the priority masking level.
Definition: interrupt.h:434
void IntUnregister(uint32_t ui32Interrupt)
Unregisters the function to be called when an interrupt occurs.
Definition: interrupt.c:200
void IntPrioritySet(uint32_t ui32Interrupt, uint8_t ui8Priority)
Sets the priority of an interrupt.
Definition: interrupt.c:273
static void IntPriorityMaskSet(uint32_t ui32PriorityMask)
Sets the priority masking level.
Definition: interrupt.h:408
uint32_t CPUcpsie(void)
Enable all external interrupts.
Definition: cpu.c:249
bool IntPendGet(uint32_t ui32Interrupt)
Query whether an interrupt is pending.
Definition: interrupt.c:491
static bool IntMasterDisable(void)
Disables the processor interrupt.
Definition: interrupt.h:159
uint32_t CPUbasepriGet(void)
Get the interrupt priority disable level.
Definition: cpu.c:325
void IntDisable(uint32_t ui32Interrupt)
Disables an interrupt.
Definition: interrupt.c:378
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Registers a function to be called when an interrupt occurs.
Definition: interrupt.c:152
void IntEnable(uint32_t ui32Interrupt)
Enables an interrupt.
Definition: interrupt.c:318