CC35xxDriverLibrary
interrupt.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Filename: interrupt.h
3  *
4  * Description: Defines and prototypes for the NVIC Interrupt Controller
5  *
6  * Copyright (c) 2022-2025 Texas Instruments Incorporated
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1) Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * 2) Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3) Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  ******************************************************************************/
35 
36 #ifndef __INTERRUPT_H__
37 #define __INTERRUPT_H__
38 
39 //*****************************************************************************
40 //
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 #endif
57 
58 #include <stdbool.h>
59 #include <stdint.h>
60 
61 #include "../inc/hw_ints.h"
62 #include "../inc/hw_types.h"
63 
64 #include "../cmsis/cc35xx.h"
65 #include "../cmsis/core/core_cm33.h"
66 
67 #include "cpu.h"
68 
69 //*****************************************************************************
70 //
71 // Macro to generate an interrupt priority mask based on the number of bits
72 // of priority supported by the hardware. For CC35XX the number of priority
73 // bit is 3 as defined in <tt>hw_ints.h</tt>. The priority mask is
74 // defined as
75 //
76 // INT_PRIORITY_MASK = ((0xFF << (8 - NUM_PRIORITY_BITS)) & 0xFF)
77 //
78 //*****************************************************************************
79 #define INT_PRIORITY_MASK 0x000000F0
80 #define INT_PRI_LEVEL0 0x00000000
81 #define INT_PRI_LEVEL1 0x00000010
82 #define INT_PRI_LEVEL2 0x00000020
83 #define INT_PRI_LEVEL3 0x00000030
84 #define INT_PRI_LEVEL4 0x00000040
85 #define INT_PRI_LEVEL5 0x00000050
86 #define INT_PRI_LEVEL6 0x00000060
87 #define INT_PRI_LEVEL7 0x00000070
88 #define INT_PRI_LEVEL8 0x00000080
89 #define INT_PRI_LEVEL9 0x00000090
90 #define INT_PRI_LEVEL10 0x000000A0
91 #define INT_PRI_LEVEL11 0x000000B0
92 #define INT_PRI_LEVEL12 0x000000C0
93 #define INT_PRI_LEVEL13 0x000000D0
94 #define INT_PRI_LEVEL14 0x000000E0
95 #define INT_PRI_LEVEL15 0x000000F0
96 
97 //*****************************************************************************
98 //
99 // API Functions and prototypes
100 //
101 //*****************************************************************************
102 
103 //*****************************************************************************
104 //
127 //
128 //*****************************************************************************
129 extern void IntRegister(uint32_t intNum, void (*handler)(void));
130 
131 //*****************************************************************************
132 //
147 //
148 //*****************************************************************************
149 extern void IntUnregister(uint32_t intNum);
150 
151 //*****************************************************************************
152 //
188 //
189 //*****************************************************************************
190 extern void IntSetPriority(uint32_t intNum, uint8_t priority);
191 
192 //*****************************************************************************
193 //
223 //
224 //*****************************************************************************
225 extern int32_t IntGetPriority(uint32_t intNum);
226 
227 //*****************************************************************************
228 //
241 //
242 //*****************************************************************************
243 extern void IntEnable(uint32_t intNum);
244 
245 //*****************************************************************************
246 //
257 //
258 //*****************************************************************************
259 extern void IntDisable(uint32_t intNum);
260 
261 //*****************************************************************************
262 //
278 //
279 //*****************************************************************************
280 extern void IntSetPend(uint32_t intNum);
281 
282 //*****************************************************************************
283 //
302 //
303 //*****************************************************************************
304 extern bool IntGetPend(uint32_t intNum);
305 
306 //*****************************************************************************
307 //
322 //
323 //*****************************************************************************
324 extern void IntClearPend(uint32_t intNum);
325 
326 //*****************************************************************************
327 //
335 //
336 //*****************************************************************************
338 {
339  uint32_t interruptsDisabled = __get_PRIMASK();
340  // Enable CPU interrupts.
341  __enable_irq();
342  return (interruptsDisabled);
343 }
344 
345 //*****************************************************************************
346 //
356 //
357 //*****************************************************************************
359 {
360  uint32_t interruptsDisabled = __get_PRIMASK();
361  // Disable CPU interrupts.
362  __disable_irq();
363  return (interruptsDisabled);
364 }
365 
366 //*****************************************************************************
367 //
368 // Mark the end of the C bindings section for C++ compilers.
369 //
370 //*****************************************************************************
371 #ifdef __cplusplus
372 }
373 #endif
374 
375 //*****************************************************************************
376 //
380 //
381 //*****************************************************************************
382 
383 #endif // __INTERRUPT_H__
__STATIC_INLINE bool IntDisableMaster(void)
Disables the CPU interrupts with configurable priority.
Definition: interrupt.h:358
void IntEnable(uint32_t intNum)
Enables an interrupt or system exception.
Definition: interrupt.c:211
int32_t IntGetPriority(uint32_t intNum)
Gets the priority of an interrupt.
Definition: interrupt.c:184
#define __STATIC_INLINE
Definition: hw_types.h:57
__STATIC_INLINE bool IntEnableMaster(void)
Enables the CPU interrupt.
Definition: interrupt.h:337
bool IntGetPend(uint32_t intNum)
Checks if an interrupt is pending.
Definition: interrupt.c:299
__STATIC_FORCEINLINE void __disable_irq(void)
Disable IRQ Interrupts.
Definition: cmsis_gcc.h:207
__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void)
Get Priority Mask.
Definition: cmsis_gcc.h:449
void IntClearPend(uint32_t intNum)
Unpends an interrupt.
Definition: interrupt.c:329
void IntUnregister(uint32_t intNum)
Unregisters an interrupt handler in the dynamic vector table.
Definition: interrupt.c:142
void IntSetPriority(uint32_t intNum, uint8_t priority)
Sets the priority of an interrupt.
Definition: interrupt.c:156
void IntRegister(uint32_t intNum, void(*handler)(void))
Registers a function as an interrupt handler in the dynamic vector table.
Definition: interrupt.c:107
void IntSetPend(uint32_t intNum)
Pends an interrupt.
Definition: interrupt.c:263
__STATIC_FORCEINLINE void __enable_irq(void)
Enable IRQ Interrupts.
Definition: cmsis_gcc.h:196
void IntDisable(uint32_t intNum)
Disables an interrupt or system exception.
Definition: interrupt.c:237