|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IAT91_AIC
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)
.
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 |
---|
static final int SRCTYPE_POSITIVE_EDGE
static final int SRCTYPE_HIGH_LEVEL
static final int SRCTYPE_EXT_NEGATIVE_EDGE
static final int SRCTYPE_EXT_LOW_LEVEL
static final int AIC_IRQ_PRI_NORMAL
Method Detail |
---|
void configure(int irq, int pri, int mode)
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_SMRfor constants that define the interrupts.
Select one of the modes defined by the SRCTYPE constants in this file
void enableIrq(int irq)
irq
- irq mask (ie one bit set according to which interrupt we are handling)void waitForInterrupt(int irq)
irq
- irq mask (ie one bit set according to which interrupt we are handling)void disableIrq(int irq)
irq
- irq mask (ie one bit set according to which interrupt we are handling)void clearIrq(int irq)
irq
- irq mask (ie one bit set according to which interrupt we are handling)boolean isEnabled(int irq)
irq
- irq mask (ie one bit set according to which interrupt we are handling)
|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |