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

§ IntDisable()

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(), FlashIntUnregister(), I2CIntUnregister(), I2SIntUnregister(), IOCIntUnregister(), SHA2IntUnregister(), SSIIntUnregister(), TimerIntUnregister(), TRNGIntUnregister(), UARTIntUnregister(), uDMAIntUnregister(), and WatchdogIntUnregister().

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

§ IntEnable()

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_AON_RTC_COMB
    • INT_UART0_COMB
    • INT_AUX_SWEV0
    • INT_SSI0_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_BATMON_COMB
    • INT_PKA_IRQ
    • INT_SSI1_COMB
    • INT_UART1_COMB
    • INT_AUX_TIMER2_EV0
Returns
None
See also
IntDisable()

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

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

§ IntMasterDisable()

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.
584 {
585  // Disable CPU interrupts.
586  return(CPUcpsid());
587 }
uint32_t CPUcpsid(void)
Disable all external interrupts.
Definition: cpu.c:66
Here is the call graph for this function:

§ IntMasterEnable()

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.
564 {
565  // Enable CPU interrupts.
566  return(CPUcpsie());
567 }
uint32_t CPUcpsie(void)
Enable all external interrupts.
Definition: cpu.c:204
Here is the call graph for this function:

§ IntPendClear()

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(), and SetupTrimDevice().

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

§ IntPendGet()

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.
409 {
410  uint32_t ui32IntPending;
411 
412  // Check the arguments.
413  ASSERT(ui32Interrupt < NUM_INTERRUPTS);
414 
415  // Assume no interrupts are pending.
416  ui32IntPending = 0;
417 
418  // The lower 16 IRQ vectors are unsupported by this function
419  if (ui32Interrupt < 16)
420  {
421 
422  return 0;
423  }
424 
425  // Subtract lower 16 irq vectors
426  ui32Interrupt -= 16;
427 
428  // Check if the interrupt is pending
429  ui32IntPending = HWREG(NVIC_PEND0 + (ui32Interrupt / 32));
430  ui32IntPending &= (1 << (ui32Interrupt & 31));
431 
432  return ui32IntPending ? true : false;
433 }
#define ASSERT(expr)
Definition: debug.h:71

§ IntPendSet()

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_AON_RTC_COMB
    • INT_UART0_COMB
    • INT_AUX_SWEV0
    • INT_SSI0_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_BATMON_COMB
    • INT_PKA_IRQ
    • INT_SSI1_COMB
    • INT_UART1_COMB
    • INT_AUX_TIMER2_EV0
Returns
None
See also
IntEnable()
370 {
371  // Check the arguments.
372  ASSERT(ui32Interrupt < NUM_INTERRUPTS);
373 
374  // Determine the interrupt to pend.
375  if(ui32Interrupt == INT_NMI_FAULT)
376  {
377  // Pend the NMI interrupt.
378  HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_NMI_SET;
379  }
380  else if(ui32Interrupt == INT_PENDSV)
381  {
382  // Pend the PendSV interrupt.
383  HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PEND_SV;
384  }
385  else if(ui32Interrupt == INT_SYSTICK)
386  {
387  // Pend the SysTick interrupt.
388  HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PENDSTSET;
389  }
390  else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
391  {
392  // Pend the general interrupt.
393  HWREG(NVIC_PEND0) = 1 << (ui32Interrupt - 16);
394  }
395  else if(ui32Interrupt >= 48)
396  {
397  // Pend the general interrupt.
398  HWREG(NVIC_PEND1) = 1 << (ui32Interrupt - 48);
399  }
400 }
#define ASSERT(expr)
Definition: debug.h:71

§ IntPriorityGet()

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:
266 {
267  // Check the arguments.
268  ASSERT((ui32Interrupt >= 4) && (ui32Interrupt < NUM_INTERRUPTS));
269 
270  // Return the interrupt priority.
271  return((HWREG(g_pui32Regs[ui32Interrupt >> 2]) >> (8 * (ui32Interrupt & 3))) &
272  0xFF);
273 }
static const uint32_t g_pui32Regs[]
Definition: interrupt.c:89
#define ASSERT(expr)
Definition: debug.h:71

§ IntPriorityGroupingGet()

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
218 {
219  uint32_t ui32Loop, ui32Value;
220 
221  // Read the priority grouping.
222  ui32Value = HWREG(NVIC_APINT) & NVIC_APINT_PRIGROUP_M;
223 
224  // Loop through the priority grouping values.
225  for(ui32Loop = 0; ui32Loop < NUM_PRIORITY; ui32Loop++)
226  {
227  // Stop looping if this value matches.
228  if(ui32Value == g_pui32Priority[ui32Loop])
229  {
230  break;
231  }
232  }
233 
234  // Return the number of priority bits.
235  return(ui32Loop);
236 }
static const uint32_t g_pui32Priority[]
Definition: interrupt.c:76

§ IntPriorityGroupingSet()

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()
203 {
204  // Check the arguments.
205  ASSERT(ui32Bits < NUM_PRIORITY);
206 
207  // Set the priority grouping.
208  HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | g_pui32Priority[ui32Bits];
209 }
#define ASSERT(expr)
Definition: debug.h:71
static const uint32_t g_pui32Priority[]
Definition: interrupt.c:76

§ IntPriorityMaskGet()

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.
641 {
642  return(CPUbasepriGet());
643 }
uint32_t CPUbasepriGet(void)
Get the interrupt priority disable level.
Definition: cpu.c:275
Here is the call graph for this function:

§ IntPriorityMaskSet()

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.
619 {
620  CPUbasepriSet(ui32PriorityMask);
621 }
static void CPUbasepriSet(uint32_t ui32NewBasepri)
Update the interrupt priority disable level.
Definition: cpu.h:334
Here is the call graph for this function:

§ IntPrioritySet()

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_AON_RTC_COMB
    • INT_UART0_COMB
    • INT_AUX_SWEV0
    • INT_SSI0_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_BATMON_COMB
    • INT_PKA_IRQ
    • INT_SSI1_COMB
    • INT_UART1_COMB
    • INT_AUX_TIMER2_EV0
ui8Priorityspecifies the priority of the interrupt.
Returns
None
See also
IntPriorityGroupingSet()
245 {
246  uint32_t ui32Temp;
247 
248  // Check the arguments.
249  ASSERT((ui32Interrupt >= 4) && (ui32Interrupt < NUM_INTERRUPTS));
250  ASSERT(ui8Priority <= INT_PRI_LEVEL7);
251 
252  // Set the interrupt priority.
253  ui32Temp = HWREG(g_pui32Regs[ui32Interrupt >> 2]);
254  ui32Temp &= ~(0xFF << (8 * (ui32Interrupt & 3)));
255  ui32Temp |= ui8Priority << (8 * (ui32Interrupt & 3));
256  HWREG(g_pui32Regs[ui32Interrupt >> 2]) = ui32Temp;
257 }
static const uint32_t g_pui32Regs[]
Definition: interrupt.c:89
#define INT_PRI_LEVEL7
Definition: interrupt.h:113
#define ASSERT(expr)
Definition: debug.h:71

§ IntRegister()

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_AON_RTC_COMB
    • INT_UART0_COMB
    • INT_AUX_SWEV0
    • INT_SSI0_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_BATMON_COMB
    • INT_PKA_IRQ
    • INT_SSI1_COMB
    • INT_UART1_COMB
    • INT_AUX_TIMER2_EV0
pfnHandleris a pointer to the function to register as interrupt handler.
Returns
None.
See also
IntUnregister(), IntEnable()

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

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

§ IntUnregister()

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(), FlashIntUnregister(), I2CIntUnregister(), I2SIntUnregister(), IOCIntUnregister(), SHA2IntUnregister(), SSIIntUnregister(), SysTickIntUnregister(), TimerIntUnregister(), TRNGIntUnregister(), UARTIntUnregister(), uDMAIntUnregister(), and WatchdogIntUnregister().

188 {
189  // Check the arguments.
190  ASSERT(ui32Interrupt < NUM_INTERRUPTS);
191 
192  // Reset the interrupt handler.
193  g_pfnRAMVectors[ui32Interrupt] = IntDefaultHandler;
194 }
void(* g_pfnRAMVectors[NUM_INTERRUPTS])(void)
Global pointer to the (dynamic) interrupt vector table when placed in SRAM.
Definition: interrupt.c:129
#define ASSERT(expr)
Definition: debug.h:71
static void IntDefaultHandler(void)
The default interrupt handler.
Definition: interrupt.c:109
Here is the call graph for this function:

Macro Definition Documentation

§ INT_PRI_LEVEL0

#define INT_PRI_LEVEL0   0x00000000

§ INT_PRI_LEVEL1

#define INT_PRI_LEVEL1   0x00000020

§ INT_PRI_LEVEL2

#define INT_PRI_LEVEL2   0x00000040

§ INT_PRI_LEVEL3

#define INT_PRI_LEVEL3   0x00000060

§ INT_PRI_LEVEL4

#define INT_PRI_LEVEL4   0x00000080

§ INT_PRI_LEVEL5

#define INT_PRI_LEVEL5   0x000000A0

§ INT_PRI_LEVEL6

#define INT_PRI_LEVEL6   0x000000C0

§ INT_PRI_LEVEL7

#define INT_PRI_LEVEL7   0x000000E0

Referenced by IntPrioritySet().

§ INT_PRIORITY_MASK

#define INT_PRIORITY_MASK   0x000000E0