kopia lustrzana https://github.com/felHR85/UsbSerial
CP2130 writeRead method added
rodzic
a1480886cd
commit
eb3671f7d3
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Ładowanie…
Reference in New Issue