public class TiSPIMaster extends Object
Modifier and Type | Field and Description |
---|---|
static int |
MODE0
MODE0, CPOL=0,CPHA=0
|
static int |
MODE1
MODE1, CPOL=0,CPHA=1
|
static int |
MODE2
MODE2, CPOL=1,CPHA=0
|
static int |
MODE3
MODE3, CPOL=1,CPHA=1
|
static int |
ORDER_LSB
Low bit first transmission order
|
static int |
ORDER_MSB
High bit first transmission order
|
static int |
TYPE_DIO
double io type, 16bits
|
static int |
TYPE_PIO
Parallel io type
|
static int |
TYPE_QIO
Quad io type, 32bits
|
static int |
TYPE_SIO
Single io type, 8bits
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the port of current object
|
int |
getPort()
Gets the port id of current object
|
static TiSPIMaster |
open(int portID)
Open the TiSPIMaster port by port id, and return the object
NOTE: remapID is 0, that is default location |
static TiSPIMaster |
openRemap(int portID,
int remapID)
Open the TiSPIMaster port by port id and remap id, and return the object
|
static int |
portNumber()
Maximum number of port supported
|
int |
read(byte[] data,
int offset,
int len)
Read the data from salve
|
void |
selectSlave(boolean enable)
Select the slave or not
|
void |
setWorkParameters(int mode,
int type,
int order,
int baudRate)
Set work parameters
|
int |
write(byte[] data,
int offset,
int len)
Write the data to salve
|
public static final int MODE0
public static final int MODE1
public static final int MODE2
public static final int MODE3
public static final int ORDER_LSB
public static final int ORDER_MSB
public static final int TYPE_DIO
public static final int TYPE_PIO
public static final int TYPE_QIO
public static final int TYPE_SIO
public void close() throws IOException
IOException
- If a TiSPIMaster error occurspublic int getPort()
public static TiSPIMaster open(int portID) throws IOException
portID
- port idIOException
- If a TiSPIMaster error occurspublic static TiSPIMaster openRemap(int portID, int remapID) throws IOException
portID
- port idremapID
- the remap Id, range:0-3IOException
- If a TiSPIMaster error occurspublic static int portNumber()
public int read(byte[] data, int offset, int len) throws IOException
data
- data arrayoffset
- data offsetlen
- data lengthIOException
- If a TiSPIMaster error occursNullPointerException
- If data is nullArrayIndexOutOfBoundsException
- If array index out of rangepublic void selectSlave(boolean enable) throws IOException
enable
- true - select slave, false - release slaveIOException
- If a TiSPIMaster error occurspublic void setWorkParameters(int mode, int type, int order, int baudRate) throws IOException
mode
- work mode,type
- type mode,order
- bit order mode,baudRate
- baud rate,IOException
- If a TiSPIMaster error occurspublic int write(byte[] data, int offset, int len) throws IOException
data
- data arrayoffset
- data offsetlen
- data lengthIOException
- If a TiSPIMaster error occursNullPointerException
- If data is nullArrayIndexOutOfBoundsException
- If array index out of range