CP2130 writeRead method added

pull/46/head
Felipe Herranz 2016-04-30 22:28:06 +02:00
rodzic a1480886cd
commit eb3671f7d3
3 zmienionych plików z 22 dodań i 0 usunięć

Wyświetl plik

@ -139,6 +139,24 @@ public class CP2130SpiDevice extends UsbSpiDevice
connection.bulkTransfer(outEndpoint, buffCommand, buffCommand.length, USB_TIMEOUT);
}
@Override
public void writeRead(byte[] buffer, int lengthRead)
{
byte[] buffCommand = new byte[8 + buffer.length];
buffCommand[0] = 0x00;
buffCommand[1] = 0x00;
buffCommand[2] = 0x02;
buffCommand[3] = (byte) 0x80;
buffCommand[4] = (byte) (lengthRead & 0xff);
buffCommand[5] = (byte) ((lengthRead >> 8) & 0xff);
buffCommand[6] = (byte) ((lengthRead >> 16) & 0xff);
buffCommand[7] = (byte) ((lengthRead >> 24) & 0xff);
System.arraycopy(buffer, 0, buffCommand, 8, buffer.length);
connection.bulkTransfer(outEndpoint, buffCommand, buffCommand.length, USB_TIMEOUT);
}
@Override
public void selectSlave(int nSlave)
{

Wyświetl plik

@ -59,6 +59,9 @@ public abstract class UsbSpiDevice implements UsbSpiInterface
@Override
public abstract void readMISO(int lengthBuffer);
@Override
public abstract void writeRead(byte[] buffer, int lengthRead);
@Override
public abstract void setClock(int clockDivider);

Wyświetl plik

@ -16,6 +16,7 @@ public interface UsbSpiInterface
boolean connectSPI();
void writeMOSI(byte[] buffer);
void readMISO(int lengthBuffer);
void writeRead(byte[] buffer, int lenghtRead);
void setClock(int clockDivider);
void selectSlave(int nSlave);
void setMISOCallback(UsbMISOCallback misoCallback);