| Modifier and Type | Class and Description |
|---|---|
static class |
I2C.Port
Enum representation of I2C ports on the RIO
|
Interface.InterfaceType| Modifier and Type | Field and Description |
|---|---|
private static boolean[] |
INITIALIZED_PORTS |
protected byte |
m_address |
protected byte |
m_port |
m_ifaceType, MAX_ANALOG_IN_CHANNELS, MAX_ANALOG_OUT_CHANNELS, MAX_DIGITAL_CHANNELS, MAX_PWM_CHANNELS, MAX_RELAY_CHANNELS| Constructor and Description |
|---|
I2C(I2C.Port port,
int address)
Constructor.
|
I2C(int address) |
| Modifier and Type | Method and Description |
|---|---|
void |
broadcast(int reg,
int data)
Send a broadcast write to all devices on the I2C bus.
|
boolean |
checkAddress()
Attempt to address a device on the I2C bus.
|
void |
free()
Destructor.
|
boolean |
read(int reg,
byte[] buffer,
int count)
Execute a read transaction with the device.
|
boolean |
readBit(int reg,
int bit)
Read a single bit from an 8-bit device register.
|
boolean |
readBit(int reg,
int bit,
byte[] data)
Read a single bit from an 8-bit device register.
|
boolean |
readBits(int reg,
int bitStart,
int length,
byte[] data)
Read multiple bits from an 8-bit device register.
|
boolean |
readByte(int reg,
byte[] data)
Read single byte from an 8-bit device register.
|
boolean |
readBytes(int reg,
byte[] data,
int length)
Read multiple bytes from an 8-bit device register.
|
boolean |
readOnly(byte[] buffer,
int count)
Execute a read only transaction with the device.
|
boolean |
readWord(int reg,
short[] data)
Read single word from a 16-bit device register.
|
boolean |
readWords(int reg,
short[] data,
int length)
Read multiple words from a 16-bit device register.
|
boolean |
transaction(byte[] dataToSend,
int sendSize,
byte[] dataReceived,
int receiveSize)
Generic transaction.
|
boolean |
verifySensor(int reg,
int count,
byte[] expected)
Verify that a device's registers contain expected values.
|
boolean |
write(int reg,
int data)
Execute a write transaction with the device.
|
boolean |
writeBit(int reg,
int bit,
boolean value)
write a single bit in an 8-bit device register.
|
boolean |
writeBit(int reg,
int bit,
byte value)
write a single bit in an 8-bit device register.
|
boolean |
writeBits(int reg,
int bitStart,
int length,
byte data)
Write multiple bits in an 8-bit device register.
|
boolean |
writeBulk(byte[] data)
Execute a write transaction with the device.
|
boolean |
writeByte(int reg,
byte data)
Write single byte to an 8-bit device register.
|
boolean |
writeBytes(int reg,
byte[] data,
int length)
Write multiple bytes to an 8-bit device register.
|
boolean |
writeWord(int reg,
short data)
Write single word to a 16-bit device register.
|
boolean |
writeWords(int reg,
short[] data,
int length)
Write multiple words to a 16-bit device register.
|
allocateMXPPin, checkAnalogInputChannel, checkAnalogOutputChannel, checkDigitalChannel, checkPWMChannel, checkRelayChannel, freeMXPPin, getInterfaceTypeprotected final byte m_port
protected final byte m_address
private static final boolean[] INITIALIZED_PORTS
public I2C(int address)
public I2C(I2C.Port port, int address)
port - The I2C port the device is connected to.address - The address of the device on the I2C bus.public void free()
public final boolean transaction(byte[] dataToSend,
int sendSize,
byte[] dataReceived,
int receiveSize)
dataToSend - Buffer of data to send as part of the transaction.sendSize - Number of bytes to send as part of the transaction.dataReceived - Buffer to read data into.receiveSize - Number of bytes to read from the device.public final boolean checkAddress()
public final boolean write(int reg,
int data)
reg - The address of the register on the device to be written.data - The byte to write to the register on the device.public final boolean writeBulk(byte[] data)
data - The data to write to the device.public final boolean writeBit(int reg,
int bit,
byte value)
reg - Register regAddr to write tobit - Bit position to write (0-7)value - New bit value to writepublic final boolean writeBit(int reg,
int bit,
boolean value)
reg - Register regAddr to write tobit - Bit position to write (0-7)value - New bit value to writepublic final boolean writeBits(int reg,
int bitStart,
int length,
byte data)
reg - Register regAddr to write tobitStart - First bit position to write (0-7)length - Number of bits to write (not more than 8)data - Right-aligned value to writepublic final boolean writeByte(int reg,
byte data)
reg - Register address to write todata - New byte value to writepublic final boolean writeWord(int reg,
short data)
reg - Register address to write todata - New word value to writepublic final boolean writeBytes(int reg,
byte[] data,
int length)
reg - First register address to write todata - Buffer to copy new data fromlength - Number of bytes to writepublic final boolean writeWords(int reg,
short[] data,
int length)
reg - First register address to write todata - Buffer to copy new data fromlength - Number of words to writepublic final boolean readBit(int reg,
int bit,
byte[] data)
reg - Register regAddr to read frombit - Bit position to read (0-7)data - Container for single bit valuepublic final boolean readBit(int reg,
int bit)
reg - Register regAddr to read frombit - Bit position to read (0-7)public final boolean readBits(int reg,
int bitStart,
int length,
byte[] data)
reg - Register regAddr to read frombitStart - First bit position to read (0-7)length - Number of bits to read (not more than 8)data - Container for right-aligned value (i.e. '101' read from any bitStart position will equal 0x05)public final boolean readByte(int reg,
byte[] data)
reg - Register regAddr to read fromdata - Container for byte value read from devicepublic final boolean readWord(int reg,
short[] data)
reg - Register regAddr to read fromdata - Container for word value read from devicepublic final boolean readBytes(int reg,
byte[] data,
int length)
reg - First register regAddr to read fromdata - Buffer to store read data inlength - Number of bytes to readpublic final boolean readWords(int reg,
short[] data,
int length)
reg - First register regAddr to read fromdata - Buffer to store read data inlength - Number of words to readpublic final boolean read(int reg,
byte[] buffer,
int count)
reg - The register to read first in the transaction.buffer - A pointer to the array of bytes to store the data read
from the device.count - The number of bytes to read in the transaction.public final boolean readOnly(byte[] buffer,
int count)
buffer - A pointer to the array of bytes to store the data read from
the device.count - The number of bytes to read in the transaction.public final void broadcast(int reg,
int data)
reg - The register to write on all devices on the bus.data - The value to write to the devices.public final boolean verifySensor(int reg,
int count,
byte[] expected)
reg - The base register to start reading from the device.count - The size of the field to be verified.expected - A buffer containing the values expected from the device.