|
SunSPOT API V6.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.spot.resources.Resource
com.sun.spot.sensorboard.hardware.SimpleSPIControlledIOChip
com.sun.spot.sensorboard.hardware.ADT7411
public class ADT7411
Class implementing SPI access to the ADT7411 a-to-d converter. It extends SimpleSPIControlledIOChip and provides a constructor that initializes the device. This initialized ADT7411 object can then be used by the classes derived from AbstractADT7411RangeInput to communicate with the device.
Note: by default the ADT7411 uses the slow conversion rate so as to make sure readings of A0 are correct. To read faster than every 17.1 milliseconds, ~58Hz, requires setting the ADT7411 to use its fast conversion rate.
Note: by default the ADT7411 reads all of the channels, one after the other, in round robin mode. If a program needs to read values faster then it should put the ADT7411 into single channel mode. However doing so will break the code used to read the accelerometer, the analog inputs A0-A3 and the internal thermometer. In single channel mode it is the programmer's responsibility to set the channel before reading.
| Field Summary | |
|---|---|
static int |
SPI_CONFIG
How the SPI needs to be configured for ADT7411 |
static int |
SPI_CONFIG8
|
| 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 |
setFastConversion(boolean val)
Set the fast/slow conversion rate bit of the ADC. |
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 com.sun.spot.resources.Resource |
|---|
addTag, getTags, getTagValue, hasTag, removeTag |
| 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 |
| Methods inherited from interface com.sun.spot.resources.IResource |
|---|
addTag, getTags, getTagValue, hasTag, removeTag |
| Field Detail |
|---|
public static final int SPI_CONFIG
public static final int SPI_CONFIG8
| Constructor Detail |
|---|
public ADT7411(ISPI spi)
spi - ISPI to be used to access the device
public ADT7411(ISPI spi,
boolean init)
spi - ISPI to be used to access the deviceinit - if true then initialize the device| Method Detail |
|---|
public void setUp()
setUp in interface IDriverpublic boolean tearDown()
tearDown in interface IDriverpublic void setAveraging(boolean val)
When averaging is active the sample rate is slower.
setAveraging in interface IADT7411val - if true set averaging onpublic void setFastConversion(boolean val)
Update time in milliseconds: fast/slow
Round robin mode, w/averaging off: 0.58 / 17.1
Round robin mode, w/averaging on: 9.26 / 125.4
Single channel mode, w/averaging off: 0.04 / 0.71
Single channel mode, w/averaging on: 0.71 / 11.4
Note: reading values for A0 at the fast rate may be inaccurate.
setFastConversion in interface IADT7411val - if true set to the fast conversion ratepublic byte read(byte addr)
read in interface IADT7411addr - address to be read
public void write(byte addr,
byte value)
write in interface IADT7411addr - address to writevalue - to be writtenpublic int readPin(int idx)
idx - number of pin to read.
public void setThresholdValues(int pin,
int low,
int high)
pin - pin to be monitored.low - the new low threshold value.high - the new high threshold value.public int getHighThreshold(int pin)
pin - pin to be read
public int getLowThreshold(int pin)
pin - pin to be read
public void enableThresholdEvents(int pin,
boolean enable)
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.public boolean areThresholdEventsEnabled(int pin)
pin - pin to be read
public int checkInterrupts()
public String getDriverName()
getDriverName in interface IDriverpublic void shutDown()
IDriver
shutDown in interface IDriver
|
SunSPOT API V6.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||