SunSPOT API V3.0


com.sun.spot.sensorboard.hardware
Class ADT7411

java.lang.Object
  extended by com.sun.spot.sensorboard.hardware.SimpleSPIControlledIOChip
      extended by com.sun.spot.sensorboard.hardware.ADT7411
All Implemented Interfaces:
IDriver, IADT7411, ISPIControlledIOChip

public class ADT7411
extends SimpleSPIControlledIOChip
implements IDriver, IADT7411

Class implementing SPI access to the ADT7411 a-to-d converter. It extends SimpleSPIControlledIOChip and provides a constructor that initialises the device. This initialised ADT7411 object can then be used by the classes derived from AbstractADT7411RangeInput to communicate with the device.

Author:
Syntropy & Ron Goldman

Field Summary
static int SPI_CONFIG
          How the SPI needs to be configured for ADT7411
 
Constructor Summary
ADT7411(ISPI spi)
          Constructor that initialises the device.
ADT7411(ISPI spi, boolean init)
          Constructor that maybe initialises the device.
 
Method Summary
 boolean areThresholdEventsEnabled(int pin)
          Return whether threshold events are enabled or disabled.
 int checkInterrupts()
          Check if any interrupts have occurred.
 void enableThresholdEvents(int pin, boolean enable)
          Enable or disable threshold events.
 String getDriverName()
          Routine to return this driver's name.
 int getHighThreshold(int pin)
          Return the current high threshold value for this scalar input.
 int getLowThreshold(int pin)
          Return the current low threshold value for this scalar input.
 byte read(byte addr)
          Read a byte from the ADC.
 int readPin(int idx)
          Read the current value of one of the inputs to the ADC.
 void setAveraging(boolean val)
          Set the global averaging bit of the ADC, if set to true then the part will internally sample 16 times before setting the average value, if false that behaviour is turned off.
 void setThresholdValues(int pin, int low, int high)
          Set the low and high threshold values for this scalar input.
 void setUp()
          Driver routine called to initialize the ADT7411 when powering up the sensor board.
 void shutDown()
          Notify the driver that the VM is about to exit.
 boolean tearDown()
          Driver routine called before powering down sensor board (for deep sleep).
 void write(byte addr, byte value)
          Write a byte to the ADC.
 
Methods inherited from class com.sun.spot.sensorboard.hardware.SimpleSPIControlledIOChip
claimedPins, claimPin, getSPI
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.spot.sensorboard.hardware.ISPIControlledIOChip
claimedPins, claimPin, getSPI
 

Field Detail

SPI_CONFIG

public static final int SPI_CONFIG
How the SPI needs to be configured for ADT7411

See Also:
Constant Field Values
Constructor Detail

ADT7411

public ADT7411(ISPI spi)
Constructor that initialises the device.

Parameters:
spi - ISPI to be used to access the device

ADT7411

public ADT7411(ISPI spi,
               boolean init)
Constructor that maybe initialises the device.

Parameters:
spi - ISPI to be used to access the device
init - if true then initialize the device
Method Detail

setUp

public void setUp()
Driver routine called to initialize the ADT7411 when powering up the sensor board.

Specified by:
setUp in interface IDriver

tearDown

public boolean tearDown()
Driver routine called before powering down sensor board (for deep sleep).

Specified by:
tearDown in interface IDriver
Returns:
true = always ok to deactivate ADT7411 device

setAveraging

public void setAveraging(boolean val)
Set the global averaging bit of the ADC, if set to true then the part will internally sample 16 times before setting the average value, if false that behaviour is turned off. When averaging is active the sample rate is slower.

Parameters:
val - if true set averaging on

read

public byte read(byte addr)
Read a byte from the ADC.

Specified by:
read in interface IADT7411
Parameters:
addr - address to be read
Returns:
byte read

write

public void write(byte addr,
                  byte value)
Write a byte to the ADC.

Specified by:
write in interface IADT7411
Parameters:
addr - address to write
value - to be written

readPin

public int readPin(int idx)
Read the current value of one of the inputs to the ADC.

Parameters:
idx - number of pin to read.
Returns:
the value read.

setThresholdValues

public void setThresholdValues(int pin,
                               int low,
                               int high)
Set the low and high threshold values for this scalar input. Callbacks occur when the scalar input reading falls below or equal to the low threshold value, or when it rises above or equal to the high threshold value. Note: the ADT7411, only compares against the most significant 8-bits.

Parameters:
pin - pin to be monitored.
low - the new low threshold value.
high - the new high threshold value.

getHighThreshold

public int getHighThreshold(int pin)
Return the current high threshold value for this scalar input.

Parameters:
pin - pin to be read
Returns:
the current high threshold value.

getLowThreshold

public int getLowThreshold(int pin)
Return the current low threshold value for this scalar input.

Parameters:
pin - pin to be read
Returns:
the current low threshold value.

enableThresholdEvents

public void enableThresholdEvents(int pin,
                                  boolean enable)
Enable or disable threshold events. Should not be called by user applications.

Parameters:
pin - pin to be monitored.
enable - if true then listeners will be notified if the scalar input reading goes above the high threshold or below the low threshold.

areThresholdEventsEnabled

public boolean areThresholdEventsEnabled(int pin)
Return whether threshold events are enabled or disabled.

Parameters:
pin - pin to be read
Returns:
true if events are enabled

checkInterrupts

public int checkInterrupts()
Check if any interrupts have occurred. If so disable any interrupts that have triggered. Called by EDemoBoard interrupt handler. Should not be called by user applications.

Returns:
a bitmask with a bit set for each interrupt that has triggered

getDriverName

public String getDriverName()
Routine to return this driver's name.

Specified by:
getDriverName in interface IDriver
Returns:
this driver's name

shutDown

public void shutDown()
Description copied from interface: IDriver
Notify the driver that the VM is about to exit.

Specified by:
shutDown in interface IDriver

SunSPOT API V3.0


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