SunSPOT API V3.0


com.sun.spot.peripheral
Interface IAT91_AIC

All Superinterfaces:
IDriver

public interface IAT91_AIC
extends IDriver

The interface to the AT91 Interrupt Controller.

The Java interrupt handling mechanism works like this:

At startup the main() in os.c calls set_up_java_interrupts() in eb40a-io.c which puts the address of the generic asm interrupt handler in the Source Vector Register for every interrupt source available to Java. All other set up is done in Java.

The asm interrupt handler is java_irq_hndl in java_irq_hndl.s.

Communication between the asm interrupt handler and the C code is via an unsigned int called java_irq_status. Each bit represents a different irq. The handler sets the appropriate bit every time it handles an interrupt. The handler also masks the interrupt that has just occurred in the AIC to prevent another interrupt until the first has been serviced. The asm handler then signals "end of interrupt" to the AIC and returns.

A Java thread detects an interrupt by calling waitForInterrupt(int). This method performs a Channel IO request. If the appropriate bit in java_irq_status is set the bit is cleared and the request returns immediately. If not the calling thread is blocked until the interrupt occurs.

To handle an interrupt in Java you must:

1) Call configure(int, int, int) to set the interrupt priority and trigger mode
2) Configure the source device so that it will generate an interrupt request
3) Call enableIrq(int) to allow the AIC to receive the request
4) Call waitForInterrupt(int) to wait for the interrupt.
5) Do whatever processing is necessary to clear the request
6) Call enableIrq(int) to allow another interrupt.
7) Repeat from 4)

If you don't want more interrupts then don't call enableIrq(int).

Author:
Syntropy

Field Summary
static int AIC_IRQ_PRI_NORMAL
          Normal priority value (pri=4)
static int SRCTYPE_EXT_LOW_LEVEL
          Select low level triggered interrupt source (external sources only)
static int SRCTYPE_EXT_NEGATIVE_EDGE
          Select negative edge triggered interrupt source (external sources only)
static int SRCTYPE_HIGH_LEVEL
          Select high level triggered interrupt source
static int SRCTYPE_POSITIVE_EDGE
          Select positive edge triggered interrupt source
 
Method Summary
 void clearIrq(int irq)
          Clear any pending interrupt request for the specified IRQ.
 void configure(int irq, int pri, int mode)
          Configure an interrupt for java handling.
 void disableIrq(int irq)
          Disable interrupts from the selected source.
 void enableIrq(int irq)
          Enable interrupts from selected source.
 boolean isEnabled(int irq)
          Check whether the specified interrupt is enabled in the AIC hardware.
 void waitForInterrupt(int irq)
          Suspend this thread until the selected interrupt occurs.
 
Methods inherited from interface com.sun.spot.peripheral.IDriver
getDriverName, setUp, shutDown, tearDown
 

Field Detail

SRCTYPE_POSITIVE_EDGE

static final int SRCTYPE_POSITIVE_EDGE
Select positive edge triggered interrupt source

See Also:
Constant Field Values

SRCTYPE_HIGH_LEVEL

static final int SRCTYPE_HIGH_LEVEL
Select high level triggered interrupt source

See Also:
Constant Field Values

SRCTYPE_EXT_NEGATIVE_EDGE

static final int SRCTYPE_EXT_NEGATIVE_EDGE
Select negative edge triggered interrupt source (external sources only)

See Also:
Constant Field Values

SRCTYPE_EXT_LOW_LEVEL

static final int SRCTYPE_EXT_LOW_LEVEL
Select low level triggered interrupt source (external sources only)

See Also:
Constant Field Values

AIC_IRQ_PRI_NORMAL

static final int AIC_IRQ_PRI_NORMAL
Normal priority value (pri=4)

See Also:
Constant Field Values
Method Detail

configure

void configure(int irq,
               int pri,
               int mode)
Configure an interrupt for java handling.

Parameters:
irq - irq mask (ie one bit set according to which interrupt we are handling)
pri - priority (0 to 7, with 7 being the highest)
mode - word to write into AIC_SMR
See Also:
for constants that define the interrupts. Select one of the modes defined by the SRCTYPE constants in this file

enableIrq

void enableIrq(int irq)
Enable interrupts from selected source.

Parameters:
irq - irq mask (ie one bit set according to which interrupt we are handling)

waitForInterrupt

void waitForInterrupt(int irq)
Suspend this thread until the selected interrupt occurs.

Parameters:
irq - irq mask (ie one bit set according to which interrupt we are handling)

disableIrq

void disableIrq(int irq)
Disable interrupts from the selected source.

Parameters:
irq - irq mask (ie one bit set according to which interrupt we are handling)

clearIrq

void clearIrq(int irq)
Clear any pending interrupt request for the specified IRQ. Note that this only clears an interrupt that is pending in the AIC. If the interrupt has already been detected by the low-level handler then a subsequent waitForInterrupt() will still return immediately.

Parameters:
irq - irq mask (ie one bit set according to which interrupt we are handling)

isEnabled

boolean isEnabled(int irq)
Check whether the specified interrupt is enabled in the AIC hardware. Note that the interrupt will be disabled automatically when an interrupt occurs.

Parameters:
irq - irq mask (ie one bit set according to which interrupt we are handling)
Returns:
true if the interrupt is enabled in the AIC hardware

SunSPOT API V3.0


Copyright © 2006, 2007 Sun Microsystems, Inc. All Rights Reserved.