The INTERRUPT pragma enables you to handle interrupts directly with C code. In C, the argument func is the name of a function. In C++, the pragma applies to the next function declared.
The syntax of the pragma in C is:
#pragma INTERRUPT (func) |
The syntax of the pragma in C++ is:
#pragma INTERRUPT
void func( void ) |
The GCC interrupt attribute syntax, which has the same effects as the INTERRUPT pragma, is as follows. Note that the interrupt attribute can precede either the function's definition or its declaration.
__attribute__((interrupt)) void func( void ) |
On the FPU, there are two kinds of interrupts - High Priority Interrupt (HPI) and Low Priority Interrupt (LPI). High priority interrupts use a fast context save and cannot be nested. Low priority interrupts behave like normal C28x interrupts and can be nested.
The kind of interrupt can be specified by way of the interrupt pragma using an optional second argument. The C syntax of the pragma is:
#pragma INTERRUPT (func, {HPI|LPI} ) |
The syntax of the pragma in C++ is:
#pragma INTERRUPT ( {HPI|LPI} ) |
The syntax of the GCC interrupt attribute, which has the same effects as the INTERRUPT pragma, is:
__attribute__((interrupt("HPI"|"LPI" ))) void func( void )
{ ... } |
On FPU, if no interrupt priority is specified LPI is assumed. Interrupts specified with the interrupt keyword also default to LPI.
CLA interrupts and CLA2 background tasks can be created using the interrupt attribute or the INTERRUPT pragma. For example the following could both be used with a CLA interrupt:
__attribute__((interrupt))
void interrupt_name(void) {...}
#pragma INTERRUPT(interrupt _name);
void interrupt _name(void) {...}
The following examples both create a CLA2 background task:
__attribute__((interrupt("BACKGROUND")))
void task_name(void) {...}
#pragma INTERRUPT(task_name, "BACKGROUND");
void task_name(void) {...}
NOTE
Hwi Objects and the INTERRUPT PragmaThe INTERRUPT pragma must not be used when SYS/BIOS Hwi objects are used in conjunction with C functions. The Hwi_enter/Hwi_exit macros and the Hwi dispatcher contain this functionality, and the use of the C modifier can cause negative results.