public class TiI2CMaster extends Object
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the port of current object
|
int |
getPort()
Gets the port id of current object
|
static TiI2CMaster |
open(int portID)
Open the TiI2CMaster port by port id, and return the object
NOTE: the SMBA disable, remapID is 0, that is default location |
static TiI2CMaster |
openRemap(int portID,
boolean smba,
int remapID)
Open the TiI2CMaster port by port id and remap id, and return the object
|
static int |
portNumber()
Maximum number of port supported
|
void |
read(int address,
byte[] data,
int offset,
int len)
Read the bytes data from salve with address
|
void |
read(int address,
byte[] data,
int offset,
int len,
boolean repeated)
Read the bytes data from salve with address
|
void |
read(int address,
int subAddress,
byte[] data,
int offset,
int len)
Read the bytes data from salve with address and sub address
|
void |
setWorkBaudrate(int baudRate)
Set the work baud rate
|
void |
write(int address,
byte[] data,
int offset,
int len)
Write the bytes data to salve with address
|
void |
write(int address,
byte[] data,
int offset,
int len,
boolean repeated)
Write the bytes data to salve with address
|
void |
write(int address,
int subAddress,
byte[] data,
int offset,
int len)
Write the bytes data to salve with address and sub address
|
public void close()
throws IOException
IOException - If a TiI2CMaster error occurspublic int getPort()
public static TiI2CMaster open(int portID) throws IOException
portID - port idIOException - If a TiI2CMaster error occurspublic static TiI2CMaster openRemap(int portID, boolean smba, int remapID) throws IOException
portID - port idsmba - enable SMBA or notremapID - the remap Id, range:0-3IOException - If a TiI2CMaster error occurspublic static int portNumber()
public void read(int address,
byte[] data,
int offset,
int len)
throws IOException
address - slave address, range:0-1023, address without R/W flagdata - data array or nulloffset - data offsetlen - data lengthIOException - If a TiI2CMaster error occursArrayIndexOutOfBoundsException - If array index out of rangepublic void read(int address,
byte[] data,
int offset,
int len,
boolean repeated)
throws IOException
address - slave address,range:0-1023, address without R/W flagdata - data array or nulloffset - data offsetlen - data lengthrepeated - need repeat, if repeated == true, no stop; if repeated == false,
have stopIOException - If a TiI2CMaster error occursArrayIndexOutOfBoundsException - If array index out of rangepublic void read(int address,
int subAddress,
byte[] data,
int offset,
int len)
throws IOException
address - slave address, range:0-1023, address without R/W flagsubAddress - sub address, range:0-65535data - data array or nulloffset - data offsetlen - data lengthIOException - If a TiI2CMaster error occursArrayIndexOutOfBoundsException - If array index out of rangepublic void setWorkBaudrate(int baudRate)
throws IOException
baudRate - baud rate,IOException - If a TiI2CMaster error occurspublic void write(int address,
byte[] data,
int offset,
int len)
throws IOException
address - slave address, range:0-1023, address without R/W flagdata - data array or nulloffset - data offsetlen - data lengthIOException - If a TiI2CMaster error occursArrayIndexOutOfBoundsException - If array index out of rangepublic void write(int address,
byte[] data,
int offset,
int len,
boolean repeated)
throws IOException
address - slave address,range:0-1023, address without R/W flagdata - data array or nulloffset - data offsetlen - data lengthrepeated - need repeat, if repeated == true, no stop; if repeated == false,
have stopIOException - If a TiI2CMaster error occursArrayIndexOutOfBoundsException - If array index out of rangepublic void write(int address,
int subAddress,
byte[] data,
int offset,
int len)
throws IOException
address - slave address, range:0-1023, address without R/W flagsubAddress - sub address, range:0-65535data - data array or nulloffset - data offsetlen - data lengthIOException - If a TiI2CMaster error occursArrayIndexOutOfBoundsException - If array index out of range