|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--stamp.peripheral.io.PCF8574
This class provides an interface to the Philips PCF8574 (8-bit bi- directional port expander). PCF8574 inputs and outputs are active low; pins used as inputs should be pulled-up to Vdd through 10K.
To create a PCF8574 object, the programmer will usually define a [shared] I2C bus object first and pass this object to the PCF8574 constructor.
I2C ioBus = new I2C(CPU.pin0, CPU.pin1);
PCF8574 ioPort = new PCF8574(ioBus, 0x00, 0xF0);
If a single PCF8574 is the only I2C device connected to the Javelin, an alternate constructor may be used that creates the necessary I2C bus. Note that this bus is private to the PCF8574 and cannot be shared with any other device.
PCF8574 ioPort = new PCF8574(CPU.pin0, CPU.pin1, 0x00, 0xF0);
For additonal operational details, consult Philips documentation for the PCF8574.
Constructor Summary | |
PCF8574(I2C bus,
int devAddr,
int dirs)
Create PCF8574 object |
|
PCF8574(int sdaPin,
int sclPin,
int devAddr,
int dirs)
Create PCF8574 object with private I2C bus. |
Method Summary | |
boolean |
isPresent()
Check for presence of specific PCF8574 device. |
int |
read()
Get PCF8574 inputs (pins masked with dirs value) |
void |
write(int outData)
Set PCF8574 outputs (pins masked with dirs value). |
Methods inherited from class java.lang.Object |
equals |
Constructor Detail |
public PCF8574(I2C bus, int devAddr, int dirs)
bus
- I2C bus objectdevAddr
- Device address (0 .. 7)dirs
- PCF8574 pin directions (1 = input, 0 = output)public PCF8574(int sdaPin, int sclPin, int devAddr, int dirs)
sdaPin
- I2C serial data pinsclPin
- I2C serial clock pindevAddr
- Device address (0 .. 7)dirs
- PCF8574 pin directions (1 = input, 0 = output)Method Detail |
public boolean isPresent()
public void write(int outData)
outData
- Data to write to PCF8574 portpublic int read()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |