public class NativeI2CDeviceSMBus extends Object implements I2CSMBusInterface
JNI wrapper of SMBus interface.
Reference Kernel I2C dev interface and SMBus Protocol.
See i2c-dev for defintion of the inline functions.
MAX_I2C_BLOCK_SIZE
Constructor and Description |
---|
NativeI2CDeviceSMBus(int controller,
int deviceAddress,
boolean force) |
Modifier and Type | Method and Description |
---|---|
byte[] |
blockProcessCall(int registerAddress,
byte[] txData,
int length)
SMBus Block Write - Block Read Process Call
|
void |
close() |
boolean |
probe(I2CDevice.ProbeMode mode)
Probe this I2C device
|
short |
processCall(int registerAddress,
short data)
SMBus Process Call
|
byte[] |
readBlockData(int registerAddress)
SMBus Block Read: i2c_smbus_read_block_data()
|
byte |
readByte()
SMBus Receive Byte: i2c_smbus_read_byte()
|
byte |
readByteData(int registerAddress)
SMBus Read Byte: i2c_smbus_read_byte_data()
|
byte[] |
readBytes(int length) |
byte[] |
readI2CBlockData(int registerAddress,
int length)
I2C Block Read: i2c_smbus_read_i2c_block_data()
|
short |
readWordData(int registerAddress)
SMBus Read Word: i2c_smbus_read_word_data()
|
void |
writeBlockData(int registerAddress,
byte[] data)
SMBus Block Write: i2c_smbus_write_block_data()
|
void |
writeByte(byte data)
SMBus Send Byte: i2c_smbus_write_byte()
|
void |
writeByteData(int registerAddress,
byte data)
SMBus Write Byte: i2c_smbus_write_byte_data()
|
void |
writeBytes(byte[] data) |
void |
writeI2CBlockData(int registerAddress,
byte[] data)
I2C Block Write: i2c_smbus_write_i2c_block_data()
|
void |
writeQuick(byte bit)
SMBus Quick Command
|
void |
writeWordData(int registerAddress,
short data)
SMBus Write Word: i2c_smbus_write_word_data()
|
public NativeI2CDeviceSMBus(int controller, int deviceAddress, boolean force) throws RuntimeIOException
RuntimeIOException
public void close()
close
in interface I2CSMBusInterface
close
in interface Closeable
close
in interface AutoCloseable
public boolean probe(I2CDevice.ProbeMode mode)
I2CSMBusInterface
probe
in interface I2CSMBusInterface
mode
- Probe modepublic void writeQuick(byte bit)
I2CSMBusInterface
SMBus Quick Command
This sends a single bit to the device, at the place of the Rd/Wr bit.
A Addr Rd/Wr [A] P
writeQuick
in interface I2CSMBusInterface
bit
- The bit to writepublic byte readByte()
I2CSMBusInterface
SMBus Receive Byte: i2c_smbus_read_byte()
This reads a single byte from a device, without specifying a device register. Some devices are so simple that this interface is enough; for others, it is a shorthand if you want to read the same register as in the previous SMBus command.
S Addr Rd [A] [Data] NA P
readByte
in interface I2CSMBusInterface
public void writeByte(byte data)
I2CSMBusInterface
SMBus Send Byte: i2c_smbus_write_byte()
This operation is the reverse of Receive Byte: it sends a single byte to a device. See Receive Byte for more information.
S Addr Wr [A] Data [A] P
writeByte
in interface I2CSMBusInterface
data
- value to writepublic byte[] readBytes(int length)
readBytes
in interface I2CSMBusInterface
public void writeBytes(byte[] data)
writeBytes
in interface I2CSMBusInterface
public byte readByteData(int registerAddress)
I2CSMBusInterface
SMBus Read Byte: i2c_smbus_read_byte_data()
This reads a single byte from a device, from a designated register. The register is specified through the Comm byte.
S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
readByteData
in interface I2CSMBusInterface
registerAddress
- the register to read frompublic void writeByteData(int registerAddress, byte data)
I2CSMBusInterface
SMBus Write Byte: i2c_smbus_write_byte_data()
This writes a single byte to a device, to a designated register. The register is specified through the Comm byte. This is the opposite of the Read Byte operation.
S Addr Wr [A] Comm [A] Data [A] P
writeByteData
in interface I2CSMBusInterface
registerAddress
- the register to write todata
- value to writepublic short readWordData(int registerAddress)
I2CSMBusInterface
SMBus Read Word: i2c_smbus_read_word_data()
This operation is very like Read Byte; again, data is read from a device, from a designated register that is specified through the Comm byte. But this time, the data is a complete word (16 bits).
S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
readWordData
in interface I2CSMBusInterface
registerAddress
- the register to read frompublic void writeWordData(int registerAddress, short data)
I2CSMBusInterface
SMBus Write Word: i2c_smbus_write_word_data()
This is the opposite of the Read Word operation. 16 bits of data is written to a device, to the designated register that is specified through the Comm byte.
S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P
writeWordData
in interface I2CSMBusInterface
registerAddress
- the register to write todata
- value to writepublic short processCall(int registerAddress, short data)
I2CSMBusInterface
SMBus Process Call
This command selects a device register (through the Comm byte), sends 16 bits of data to it, and reads 16 bits of data in return.
S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
processCall
in interface I2CSMBusInterface
registerAddress
- the register to write to / read fromdata
- value to writepublic byte[] readBlockData(int registerAddress)
I2CSMBusInterface
SMBus Block Read: i2c_smbus_read_block_data()
This command reads a block of up to 32 bytes from a device, from a designated register that is specified through the Comm byte. The amount of data is specified by the device in the Count byte.
S Addr Wr [A] Comm [A] S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
readBlockData
in interface I2CSMBusInterface
registerAddress
- the register to read frompublic void writeBlockData(int registerAddress, byte[] data)
I2CSMBusInterface
SMBus Block Write: i2c_smbus_write_block_data()
The opposite of the Block Read command, this writes up to 32 bytes to a device, to a designated register that is specified through the Comm byte. The amount of data is specified in the Count byte.
S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P
writeBlockData
in interface I2CSMBusInterface
registerAddress
- the register to write todata
- values to writepublic byte[] blockProcessCall(int registerAddress, byte[] txData, int length)
I2CSMBusInterface
SMBus Block Write - Block Read Process Call
SMBus Block Write - Block Read Process Call was introduced in
Revision 2.0 of the specification.
This command selects a device register (through the Comm byte), sends
1 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return.
S Addr Wr [A] Comm [A] Count [A] Data [A] ... S Addr Rd [A] [Count] A [Data] ... A P
blockProcessCall
in interface I2CSMBusInterface
registerAddress
- the register to write totxData
- data to writelength
- Lengthpublic byte[] readI2CBlockData(int registerAddress, int length)
I2CSMBusInterface
I2C Block Read: i2c_smbus_read_i2c_block_data()
This command reads a block of bytes from a device, from a designated register that is specified through the Comm byte.
S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
readI2CBlockData
in interface I2CSMBusInterface
registerAddress
- the register to read fromlength
- amount of data to readpublic void writeI2CBlockData(int registerAddress, byte[] data)
I2CSMBusInterface
I2C Block Write: i2c_smbus_write_i2c_block_data()
The opposite of the Block Read command, this writes bytes to a device, to a designated register that is specified through the Comm byte. Note that command lengths of 0, 2, or more bytes are supported as they are indistinguishable from data.
S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
writeI2CBlockData
in interface I2CSMBusInterface
registerAddress
- the register to write todata
- values to writeCopyright © 2016–2018 mattjlewis. All rights reserved.