public class SMBus extends Object
As such, the Linux kernel provides utilities for executing SMBus operations on an I2C bus.
| Modifier and Type | Class and Description |
|---|---|
static class |
SMBus.Block
Class representing a block of bytes for SMBus operations.
|
| Modifier and Type | Method and Description |
|---|---|
int |
blockProcessCall(int command,
SMBus.Block block)
SMBus RPC-like operation, writing several bytes after specifying a command and then
reading several bytes as an answer.
|
int |
blockProcessCall(int command,
SMBus.Block blockWrite,
SMBus.Block blockRead)
SMBus RPC-like operation, writing several bytes after specifying a command and then
reading several bytes as an answer.
|
int |
processCall(int command,
int word)
SMBus RPC-like operation, writing a short after specifying a command and then
reading the answer.
|
void |
quick(boolean isWrite)
SMBus operation sending only the READ or WRITE bit, no data is carried.
|
int |
readBlock(int command,
SMBus.Block block)
SMBus operation reading several bytes after specifying a command.
|
int |
readByte(int command)
SMBus operation reading a byte after specifying a command.
|
int |
readByteDirectly()
SMBus operation reading a byte without a command.
|
void |
readI2CBlock(int command,
SMBus.Block block,
int length)
SMBus-like operation reading several bytes after specifying a command where the length
is part of the message.
|
int |
readWord(int command)
SMBus operation reading a short after specifying a command.
|
void |
usePEC(boolean usePEC)
Enables or disables packet error checking for SMBus commands.
|
void |
writeBlock(int command,
SMBus.Block block)
SMBus operation writing several bytes after specifying a command.
|
void |
writeByte(int command,
int b)
SMBus operation writing a byte after specifying a command.
|
void |
writeByteDirectly(int b)
SMBus operation writing a byte without a command.
|
void |
writeI2CBlock(int command,
SMBus.Block block)
SMBus-like operation writing several bytes after specifying a command where the length
is part of the message.
|
void |
writeWord(int command,
int word)
SMBus operation writing a short after specifying a command.
|
public void usePEC(boolean usePEC)
throws IOException
Is ignored unless the underlying driver provides this functionality.
Slave devices do not necessarely support this feature either.
usePEC - Should PEC be enabled ?IllegalStateException - When the underlying I2C bus has been closed.IOException - When the bus is not a proper I2C bus or an unplanned error occured.public void quick(boolean isWrite)
throws IOException
isWrite - True if the WRITE bit must be set.IllegalStateException - When the underlying I2C bus has been closed.IOException - When the bus is not a proper I2C bus or an unplanned error occured.public int readByteDirectly()
throws IOException
IllegalStateException - When the underlying I2C bus has been closed.IOException - When the bus is not a proper I2C bus or an unplanned error occured.public int readByte(int command)
throws IOException
command - AKA "register".IllegalStateException - When thelbus has been closed.IOException - When the bus is not a proper I2C bus or an unplanned error occured.public int readWord(int command)
throws IOException
command - AKA "register".IllegalStateException - When the underlying I2C bus has been closed.IOException - When the bus is not a proper I2C bus or an unplanned error occured.public int readBlock(int command,
SMBus.Block block)
throws IOException
command - AKA "register".block - Block of bytes the answer will be written to.IllegalStateException - When the underlying I2C bus has been closed.IOException - When the bus is not a proper I2C bus or an unplanned error occured.public void readI2CBlock(int command,
SMBus.Block block,
int length)
throws IOException
This operation is not in the SMBus standard but is often supported nonetheless.
command - AKA "register".block - Block of bytes the answer will be written to.length - How many bytes should be read.IllegalStateException - When the underlying I2C bus has been closed.IOException - When the bus is not a proper I2C bus or an unplanned error occured.public void writeByteDirectly(int b)
throws IOException
b - Unsigned byte that needs to be sent.IllegalStateException - When the underlying I2C bus has been closed.IOException - When the bus is not a proper I2C bus or an unplanned error occured.public void writeByte(int command,
int b)
throws IOException
command - AKA "register".b - Unsigned byte that needs to be sent.IllegalStateException - When the underlying I2C bus has been closed.IOException - When the bus is not a proper I2C bus or an unplanned error occured.public void writeWord(int command,
int word)
throws IOException
command - AKA "register".word - Unsigned short that needs to be sent.IllegalStateException - When the underlying I2C bus has been closed.IOException - When the bus is not a proper I2C bus or an unplanned error occured.public void writeBlock(int command,
SMBus.Block block)
throws IOException
After the command byte, the master also sends a byte count, how many bytes will be written.
command - AKA "register".block - Block of bytes to write.IllegalStateException - When the underlying I2C bus has been closed.IOException - When the bus is not a proper I2C bus or an unplanned error occured.public void writeI2CBlock(int command,
SMBus.Block block)
throws IOException
This operation is not in the SMBus standard but is often supported nonetheless.
Unlike writeBlock, this operation
does not send a byte count after the command.
command - AKA "register".block - Block of bytes to write.IllegalStateException - When the underlying I2C bus has been closed.IOException - When the bus is not a proper I2C bus or an unplanned error occured.public int processCall(int command,
int word)
throws IOException
command - AKA "register".word - Unsigned short to be sent.IllegalStateException - When the underlying I2C bus has been closed.IOException - When the bus is not a proper I2C bus or an unplanned error occured.public int blockProcessCall(int command,
SMBus.Block block)
throws IOException
command - AKA "register".block - Block of bytes to write, also where the answer will be written to.IllegalStateException - When the underlying I2C bus has been closed.IOException - When the bus is not a proper I2C bus or an unplanned error occured.public int blockProcessCall(int command,
SMBus.Block blockWrite,
SMBus.Block blockRead)
throws IOException
command - AKA "register".blockWrite - Block of bytes to write.blockRead - Block of bytes the answer will be written to (can be the same as blockWrite
if it can be overwritten).IllegalStateException - When the underlying I2C bus has been closed.IOException - When the bus is not a proper I2C bus or an unplanned error occured.