Skip to content

Commit

Permalink
fix CP2102N initialization
Browse files Browse the repository at this point in the history
do not send SET_BAUDDIV command. It fails on CP2102N and CP2102/5 work without
  • Loading branch information
kai-morich committed Mar 1, 2020
1 parent 17c3d40 commit 2cad1fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion usbSerialForAndroid/publishToMavenLocal.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ publishing {
maven(MavenPublication) {
groupId 'com.github.mik3y'
artifactId 'usb-serial-for-android'
version '2.2.0a'
version '2.2.2a'
afterEvaluate {
artifact androidSourcesJar
artifact bundleReleaseAar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,12 @@ public UsbSerialDriver getDriver() {
return Cp21xxSerialDriver.this;
}

private int setConfigSingle(int request, int value) throws IOException {
private void setConfigSingle(int request, int value) throws IOException {
int result = mConnection.controlTransfer(REQTYPE_HOST_TO_DEVICE, request, value,
mPortNumber, null, 0, USB_WRITE_TIMEOUT_MILLIS);
if (result != 0) {
throw new IOException("Setting baudrate failed: result=" + result);
throw new IOException("Control transfer failed: " + request + " / " + value + " -> " + result);
}
return result;
}

@Override
Expand All @@ -160,7 +159,7 @@ public void openInt(UsbDeviceConnection connection) throws IOException {

setConfigSingle(SILABSER_IFC_ENABLE_REQUEST_CODE, UART_ENABLE);
setConfigSingle(SILABSER_SET_MHS_REQUEST_CODE, MCR_ALL | CONTROL_WRITE_DTR | CONTROL_WRITE_RTS);
setConfigSingle(SILABSER_SET_BAUDDIV_REQUEST_CODE, BAUD_RATE_GEN_FREQ / DEFAULT_BAUD_RATE);
// setConfigSingle(SILABSER_SET_BAUDDIV_REQUEST_CODE, BAUD_RATE_GEN_FREQ / DEFAULT_BAUD_RATE);
// setParameters(DEFAULT_BAUD_RATE, DEFAULT_DATA_BITS, DEFAULT_STOP_BITS, DEFAULT_PARITY);
}

Expand Down

1 comment on commit 2cad1fd

@kai-morich
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.