Interrupt handlers – Comtrol eCos User Manual

Page 88

Advertising
background image

Interrupt Handling

The exact details of interrupt handling vary widely between architectures. The functionality provided by the kernel
abstracts away from many of the details of the underlying hardware, thus simplifying application development.
However this is not always successful. For example, if some hardware does not provide any support at all for
masking specific interrupts then calling

cyg_interrupt_mask

may not behave as intended: instead of masking

just the one interrupt source it might disable all interrupts, because that is as close to the desired behaviour as is
possible given the hardware restrictions. Another possibility is that masking a given interrupt source also affects all
lower-priority interrupts, but still allows higher-priority ones. The documentation for the appropriate HAL packages
should be consulted for more information about exactly how interrupts are handled on any given hardware. The
HAL header files will also contain useful information.

Interrupt Handlers

Interrupt handlers are created by a call to

cyg_interrupt_create

. This takes the following arguments:

cyg_vector_t

vector

The interrupt vector, a small integer, identifies the specific interrupt source. The appropriate hardware docu-
mentation or HAL header files should be consulted for details of which vector corresponds to which device.

cyg_priority_t

priority

Some hardware may support interrupt priorities, where a low priority interrupt handler can in turn be inter-
rupted by a higher priority one. Again hardware-specific documentation should be consulted for details about
what the valid interrupt priority levels are.

cyg_addrword_t

data

When an interrupt occurs eCos will first call the associated interrupt service routine or ISR, then optionally
a deferred service routine or DSR. The

data

argument to

cyg_interrupt_create

will be passed to both

these functions. Typically it will be a pointer to some data structure.

cyg_ISR_t

isr

When an interrupt occurs the hardware will transfer control to the appropriate vector service routine or VSR,
which is usually provided by eCos. This performs any appropriate processing, for example to work out exactly
which interrupt occurred, and then as quickly as possible transfers control the installed ISR. An ISR is a C
function which takes the following form:

cyg_uint32

isr_function(cyg_vector_t vector, cyg_addrword_t data)

{

cyg_bool_t dsr_required = 0;

...

return dsr_required ? CYG_ISR_CALL_DSR : CYG_ISR_HANDLED;

}

The first argument identifies the particular interrupt source, especially useful if there multiple instances of
a given device and a single ISR can be used for several different interrupt vectors. The second argument
is the

data

field passed to

cyg_interrupt_create

, usually a pointer to some data structure. The exact

conditions under which an ISR runs will depend partly on the hardware and partly on configuration options.

88

Advertising