com.sentilla.platform.tmote
Class InterruptPin

java.lang.Object
  extended by com.sentilla.platform.tmote.Action
      extended by com.sentilla.platform.tmote.DigitalPin
          extended by com.sentilla.platform.tmote.InterruptPin
All Implemented Interfaces:
Action, DigitalPin, InterruptPin
Direct Known Subclasses:
Button

public class InterruptPin
extends DigitalPin
implements InterruptPin

Creates an action for interruptable single pins of digital input/output on the tmote platform.

Valid interrupt pins on the tmote platform are 0x10-0x17 (Port 1.0 through Port 1.7) and 0x20-0x27 (Port 2.0 through Port 2.7).

The action verb edge completes upon the satification of the triggering condition for a particular unit of digital I/O. Similarly the setter setEdge enables the conditions that qualify a digital I/O interrrupt action for caching. The getter getEdgeTime provides a marker of when I/O triggering conditions were satisfied. The getter isRisingEdge is a predicate returning the state of the specific I/O unit.

See Also:
InterruptPinDriver

Field Summary
 
Fields inherited from class com.sentilla.platform.tmote.DigitalPin
digitalPinCmd, digitalPinId, digitalPinPortmask, digitalPinTime, digitalPinValue, EDGE_CHANGE, EDGE_FALLING, EDGE_RISING, GET_PORT, GET_VALUE, SET_PORT, SET_VALUE
 
Fields inherited from class com.sentilla.platform.tmote.Action
actionAuto, actionId, actionState, isolateOwner
 
Fields inherited from interface com.sentilla.system.Action
DONE, ERROR, IDLE, PENDING
 
Constructor Summary
InterruptPin(int id)
          Create an object to capture interrupt events from a digital input/output pin.
 
Method Summary
protected  boolean checkId(int id)
          Checks that the Id is within bounds for this platform.
 void edge(boolean onFalling, boolean onRising)
          Blocks until the pin state changes on an interrupt edge.
 int getEdgeTime()
          Get the time of the last event
 boolean isRisingEdge()
          Check the condition of the last event.
 InterruptPin setEdge(boolean onFalling, boolean onRising)
          Asynchronous interface to set the conditions for detection.
 
Methods inherited from class com.sentilla.platform.tmote.DigitalPin
getId, getTime, getValue, read, read, readPort, setId, setRead, setWrite, write, write, writePort
 
Methods inherited from class com.sentilla.platform.tmote.Action
block, block, cancel, getActionState, initAction, isDone, lookup, submit
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sentilla.system.DigitalPin
getId, getTime, getValue, read, setRead, setWrite, write, writePort
 
Methods inherited from interface com.sentilla.system.Action
block, block, cancel, getActionState, isDone, submit
 

Constructor Detail

InterruptPin

public InterruptPin(int id)
Create an object to capture interrupt events from a digital input/output pin.

id is specified by port and pin value in hex. For example, Port 2, Pin 3 is represented by id 0x23.

Parameters:
id - The interrupt pin identifier
Throws:
IllegalArgumentException - when the given id does not exist on the tmote platform
Method Detail

checkId

protected boolean checkId(int id)
Description copied from class: DigitalPin
Checks that the Id is within bounds for this platform.

Overrides:
checkId in class DigitalPin
Parameters:
id - Pin identity to check
Returns:
true if the id is valid

edge

public void edge(boolean onFalling,
                 boolean onRising)
Description copied from interface: InterruptPin
Blocks until the pin state changes on an interrupt edge. Set both onFalling and onRising to true to trigger on any edge change.

Note: If both onFalling and onRising are set to false, the edge() function will never return.

Specified by:
edge in interface InterruptPin
Parameters:
onFalling - true if the function should return control after a falling edge is detected
onRising - true if the function should return control after a falling edge is detected

setEdge

public InterruptPin setEdge(boolean onFalling,
                            boolean onRising)
Description copied from interface: InterruptPin
Asynchronous interface to set the conditions for detection. Must be initiated with the submit function.

Specified by:
setEdge in interface InterruptPin
Parameters:
onFalling - true if the function should return control after a falling edge is detected
onRising - true if the function should return control after a falling edge is detected
Returns:
Instance of InterruptPin that is set

isRisingEdge

public boolean isRisingEdge()
Description copied from interface: InterruptPin
Check the condition of the last event. Returns true if the last event was caused by a rising edge condition.

Specified by:
isRisingEdge in interface InterruptPin
Returns:
true if the edge was rising

getEdgeTime

public int getEdgeTime()
Description copied from interface: InterruptPin
Get the time of the last event

Specified by:
getEdgeTime in interface InterruptPin
Returns:
the system's local time in milliseconds at the last event


Copyright © 2007 Sentilla Corporation. All Rights Reserved.