Added setGpioChipSelect method

pull/46/head
Felipe Herranz 2016-04-25 22:17:14 +02:00
rodzic ab03620e45
commit 8bf3a754ca
1 zmienionych plików z 26 dodań i 0 usunięć

Wyświetl plik

@ -26,6 +26,7 @@ public class CP2130SpiDevice extends UsbSpiDevice
private static final int BM_REQ_HOST_2_DEVICE = 0x40;
private static final int SET_SPI_WORD = 0x31;
private static final int SET_GPIO_CHIP_SELECT = 0x25;
private UsbInterface mInterface;
private UsbEndpoint inEndpoint;
@ -175,6 +176,31 @@ public class CP2130SpiDevice extends UsbSpiDevice
}
private void setGpioChipSelect(int channel, boolean othersDisabled)
{
byte[] payload = new byte[2];
if(channel >= 0 && channel <= 10)
{
payload[0] = (byte) channel;
}else
{
Log.i(CLASS_ID, "Channel not valid");
return;
}
byte control;
if(othersDisabled)
control = 0x02;
else
control = 0x01;
payload[1] = control;
setControlCommandOut(SET_GPIO_CHIP_SELECT, 0x00, 0x00, payload);
}
private int setControlCommandOut(int request, int value, int index, byte[] data)
{
int dataLength = 0;