15.3.2 Syntax for Writing ISRs
To declare a C function as an interrupt handler, tag the function with
the interrupt attribute (see the Function Attributes section for a description of the __attribute__
keyword).
The syntax of the interrupt attribute is:
__attribute__((interrupt [(
[ save(symbol-list)]
[, irq(irqid)]
[, preprologue(asm)]
)]
))
The interrupt
attribute name and the parameter names
may be written with a pair of underscore characters before and after the name. Thus,
interrupt
and __interrupt__
are equivalent, as are
save
and __save__
.
The optional save
parameter names a list of one or more
variables that are to be saved and restored on entry to and exit from the ISR. The list
of names is written inside parentheses, with the names separated by commas.
You should arrange to save global variables that may be modified in an
ISR if you do not want the value to be exported. Global variables accessed by an ISR
should be qualified volatile
.
The optional irq
parameter allows you to place an
interrupt vector at a specific interrupt. Each parameter requires a parenthesized
interrupt ID number (see the Specifying the Interrupt Vector section for a list of interrupt IDs).
The optional preprologue
parameter allows you to insert
assembly-language statements into the generated code immediately before the
compiler-generated function prologue.