Skip to content

Instantly share code, notes, and snippets.

@jasongao
Created December 9, 2014 01:39
Show Gist options
  • Select an option

  • Save jasongao/d19952902c19363d3c16 to your computer and use it in GitHub Desktop.

Select an option

Save jasongao/d19952902c19363d3c16 to your computer and use it in GitHub Desktop.
Edits to FTDISerialDriver.java to set FTDI latency timer
// FTDISerialDriver.java
/**
* Set latency timer.
*/
private static final int SIO_SET_LATENCY_TIMER_REQUEST = 9;
public int setLatencyTimer(int latency) throws IOException {
if (latency < 1 || latency > 255) {
throw new IOException("Latency out of range. Only valid for 1-255");
}
long value = latency;
int result = mConnection.controlTransfer(FTDI_DEVICE_OUT_REQTYPE,
SIO_SET_LATENCY_TIMER_REQUEST, (int) value, 0, null, 0, USB_WRITE_TIMEOUT_MILLIS);
if (result != 0) {
throw new IOException("Setting latency timer failed: result=" + result);
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment