com.dalsemi.system
Class I2CPort
java.lang.Object
|
+--com.dalsemi.system.I2CPort
- public class I2CPort
- extends java.lang.Object
This class encapsulates I2C protocol using one of two resources:
1. P5.0(SCL) and P5.1(SDA)
2. Any two memory mapped IO areas. Masks required to select
bit or bits within byte for SCL and SDA.
|
Constructor Summary |
I2CPort()
Use processor port pin P5.0 for SCL and P5.1 for SDA. |
I2CPort(byte SCLChipSelect,
int SCLOffset,
byte SCLMask,
byte SDAChipSelect,
int SDAOffset,
byte SDAMask)
Use memory mapped IO address for SCL and SDA pins. |
|
Method Summary |
int |
getStretchCycles()
Get the MOVX stretch cycles for read/write. |
int |
read(byte[] barr,
int len)
Read into the byte array from the current slave address |
void |
setAddress(byte address)
Set the I2C slave address. |
void |
setClockDelay(byte delay)
Set the clock delay for the I2C bus. |
void |
setStretchCycles(byte stretch)
Set the MOVX stretch cycles for read/write. |
int |
write(byte[] barr,
int len)
Write the byte array to the current slave address |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
CE0
public static final byte CE0
CE1
public static final byte CE1
CE2
public static final byte CE2
CE3
public static final byte CE3
PCE0
public static final byte PCE0
PCE1
public static final byte PCE1
PCE2
public static final byte PCE2
PCE3
public static final byte PCE3
STRETCH2
public static final byte STRETCH2
STRETCH3
public static final byte STRETCH3
STRETCH4
public static final byte STRETCH4
STRETCH5
public static final byte STRETCH5
STRETCH9
public static final byte STRETCH9
STRETCH10
public static final byte STRETCH10
STRETCH11
public static final byte STRETCH11
STRETCH12
public static final byte STRETCH12
latchValue
public int latchValue
stretchCycles
public byte stretchCycles
slaveAddress
public byte slaveAddress
clockDelay
public byte clockDelay
I2CStretchCycles
public byte I2CStretchCycles
SCLChipSelect
public byte SCLChipSelect
SCLOffset
public int SCLOffset
SCLMask
public byte SCLMask
SDAChipSelect
public byte SDAChipSelect
SDAOffset
public int SDAOffset
SDAMask
public byte SDAMask
I2CPort
public I2CPort()
- Use processor port pin P5.0 for SCL and P5.1 for SDA.
I2CPort
public I2CPort(byte SCLChipSelect,
int SCLOffset,
byte SCLMask,
byte SDAChipSelect,
int SDAOffset,
byte SDAMask)
- Use memory mapped IO address for SCL and SDA pins.
- Parameters:
SCLChipSelect - Descriptor of chipselect to use.SCLOffset - Offset from the chip select.SCLMask - Mask of bit or bits to use.SDAChipSelect - Descriptor of chipselect to use.SDAOffset - Offset from the chip select.SDAMask - Mask of bit or bits to use.
setAddress
public void setAddress(byte address)
- Set the I2C slave address.
This address will take effect on the next read or write.
- Parameters:
address - Addres of I2C slave device.
setClockDelay
public void setClockDelay(byte delay)
- Set the clock delay for the I2C bus.
- Parameters:
delay - I2C Clock delay
setStretchCycles
public void setStretchCycles(byte stretch)
throws java.io.IOException
- Set the MOVX stretch cycles for read/write.
- Parameters:
stretch - Stretch cycle value.- Throws:
- java.io.IOException - if stretch is out of range.
getStretchCycles
public int getStretchCycles()
- Get the MOVX stretch cycles for read/write.
- Returns:
- Stretch cycle value.
write
public int write(byte[] barr,
int len)
- Write the byte array to the current slave address
- Parameters:
barr - Array of bytes to sendlen - Length of bytes to send- Returns:
- -1 on error
read
public int read(byte[] barr,
int len)
- Read into the byte array from the current slave address
- Parameters:
barr - Array to fill from read operationlen - Length of bytes to read- Returns:
- -1 on error