public class HidToSpi extends HidToGpio
* thanks to ....
| Constructor and Description |
|---|
HidToSpi()
New a HidToSpi driver object.
|
HidToSpi(android.content.Context context,
java.lang.String strAppName)
New a HidToSpi driver object.
|
| Modifier and Type | Method and Description |
|---|---|
int |
askPermissionByDeviceIndex(int nDeviceIndex)
Obtain permission to communicate with a device by given device name
|
int |
askPermissionByUsbDevice(android.hardware.usb.UsbDevice usbDevice)
Obtain permission to communicate with the given device.
|
int |
closeDevice()
Close the PL23D3 device.
|
int |
closeDeviceByDeviceIndex(int nDeviceIndex) |
void |
dumpMsg(java.lang.Object objMsg)
Dump log into sdk.
|
int |
enumDevices(int nDeviceVid)
Found a PL23B3, PL23C3, or PL23D3 device , the default VID is 067B
|
int |
enumDevices(int nDeviceVid,
int nDevicePid)
Found a PL23B3, PL23C3, or PL23D3 device by given VID and PID
|
java.lang.String |
getDeviceName(int nDeviceIndex)
Gets device name by given index.
|
java.lang.String |
getSdkVersion()
Gets SDK version.
|
java.lang.String |
getSerialNumber(int nDeviceIndex)
Gets device serial number by given index.
|
android.hardware.usb.UsbDevice |
getUsbDevice(int nDeviceIndex)
Gets UsbDevice object by given index
|
boolean |
hasPermissionByDeviceIndex(int nDeviceIndex)
Detecting whether this device which decided by given index has permission
|
boolean |
hasPermissionByUsbDevice(android.hardware.usb.UsbDevice usbDevice)
check if device has permission or not.
|
int |
openDeviceByIndex(int nDeviceIndex)
Open device by given index.
|
int |
openDeviceBySerialNumber(java.lang.String strSerialNumber)
Open device by given serial number.
|
void |
setCommandTimeOut(int nMillSecond)
Sets device command time out value.
|
int |
setSpiFrequency(int nDeviceIndex,
byte byFreqDiv,
SpiSetting.SPI_MODE nSpiMode)
Sets spi frequency.
|
int |
spiRead(int nDeviceIndex,
SpiSetting.Select nSelect,
byte[] byBuffer,
int nNumberOfBytesToRead,
int nTimeOutms)
Read Binary Data from PL23D3 HidtoSpi chip.
|
int |
spiReset(int nDeviceIndex)
Reset PL23D3 HidToSpi Chip configurations.
|
int |
spiWrite(int nDeviceIndex,
SpiSetting.Select nSelect,
byte[] byBuffer,
int nNumberOfBytesToWrite,
int nTimeOutms)
Write Binary Data to PL23D3 HidtoSpi chip.
|
int |
spiWriteRead(int nDeviceIndex,
SpiSetting.Select nSelect,
byte[] byWriteBuffer,
int nNumberOfBytesToWrite,
byte[] byReadBuffer,
int nNumberOfBytesToRead,
int nTimeOutms)
Write Read Data to PL23D3 HidtoSpi chip.
|
getGpio, setGpio, setGpioDirpublic HidToSpi()
public HidToSpi(android.content.Context context,
java.lang.String strAppName)
context - the contextstrAppName - ACTION_USB_PERMISSION string, for example: "tw.com.prolific.HidToSpiTest.USB_PERMISSION"public int setSpiFrequency(int nDeviceIndex,
byte byFreqDiv,
SpiSetting.SPI_MODE nSpiMode)
nDeviceIndex - The Device IndexbyFreqDiv - The frequency divisor, this value should be equal or larger than 3.
SPI Frequency(KHz) = 24000/(nFreqDiv+1)nSpiMode - The spi mode.public int spiRead(int nDeviceIndex,
SpiSetting.Select nSelect,
byte[] byBuffer,
int nNumberOfBytesToRead,
int nTimeOutms)
nDeviceIndex - the device indexnSelect - the chip selectbyBuffer - Reading buffernNumberOfBytesToRead - the number of bytes to readnTimeOutms - The timeout value in milliseconds.public int spiWrite(int nDeviceIndex,
SpiSetting.Select nSelect,
byte[] byBuffer,
int nNumberOfBytesToWrite,
int nTimeOutms)
nDeviceIndex - the device indexnSelect - the spi chip selectbyBuffer - The write buffernNumberOfBytesToWrite - the number of bytes to writenTimeOutms - The timeout value in milliseconds.public int spiWriteRead(int nDeviceIndex,
SpiSetting.Select nSelect,
byte[] byWriteBuffer,
int nNumberOfBytesToWrite,
byte[] byReadBuffer,
int nNumberOfBytesToRead,
int nTimeOutms)
nDeviceIndex - the device indexnSelect - the spi chip selectbyWriteBuffer - The write buffernNumberOfBytesToWrite - the number of bytes to writebyReadBuffer - Reading buffernNumberOfBytesToRead - the number of bytes to readnTimeOutms - The timeout value in milliseconds.public int spiReset(int nDeviceIndex)
nDeviceIndex - the device indexpublic int enumDevices(int nDeviceVid)
nDeviceVid - the device vidpublic int enumDevices(int nDeviceVid,
int nDevicePid)
nDeviceVid - the device vidnDevicePid - the device pidpublic java.lang.String getDeviceName(int nDeviceIndex)
nDeviceIndex - The index of devicepublic java.lang.String getSerialNumber(int nDeviceIndex)
nDeviceIndex - the index of devicepublic int openDeviceByIndex(int nDeviceIndex)
nDeviceIndex - the index of devicepublic int openDeviceBySerialNumber(java.lang.String strSerialNumber)
strSerialNumber - the serial number of devicepublic boolean hasPermissionByDeviceIndex(int nDeviceIndex)
nDeviceIndex - the index of devicepublic int askPermissionByDeviceIndex(int nDeviceIndex)
nDeviceIndex - the index of devicepublic boolean hasPermissionByUsbDevice(android.hardware.usb.UsbDevice usbDevice)
usbDevice - the usb devicepublic int askPermissionByUsbDevice(android.hardware.usb.UsbDevice usbDevice)
usbDevice - the usb devicepublic int closeDevice()
public int closeDeviceByDeviceIndex(int nDeviceIndex)
public java.lang.String getSdkVersion()
public void setCommandTimeOut(int nMillSecond)
nMillSecond - the time value in millisecond.public void dumpMsg(java.lang.Object objMsg)
objMsg - The message content.public android.hardware.usb.UsbDevice getUsbDevice(int nDeviceIndex)
nDeviceIndex - the index of device