CC26xx Driver Library
[interrupt.h] Interrupt

Functions

void IntRegister (uint32_t ui32Interrupt, void(*pfnHandler)(void))
 Registers a function as an interrupt handler in the dynamic vector table. More...
 
void IntUnregister (uint32_t ui32Interrupt)
 Unregisters an interrupt handler in the dynamic vector table. More...
 
void IntPriorityGroupingSet (uint32_t ui32Bits)
 Sets the priority grouping of the interrupt controller. More...
 
uint32_t IntPriorityGroupingGet (void)
 Gets the priority grouping of the interrupt controller. More...
 
void IntPrioritySet (uint32_t ui32Interrupt, uint8_t ui8Priority)
 Sets the priority of an interrupt. More...
 
int32_t IntPriorityGet (uint32_t ui32Interrupt)
 Gets the priority of an interrupt. More...
 
void IntEnable (uint32_t ui32Interrupt)
 Enables an interrupt or system exception. More...
 
void IntDisable (uint32_t ui32Interrupt)
 Disables an interrupt or system exception. More...
 
void IntPendSet (uint32_t ui32Interrupt)
 Pends an interrupt. More...
 
bool IntPendGet (uint32_t ui32Interrupt)
 Checks if an interrupt is pending. More...
 
void IntPendClear (uint32_t ui32Interrupt)
 Unpends an interrupt. More...
 
static bool IntMasterEnable (void)
 Enables the CPU interrupt. More...
 
static bool IntMasterDisable (void)
 Disables the CPU interrupts with configurable priority. More...
 
static void IntPriorityMaskSet (uint32_t ui32PriorityMask)
 Sets the priority masking level. More...
 
static uint32_t IntPriorityMaskGet (void)
 Gets the priority masking level. More...
 

Detailed Description

Introduction

The interrupt controller API provides a set of functions for dealing with the Nested Vectored Interrupt Controller (NVIC). Functions are provided to enable and disable interrupts, register interrupt handlers, and set the priority of interrupts.

The event sources that trigger the interrupt lines in the NVIC are controlled by the MCU event fabric. All event sources are statically connected to the NVIC interrupt lines except one which is programmable. For more information about the MCU event fabric, see the MCU event fabric API.

API

Interrupts and system exceptions must be individually enabled and disabled through:

The global CPU interrupt can be enabled and disabled with the following functions:

This does not affect the individual interrupt enable states. Masking of the CPU interrupt can be used as a simple critical section (only an NMI can interrupt the CPU while the CPU interrupt is disabled), although masking the CPU interrupt can increase the interrupt response time.

It is possible to access the NVIC to see if any interrupts are pending and manually clear pending interrupts which have not yet been serviced or set a specific interrupt as pending to be handled based on its priority. Pending interrupts are cleared automatically when the interrupt is accepted and executed. However, the event source which caused the interrupt might need to be cleared manually to avoid re-triggering the corresponding interrupt. The functions to read, clear, and set pending interrupts are:

The interrupt prioritization in the NVIC allows handling of higher priority interrupts before lower priority interrupts, as well as allowing preemption of lower priority interrupt handlers by higher priority interrupts. The device supports eight priority levels from 0 to 7 with 0 being the highest priority. The priority of each interrupt source can be set and examined using:

Interrupts can be masked based on their priority such that interrupts with the same or lower priority than the mask are effectively disabled. This can be configured with:

Subprioritization is also possible. Instead of having three bits of preemptable prioritization (eight levels), the NVIC can be configured for 3 - M bits of preemptable prioritization and M bits of subpriority. In this scheme, two interrupts with the same preemptable prioritization but different subpriorities do not cause a preemption. Instead, tail chaining is used to process the two interrupts back-to-back. If two interrupts with the same priority (and subpriority if so configured) are asserted at the same time, the one with the lower interrupt number is processed first. Subprioritization is handled by:

Interrupt Vector Table

The interrupt vector table can be configured in one of two ways:

When configured, the interrupts must be explicitly enabled in the NVIC through IntEnable() before the CPU can respond to the interrupt (in addition to any interrupt enabling required within the peripheral).

Static Vector Table

Static registration of interrupt handlers is accomplished by editing the interrupt handler table in the startup code of the application. Texas Instruments provides startup files for each supported compiler ( startup_<compiler>.c ) and these startup files include a default static interrupt vector table. All entries, except ResetISR, are declared as extern with weak assignment to a default interrupt handler. This allows the user to declare and define a function (in the user's code) with the same name as an entry in the vector table. At compile time, the linker then replaces the pointer to the default interrupt handler in the vector table with the pointer to the interrupt handler defined by the user.

Statically configuring the interrupt table provides the fastest interrupt response time because the stacking operation (a write to SRAM on the data bus) is performed in parallel with the interrupt handler table fetch (a read from Flash on the instruction bus), as well as the prefetch of the interrupt handler (assuming it is also in Flash).

Dynamic Vector Table

Alternatively, interrupts can be registered in the vector table at runtime, thus dynamically. The dynamic vector table is placed in SRAM and the code can then modify the pointers to interrupt handlers throughout the application.

DriverLib uses these two functions to modify the dynamic vector table:

Note
First call to IntRegister() initializes the vector table in SRAM by copying the static vector table from Flash and forcing the NVIC to use the dynamic vector table from this point forward. If using the dynamic vector table it is highly recommended to initialize it during the setup phase of the application. The NVIC uses the static vector table in Flash until the application initializes the dynamic vector table in SRAM.

Runtime configuration of interrupts adds a small latency to the interrupt response time because the stacking operation (a write to SRAM on the data bus) and the interrupt handler fetch from the vector table (a read from SRAM on the instruction bus) must be performed sequentially.

The dynamic vector table, g_pfnRAMVectors, is placed in SRAM in the section called vtable_ram which is a section defined in the linker file. By default the linker file places this section at the start of the SRAM but this is configurable by the user.

Warning
Runtime configuration of interrupt handlers requires that the interrupt handler table is placed on a 256-byte boundary in SRAM (typically, this is at the beginning of SRAM). Failure to do so results in an incorrect vector address being fetched in response to an interrupt.

Function Documentation

void IntDisable ( uint32_t  ui32Interrupt)

Disables an interrupt or system exception.

This function disables the specified interrupt in the interrupt controller.

Parameters
ui32Interruptspecifies the index in the vector table to disable.
Returns
None
See also
IntEnable()

Referenced by AESIntUnregister(), AESWriteToKeyStore(), CRYPTOAesEcbStatus(), CRYPTOAesLoadKey(), CRYPTOCcmAuthEncrypt(), CRYPTOCcmAuthEncryptStatus(), CRYPTOCcmInvAuthDecrypt(), CRYPTOCcmInvAuthDecryptStatus(), CRYPTOIntUnregister(), FlashIntUnregister(), I2CIntUnregister(), I2SIntUnregister(), IOCIntUnregister(), SHA2IntUnregister(), SSIIntUnregister(), TimerIntUnregister(), TRNGIntUnregister(), UARTIntUnregister(), uDMAIntUnregister(), and WatchdogIntUnregister().

328 {
329  // Check the arguments.
330  ASSERT(ui32Interrupt < NUM_INTERRUPTS);
331 
332  // Determine the interrupt to disable.
333  if(ui32Interrupt == INT_MEMMANAGE_FAULT)
334  {
335  // Disable the MemManage interrupt.
336  HWREG(NVIC_SYS_HND_CTRL) &= ~(NVIC_SYS_HND_CTRL_MEM);
337  }
338  else if(ui32Interrupt == INT_BUS_FAULT)
339  {
340  // Disable the bus fault interrupt.
341  HWREG(NVIC_SYS_HND_CTRL) &= ~(NVIC_SYS_HND_CTRL_BUS);
342  }
343  else if(ui32Interrupt == INT_USAGE_FAULT)
344  {
345  // Disable the usage fault interrupt.
346  HWREG(NVIC_SYS_HND_CTRL) &= ~(NVIC_SYS_HND_CTRL_USAGE);
347  }
348  else if(ui32Interrupt == INT_SYSTICK)
349  {
350  // Disable the System Tick interrupt.
351  HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_INTEN);
352  }
353  else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
354  {
355  // Disable the general interrupt.
356  HWREG(NVIC_DIS0) = 1 << (ui32Interrupt - 16);
357  }
358  else if(ui32Interrupt >= 48)
359  {
360  // Disable the general interrupt.
361  HWREG(NVIC_DIS1) = 1 << (ui32Interrupt - 48);
362  }
363 }
#define ASSERT(expr)
Definition: debug.h:73
void IntEnable ( uint32_t  ui32Interrupt)

Enables an interrupt or system exception.

This function enables the specified interrupt in the interrupt controller.

Note
If a fault condition occurs while the corresponding system exception is disabled, the fault is treated as a Hard Fault.
Parameters
ui32Interruptspecifies the index in the vector table to enable.
  • System exceptions:
    • INT_MEMMANAGE_FAULT
    • INT_BUS_FAULT
    • INT_USAGE_FAULT
    • INT_SYSTICK
  • Interrupts:
    • INT_AON_GPIO_EDGE
    • INT_I2C_IRQ
    • INT_RFC_CPE_1
    • INT_PKA_IRQ
    • INT_AON_RTC_COMB
    • INT_UART0_COMB
    • INT_AUX_SWEV0
    • INT_SSI0_COMB
    • INT_SSI1_COMB
    • INT_RFC_CPE_0
    • INT_RFC_HW_COMB
    • INT_RFC_CMD_ACK
    • INT_I2S_IRQ
    • INT_AUX_SWEV1
    • INT_WDT_IRQ
    • INT_GPT0A
    • INT_GPT0B
    • INT_GPT1A
    • INT_GPT1B
    • INT_GPT2A
    • INT_GPT2B
    • INT_GPT3A
    • INT_GPT3B
    • INT_CRYPTO_RESULT_AVAIL_IRQ
    • INT_DMA_DONE_COMB
    • INT_DMA_ERR
    • INT_FLASH
    • INT_SWEV0
    • INT_AUX_COMB
    • INT_AON_PROG0
    • INT_PROG0 (Programmable interrupt, see EventRegister())
    • INT_AUX_COMPA
    • INT_AUX_ADC_IRQ
    • INT_TRNG_IRQ
    • INT_OSC_COMB
    • INT_AUX_TIMER2_EV0
    • INT_UART1_COMB
    • INT_BATMON_COMB
Returns
None
See also
IntDisable()

Referenced by AESIntRegister(), AESWriteToKeyStore(), CRYPTOAesCbc(), CRYPTOAesEcb(), CRYPTOCcmAuthEncrypt(), CRYPTOCcmInvAuthDecrypt(), CRYPTOIntRegister(), FlashIntRegister(), I2CIntRegister(), I2SIntRegister(), IOCIntRegister(), SHA2IntRegister(), SSIIntRegister(), TimerIntRegister(), TRNGIntRegister(), UARTIntRegister(), uDMAIntRegister(), and WatchdogIntRegister().

284 {
285  // Check the arguments.
286  ASSERT(ui32Interrupt < NUM_INTERRUPTS);
287 
288  // Determine the interrupt to enable.
289  if(ui32Interrupt == INT_MEMMANAGE_FAULT)
290  {
291  // Enable the MemManage interrupt.
292  HWREG(NVIC_SYS_HND_CTRL) |= NVIC_SYS_HND_CTRL_MEM;
293  }
294  else if(ui32Interrupt == INT_BUS_FAULT)
295  {
296  // Enable the bus fault interrupt.
297  HWREG(NVIC_SYS_HND_CTRL) |= NVIC_SYS_HND_CTRL_BUS;
298  }
299  else if(ui32Interrupt == INT_USAGE_FAULT)
300  {
301  // Enable the usage fault interrupt.
302  HWREG(NVIC_SYS_HND_CTRL) |= NVIC_SYS_HND_CTRL_USAGE;
303  }
304  else if(ui32Interrupt == INT_SYSTICK)
305  {
306  // Enable the System Tick interrupt.
307  HWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_INTEN;
308  }
309  else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
310  {
311  // Enable the general interrupt.
312  HWREG(NVIC_EN0) = 1 << (ui32Interrupt - 16);
313  }
314  else if(ui32Interrupt >= 48)
315  {
316  // Enable the general interrupt.
317  HWREG(NVIC_EN1) = 1 << (ui32Interrupt - 48);
318  }
319 }
#define ASSERT(expr)
Definition: debug.h:73
static bool IntMasterDisable ( void  )
inlinestatic

Disables the CPU interrupts with configurable priority.

Prevents the CPU from receiving interrupts except NMI and hard fault. This does not affect the set of interrupts enabled in the interrupt controller; it just gates the interrupt from the interrupt controller to the CPU.

Returns
Returns:
  • true : Interrupts were already disabled when the function was called.
  • false : Interrupts were enabled and are now disabled.
586 {
587  // Disable CPU interrupts.
588  return(CPUcpsid());
589 }
uint32_t CPUcpsid(void)
Disable all external interrupts.
Definition: cpu.c:68

Here is the call graph for this function:

static bool IntMasterEnable ( void  )
inlinestatic

Enables the CPU interrupt.

Allows the CPU to respond to interrupts.

Returns
Returns:
  • true : Interrupts were disabled and are now enabled.
  • false : Interrupts were already enabled when the function was called.
566 {
567  // Enable CPU interrupts.
568  return(CPUcpsie());
569 }
uint32_t CPUcpsie(void)
Enable all external interrupts.
Definition: cpu.c:206

Here is the call graph for this function:

void IntPendClear ( uint32_t  ui32Interrupt)

Unpends an interrupt.

This function unpends the specified interrupt in the interrupt controller. This causes any previously generated interrupts that have not been handled yet (due to higher priority interrupts or the interrupt no having been enabled yet) to be discarded.

Note
It is not possible to unpend the NMI because it takes effect immediately when being pended.
Parameters
ui32Interruptspecifies the index in the vector table to unpend.
  • See IntPendSet() for list of valid arguments (except NMI).
Returns
None

Referenced by AESWriteToKeyStore(), CRYPTOAesCbc(), CRYPTOAesEcb(), CRYPTOCcmAuthEncrypt(), and CRYPTOCcmInvAuthDecrypt().

444 {
445  // Check the arguments.
446  ASSERT(ui32Interrupt < NUM_INTERRUPTS);
447 
448  // Determine the interrupt to unpend.
449  if(ui32Interrupt == INT_PENDSV)
450  {
451  // Unpend the PendSV interrupt.
452  HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_UNPEND_SV;
453  }
454  else if(ui32Interrupt == INT_SYSTICK)
455  {
456  // Unpend the SysTick interrupt.
457  HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PENDSTCLR;
458  }
459  else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
460  {
461  // Unpend the general interrupt.
462  HWREG(NVIC_UNPEND0) = 1 << (ui32Interrupt - 16);
463  }
464  else if(ui32Interrupt >= 48)
465  {
466  // Unpend the general interrupt.
467  HWREG(NVIC_UNPEND1) = 1 << (ui32Interrupt - 48);
468  }
469 }
#define ASSERT(expr)
Definition: debug.h:73
bool IntPendGet ( uint32_t  ui32Interrupt)

Checks if an interrupt is pending.

This function checks the interrupt controller to see if an interrupt is pending.

The interrupt must be enabled in order for the corresponding interrupt handler to be executed, so an interrupt can be pending waiting to be enabled or waiting for an interrupt of higher priority to be done executing.

Note
This function does not support reading pending status for system exceptions (vector table indexes <16).
Parameters
ui32Interruptspecifies the index in the vector table to check pending status for.
  • See IntPendSet() for list of valid arguments (except system exceptions).
Returns
Returns:
  • true : Specified interrupt is pending.
  • false : Specified interrupt is not pending.
411 {
412  uint32_t ui32IntPending;
413 
414  // Check the arguments.
415  ASSERT(ui32Interrupt < NUM_INTERRUPTS);
416 
417  // Assume no interrupts are pending.
418  ui32IntPending = 0;
419 
420  // The lower 16 IRQ vectors are unsupported by this function
421  if (ui32Interrupt < 16)
422  {
423 
424  return 0;
425  }
426 
427  // Subtract lower 16 irq vectors
428  ui32Interrupt -= 16;
429 
430  // Check if the interrupt is pending
431  ui32IntPending = HWREG(NVIC_PEND0 + (ui32Interrupt / 32));
432  ui32IntPending &= (1 << (ui32Interrupt & 31));
433 
434  return ui32IntPending ? true : false;
435 }
#define ASSERT(expr)
Definition: debug.h:73
void IntPendSet ( uint32_t  ui32Interrupt)

Pends an interrupt.

This function pends the specified interrupt in the interrupt controller. This causes the interrupt controller to execute the corresponding interrupt handler at the next available time, based on the current interrupt state priorities.

This interrupt controller automatically clears the pending interrupt once the interrupt handler is executed.

Parameters
ui32Interruptspecifies the index in the vector table to pend.
  • System exceptions:
    • INT_NMI_FAULT
    • INT_PENDSV
    • INT_SYSTICK
  • Interrupts:
    • INT_AON_GPIO_EDGE
    • INT_I2C_IRQ
    • INT_RFC_CPE_1
    • INT_PKA_IRQ
    • INT_AON_RTC_COMB
    • INT_UART0_COMB
    • INT_AUX_SWEV0
    • INT_SSI0_COMB
    • INT_SSI1_COMB
    • INT_RFC_CPE_0
    • INT_RFC_HW_COMB
    • INT_RFC_CMD_ACK
    • INT_I2S_IRQ
    • INT_AUX_SWEV1
    • INT_WDT_IRQ
    • INT_GPT0A
    • INT_GPT0B
    • INT_GPT1A
    • INT_GPT1B
    • INT_GPT2A
    • INT_GPT2B
    • INT_GPT3A
    • INT_GPT3B
    • INT_CRYPTO_RESULT_AVAIL_IRQ
    • INT_DMA_DONE_COMB
    • INT_DMA_ERR
    • INT_FLASH
    • INT_SWEV0
    • INT_AUX_COMB
    • INT_AON_PROG0
    • INT_PROG0 (Programmable interrupt, see EventRegister())
    • INT_AUX_COMPA
    • INT_AUX_ADC_IRQ
    • INT_TRNG_IRQ
    • INT_OSC_COMB
    • INT_AUX_TIMER2_EV0
    • INT_UART1_COMB
    • INT_BATMON_COMB
Returns
None
See also
IntEnable()
372 {
373  // Check the arguments.
374  ASSERT(ui32Interrupt < NUM_INTERRUPTS);
375 
376  // Determine the interrupt to pend.
377  if(ui32Interrupt == INT_NMI_FAULT)
378  {
379  // Pend the NMI interrupt.
380  HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_NMI_SET;
381  }
382  else if(ui32Interrupt == INT_PENDSV)
383  {
384  // Pend the PendSV interrupt.
385  HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PEND_SV;
386  }
387  else if(ui32Interrupt == INT_SYSTICK)
388  {
389  // Pend the SysTick interrupt.
390  HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PENDSTSET;
391  }
392  else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
393  {
394  // Pend the general interrupt.
395  HWREG(NVIC_PEND0) = 1 << (ui32Interrupt - 16);
396  }
397  else if(ui32Interrupt >= 48)
398  {
399  // Pend the general interrupt.
400  HWREG(NVIC_PEND1) = 1 << (ui32Interrupt - 48);
401  }
402 }
#define ASSERT(expr)
Definition: debug.h:73
int32_t IntPriorityGet ( uint32_t  ui32Interrupt)

Gets the priority of an interrupt.

This function gets the priority of an interrupt.

Warning
This function does not support getting priority of interrupt vectors one through three which are:
  • 1: Reset handler
  • 2: NMI handler
  • 3: Hard fault handler
Parameters
ui32Interruptspecifies the index in the vector table to read priority of.
Returns
Returns the interrupt priority:
268 {
269  // Check the arguments.
270  ASSERT((ui32Interrupt >= 4) && (ui32Interrupt < NUM_INTERRUPTS));
271 
272  // Return the interrupt priority.
273  return((HWREG(g_pui32Regs[ui32Interrupt >> 2]) >> (8 * (ui32Interrupt & 3))) &
274  0xFF);
275 }
static const uint32_t g_pui32Regs[]
Definition: interrupt.c:91
#define ASSERT(expr)
Definition: debug.h:73
uint32_t IntPriorityGroupingGet ( void  )

Gets the priority grouping of the interrupt controller.

This function returns the split between preemptable priority levels and subpriority levels in the interrupt priority specification.

Returns
Returns the number of bits of preemptable priority.
  • 0 : No pre-emption priority, eight bits of subpriority.
  • 1 : One bit of pre-emption priority, seven bits of subpriority
  • 2 : Two bits of pre-emption priority, six bits of subpriority
  • 3-7 : Three bits of pre-emption priority, five bits of subpriority
220 {
221  uint32_t ui32Loop, ui32Value;
222 
223  // Read the priority grouping.
224  ui32Value = HWREG(NVIC_APINT) & NVIC_APINT_PRIGROUP_M;
225 
226  // Loop through the priority grouping values.
227  for(ui32Loop = 0; ui32Loop < NUM_PRIORITY; ui32Loop++)
228  {
229  // Stop looping if this value matches.
230  if(ui32Value == g_pui32Priority[ui32Loop])
231  {
232  break;
233  }
234  }
235 
236  // Return the number of priority bits.
237  return(ui32Loop);
238 }
static const uint32_t g_pui32Priority[]
Definition: interrupt.c:78
void IntPriorityGroupingSet ( uint32_t  ui32Bits)

Sets the priority grouping of the interrupt controller.

This function specifies the split between preemptable priority levels and subpriority levels in the interrupt priority specification.

Three bits are available for hardware interrupt prioritization thus priority grouping values of three through seven have the same effect.

Parameters
ui32Bitsspecifies the number of bits of preemptable priority.
  • 0 : No pre-emption priority, eight bits of subpriority.
  • 1 : One bit of pre-emption priority, seven bits of subpriority
  • 2 : Two bits of pre-emption priority, six bits of subpriority
  • 3-7 : Three bits of pre-emption priority, five bits of subpriority
Returns
None
See also
IntPrioritySet()
205 {
206  // Check the arguments.
207  ASSERT(ui32Bits < NUM_PRIORITY);
208 
209  // Set the priority grouping.
210  HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | g_pui32Priority[ui32Bits];
211 }
#define ASSERT(expr)
Definition: debug.h:73
static const uint32_t g_pui32Priority[]
Definition: interrupt.c:78
static uint32_t IntPriorityMaskGet ( void  )
inlinestatic

Gets the priority masking level.

This function gets the current setting of the interrupt priority masking level. The value returned is the priority level such that all interrupts of that and lesser priority are masked. A value of 0 means that priority masking is disabled.

Smaller numbers correspond to higher interrupt priorities. So for example a priority level mask of 4 will allow interrupts of priority level 0-3, and interrupts with a numerical priority of 4 and greater will be blocked.

Returns
Returns the value of the interrupt priority level mask.
643 {
644  return(CPUbasepriGet());
645 }
uint32_t CPUbasepriGet(void)
Get the interrupt priority disable level.
Definition: cpu.c:277

Here is the call graph for this function:

static void IntPriorityMaskSet ( uint32_t  ui32PriorityMask)
inlinestatic

Sets the priority masking level.

This function sets the interrupt priority masking level so that all interrupts at the specified or lesser priority level are masked. This can be used to globally disable a set of interrupts with priority below a predetermined threshold. A value of 0 disables priority masking.

Smaller numbers correspond to higher interrupt priorities. So for example a priority level mask of 4 will allow interrupts of priority level 0-3, and interrupts with a numerical priority of 4 and greater will be blocked. The device supports priority levels 0 through 7.

Parameters
ui32PriorityMaskis the priority level that will be masked.
  • 0 : Disable priority masking.
  • 1 : Allow priority 0 interrupts, mask interrupts with priority 1-7.
  • 2 : Allow priority 0-1 interrupts, mask interrupts with priority 2-7.
  • 3 : Allow priority 0-2 interrupts, mask interrupts with priority 3-7.
  • 4 : Allow priority 0-3 interrupts, mask interrupts with priority 4-7.
  • 5 : Allow priority 0-4 interrupts, mask interrupts with priority 5-7.
  • 6 : Allow priority 0-5 interrupts, mask interrupts with priority 6-7.
  • 7 : Allow priority 0-6 interrupts, mask interrupts with priority 7.
Returns
None.
621 {
622  CPUbasepriSet(ui32PriorityMask);
623 }
static void CPUbasepriSet(uint32_t ui32NewBasepri)
Update the interrupt priority disable level.
Definition: cpu.h:337

Here is the call graph for this function:

void IntPrioritySet ( uint32_t  ui32Interrupt,
uint8_t  ui8Priority 
)

Sets the priority of an interrupt.

This function sets the priority of an interrupt, including system exceptions. When multiple interrupts are asserted simultaneously, the ones with the highest priority are processed before the lower priority interrupts. Smaller numbers correspond to higher interrupt priorities thus priority 0 is the highest interrupt priority.

Warning
This function does not support setting priority of interrupt vectors one through three which are:
  • 1: Reset handler
  • 2: NMI handler
  • 3: Hard fault handler
Parameters
ui32Interruptspecifies the index in the vector table to change priority for.
  • System exceptions:
    • INT_MEMMANAGE_FAULT
    • INT_BUS_FAULT
    • INT_USAGE_FAULT
    • INT_SVCALL
    • INT_DEBUG
    • INT_PENDSV
    • INT_SYSTICK
  • Interrupts:
    • INT_AON_GPIO_EDGE
    • INT_I2C_IRQ
    • INT_RFC_CPE_1
    • INT_PKA_IRQ
    • INT_AON_RTC_COMB
    • INT_UART0_COMB
    • INT_AUX_SWEV0
    • INT_SSI0_COMB
    • INT_SSI1_COMB
    • INT_RFC_CPE_0
    • INT_RFC_HW_COMB
    • INT_RFC_CMD_ACK
    • INT_I2S_IRQ
    • INT_AUX_SWEV1
    • INT_WDT_IRQ
    • INT_GPT0A
    • INT_GPT0B
    • INT_GPT1A
    • INT_GPT1B
    • INT_GPT2A
    • INT_GPT2B
    • INT_GPT3A
    • INT_GPT3B
    • INT_CRYPTO_RESULT_AVAIL_IRQ
    • INT_DMA_DONE_COMB
    • INT_DMA_ERR
    • INT_FLASH
    • INT_SWEV0
    • INT_AUX_COMB
    • INT_AON_PROG0
    • INT_PROG0 (Programmable interrupt, see EventRegister())
    • INT_AUX_COMPA
    • INT_AUX_ADC_IRQ
    • INT_TRNG_IRQ
    • INT_OSC_COMB
    • INT_AUX_TIMER2_EV0
    • INT_UART1_COMB
    • INT_BATMON_COMB
ui8Priorityspecifies the priority of the interrupt.
Returns
None
See also
IntPriorityGroupingSet()
247 {
248  uint32_t ui32Temp;
249 
250  // Check the arguments.
251  ASSERT((ui32Interrupt >= 4) && (ui32Interrupt < NUM_INTERRUPTS));
252  ASSERT(ui8Priority <= INT_PRI_LEVEL7);
253 
254  // Set the interrupt priority.
255  ui32Temp = HWREG(g_pui32Regs[ui32Interrupt >> 2]);
256  ui32Temp &= ~(0xFF << (8 * (ui32Interrupt & 3)));
257  ui32Temp |= ui8Priority << (8 * (ui32Interrupt & 3));
258  HWREG(g_pui32Regs[ui32Interrupt >> 2]) = ui32Temp;
259 }
static const uint32_t g_pui32Regs[]
Definition: interrupt.c:91
#define INT_PRI_LEVEL7
Definition: interrupt.h:115
#define ASSERT(expr)
Definition: debug.h:73
void IntRegister ( uint32_t  ui32Interrupt,
void(*)(void)  pfnHandler 
)

Registers a function as an interrupt handler in the dynamic vector table.

Note
Only use this function if you want to use the dynamic vector table (in SRAM)!

This function writes a function pointer to the dynamic interrupt vector table in SRAM to register the function as an interrupt handler (ISR). When the corresponding interrupt occurs, and it has been enabled (see IntEnable()), the function pointer is fetched from the dynamic vector table, and the System CPU will execute the interrupt handler.

Note
The first call to this function (directly or indirectly via a peripheral driver interrupt register function) copies the interrupt vector table from Flash to SRAM. NVIC uses the static vector table (in Flash) until this function is called.
Parameters
ui32Interruptspecifies the index in the vector table to modify.
  • System exceptions (vectors 0 to 15):
    • INT_NMI_FAULT
    • INT_HARD_FAULT
    • INT_MEMMANAGE_FAULT
    • INT_BUS_FAULT
    • INT_USAGE_FAULT
    • INT_SVCALL
    • INT_DEBUG
    • INT_PENDSV
    • INT_SYSTICK
  • Interrupts (vectors >15):
    • INT_AON_GPIO_EDGE
    • INT_I2C_IRQ
    • INT_RFC_CPE_1
    • INT_PKA_IRQ
    • INT_AON_RTC_COMB
    • INT_UART0_COMB
    • INT_AUX_SWEV0
    • INT_SSI0_COMB
    • INT_SSI1_COMB
    • INT_RFC_CPE_0
    • INT_RFC_HW_COMB
    • INT_RFC_CMD_ACK
    • INT_I2S_IRQ
    • INT_AUX_SWEV1
    • INT_WDT_IRQ
    • INT_GPT0A
    • INT_GPT0B
    • INT_GPT1A
    • INT_GPT1B
    • INT_GPT2A
    • INT_GPT2B
    • INT_GPT3A
    • INT_GPT3B
    • INT_CRYPTO_RESULT_AVAIL_IRQ
    • INT_DMA_DONE_COMB
    • INT_DMA_ERR
    • INT_FLASH
    • INT_SWEV0
    • INT_AUX_COMB
    • INT_AON_PROG0
    • INT_PROG0 (Programmable interrupt, see EventRegister())
    • INT_AUX_COMPA
    • INT_AUX_ADC_IRQ
    • INT_TRNG_IRQ
    • INT_OSC_COMB
    • INT_AUX_TIMER2_EV0
    • INT_UART1_COMB
    • INT_BATMON_COMB
pfnHandleris a pointer to the function to register as interrupt handler.
Returns
None.
See also
IntUnregister(), IntEnable()

Referenced by AESIntRegister(), CRYPTOIntRegister(), FlashIntRegister(), I2CIntRegister(), I2SIntRegister(), IOCIntRegister(), SHA2IntRegister(), SSIIntRegister(), SysTickIntRegister(), TimerIntRegister(), TRNGIntRegister(), UARTIntRegister(), uDMAIntRegister(), and WatchdogIntRegister().

154 {
155  uint32_t ui32Idx, ui32Value;
156 
157  // Check the arguments.
158  ASSERT(ui32Interrupt < NUM_INTERRUPTS);
159 
160  // Make sure that the RAM vector table is correctly aligned.
161  ASSERT(((uint32_t)g_pfnRAMVectors & 0x000000ff) == 0);
162 
163  // See if the RAM vector table has been initialized.
164  if(HWREG(NVIC_VTABLE) != (uint32_t)g_pfnRAMVectors)
165  {
166  // Copy the vector table from the beginning of FLASH to the RAM vector
167  // table.
168  ui32Value = HWREG(NVIC_VTABLE);
169  for(ui32Idx = 0; ui32Idx < NUM_INTERRUPTS; ui32Idx++)
170  {
171  g_pfnRAMVectors[ui32Idx] = (void (*)(void))HWREG((ui32Idx * 4) +
172  ui32Value);
173  }
174 
175  // Point NVIC at the RAM vector table.
176  HWREG(NVIC_VTABLE) = (uint32_t)g_pfnRAMVectors;
177  }
178 
179  // Save the interrupt handler.
180  g_pfnRAMVectors[ui32Interrupt] = pfnHandler;
181 }
void(* g_pfnRAMVectors[NUM_INTERRUPTS])(void)
Global pointer to the (dynamic) interrupt vector table when placed in SRAM.
Definition: interrupt.c:131
#define ASSERT(expr)
Definition: debug.h:73
void IntUnregister ( uint32_t  ui32Interrupt)

Unregisters an interrupt handler in the dynamic vector table.

This function removes an interrupt handler from the dynamic vector table and replaces it with the default interrupt handler IntDefaultHandler().

Note
Remember to disable the interrupt before removing its interrupt handler from the vector table.
Parameters
ui32Interruptspecifies the index in the vector table to modify.
Returns
None.
See also
IntRegister(), IntDisable()

Referenced by AESIntUnregister(), CRYPTOIntUnregister(), FlashIntUnregister(), I2CIntUnregister(), I2SIntUnregister(), IOCIntUnregister(), SHA2IntUnregister(), SSIIntUnregister(), SysTickIntUnregister(), TimerIntUnregister(), TRNGIntUnregister(), UARTIntUnregister(), uDMAIntUnregister(), and WatchdogIntUnregister().

190 {
191  // Check the arguments.
192  ASSERT(ui32Interrupt < NUM_INTERRUPTS);
193 
194  // Reset the interrupt handler.
195  g_pfnRAMVectors[ui32Interrupt] = IntDefaultHandler;
196 }
void(* g_pfnRAMVectors[NUM_INTERRUPTS])(void)
Global pointer to the (dynamic) interrupt vector table when placed in SRAM.
Definition: interrupt.c:131
#define ASSERT(expr)
Definition: debug.h:73
static void IntDefaultHandler(void)
The default interrupt handler.
Definition: interrupt.c:111

Here is the call graph for this function:

Macro Definition Documentation

#define INT_PRI_LEVEL0   0x00000000
#define INT_PRI_LEVEL1   0x00000020
#define INT_PRI_LEVEL2   0x00000040
#define INT_PRI_LEVEL3   0x00000060
#define INT_PRI_LEVEL4   0x00000080
#define INT_PRI_LEVEL5   0x000000A0
#define INT_PRI_LEVEL6   0x000000C0
#define INT_PRI_LEVEL7   0x000000E0

Referenced by IntPrioritySet().

#define INT_PRIORITY_MASK   0x000000E0