Chapter 15. Low-Level Programming <intrrpt.h>

The file <intrrpt.h> is similar to the file <signal.h> but declares macros and functions for interrupt handling rather than signal handling.

The macros defined are:




which expand to constant expressions with distinct values that are type compatible with the second argument to and the return value of the handler function, and whose value compares unequal to the address of any declarable function; and the following, each of which expands to a positive integral constant expression that is the signal number corresponding to the specified condition.

For the M1750 the interrupt numbers are defined as follows:

#define INTPWRDWN     0
#define INTMACHERR    1
#define INTSPARE1     2
#define INTFLVFLOW    3
#define INTFXVFLOW    4
#define INTBEX        5
#define INTFLUFLOW    6
#define INTTIMERA     7
#define INTSPARE2     8
#define INTTIMERB     9
#define INTSPARE3    10
#define INTSPARE4    11
#define INTLEVEL1    12
#define INTSPARE5    13
#define INTLEVEL2    14
#define INTSPARE6    15

For the ERC32 the interrupt numbers are defined as follows:

#define INTMASKED_ERRORS             1
#define INTEXTERNAL_0                2
#define INTEXTERNAL_1                3
#define INTUART_A_RX_TX              4
#define INTUART_B_RX_TX              5
#define INTUART_ERROR                7
#define INTDMA_ACCESS_ERROR          8
#define INTDMA_TIMEOUT               9
#define INTEXTERNAL_2                10
#define INTEXTERNAL_3                11
#define INTREAL_TIME_CLOCK           13
#define INTEXTERNAL_4                14
#define INTWATCHDOG_TIMEOUT          15

15.1. Interrupt Handling Functions

15.1.1. The handler function

#include <intrrpt.h>

(*handler (int i, void (*func)(int)))handler ( int );


The handler function chooses one of three ways in which receipt of the interrupt number i is to subsequently handled. If the value of func is INT_DFL, default handling for that interrupt will occur. If the value of func is INT_IGN, the interrupt will be ignored. Otherwise func shall point to a function to be called when the interrupt occurs. Such a function is called a interrupt handler.

When a interrupt occurs, if func points to a function, first the equivalent of handler(INT,INT_DFL); is executed or an implementation-defined blocking of the interrupt is performed. Next the equivalent of (*func)(i); is executed. The function func may terminate by executing a return statement or by calling the abort, exit or longjmp function. If func executes a return statement, and the value of i was INTFPE or any other implementation-defined value corresponding to a computational exception, the behavior is undefined. Otherwise, the program will resume execution at the point it was interrupted.

At program startup, the equivalent of handler(sig, INT_IGN); is executed for some interrupt selected in an implementation-defined manner, the equivalent of handler(i, INT_DFL); is executed for all other interrupts defined by the implementation.


If the request can be honored, the handler function returns the value of func for the most recent call to handler for the specified interrupt i. Otherwise a value of INT_ERR is returned and a positive value is stored in errno.

See Also

The abort function, Section 10.4.1

The exit function, Section 10.4.3