From e62e95be2e3882c685e310f602e18cbae1f14178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20H=C3=A4dicke?= Date: Wed, 5 Jun 2013 23:37:55 +0200 Subject: [PATCH] Rename Cp2102SerialDriver to Cp21xxSerialDriver and add Usb IDs for more Silabs devices Conflicts: UsbSerialLibrary/src/com/hoho/android/usbserial/driver/Cp21xxSerialDriver.java UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbId.java UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbSerialProber.java --- ...ialDriver.java => Cp21xxSerialDriver.java} | 43 ++++++++++--------- .../hoho/android/usbserial/driver/UsbId.java | 7 ++- .../usbserial/driver/UsbSerialProber.java | 2 +- 3 files changed, 29 insertions(+), 23 deletions(-) rename UsbSerialLibrary/src/com/hoho/android/usbserial/driver/{Cp2102SerialDriver.java => Cp21xxSerialDriver.java} (91%) diff --git a/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/Cp2102SerialDriver.java b/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/Cp21xxSerialDriver.java similarity index 91% rename from UsbSerialLibrary/src/com/hoho/android/usbserial/driver/Cp2102SerialDriver.java rename to UsbSerialLibrary/src/com/hoho/android/usbserial/driver/Cp21xxSerialDriver.java index a427a18..7125104 100644 --- a/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/Cp2102SerialDriver.java +++ b/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/Cp21xxSerialDriver.java @@ -34,16 +34,16 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -public class Cp2102SerialDriver implements UsbSerialDriver { +public class Cp21xxSerialDriver implements UsbSerialDriver { - private static final String TAG = Cp2102SerialDriver.class.getSimpleName(); + private static final String TAG = Cp21xxSerialDriver.class.getSimpleName(); private final UsbDevice mDevice; private final UsbSerialPort mPort; - public Cp2102SerialDriver(UsbDevice device) { + public Cp21xxSerialDriver(UsbDevice device) { mDevice = device; - mPort = new Cp2102SerialPort(mDevice); + mPort = new Cp21xxSerialPort(mDevice); } @Override @@ -56,7 +56,7 @@ public class Cp2102SerialDriver implements UsbSerialDriver { return Collections.singletonList(mPort); } - class Cp2102SerialPort extends CommonUsbSerialPort { + public class Cp21xxSerialPort extends CommonUsbSerialPort { private static final int DEFAULT_BAUD_RATE = 9600; @@ -104,13 +104,13 @@ public class Cp2102SerialDriver implements UsbSerialDriver { private UsbEndpoint mReadEndpoint; private UsbEndpoint mWriteEndpoint; - public Cp2102SerialPort(UsbDevice device) { + public Cp21xxSerialPort(UsbDevice device) { super(device); } @Override public UsbSerialDriver getDriver() { - return Cp2102SerialDriver.this; + return Cp21xxSerialDriver.this; } private int setConfigSingle(int request, int value) { @@ -330,27 +330,30 @@ public class Cp2102SerialDriver implements UsbSerialDriver { public void setRTS(boolean value) throws IOException { } - @Override - public boolean purgeHwBuffers(boolean purgeReadBuffers, - boolean purgeWriteBuffers) throws IOException { - int value = (purgeReadBuffers ? FLUSH_READ_CODE : 0) - | (purgeWriteBuffers ? FLUSH_WRITE_CODE : 0); + @Override + public boolean purgeHwBuffers(boolean purgeReadBuffers, + boolean purgeWriteBuffers) throws IOException { + int value = (purgeReadBuffers ? FLUSH_READ_CODE : 0) + | (purgeWriteBuffers ? FLUSH_WRITE_CODE : 0); - if (value != 0) { - setConfigSingle(SILABSER_FLUSH_REQUEST_CODE, value); - } + if (value != 0) { + setConfigSingle(SILABSER_FLUSH_REQUEST_CODE, value); + } - return true; - } + return true; + } } public static Map getSupportedDevices() { final Map supportedDevices = new LinkedHashMap(); - supportedDevices.put(Integer.valueOf(UsbId.VENDOR_SILAB), + supportedDevices.put(Integer.valueOf(UsbId.VENDOR_SILABS), new int[] { - UsbId.SILAB_CP2102 - }); + UsbId.SILABS_CP2102, + UsbId.SILABS_CP2105, + UsbId.SILABS_CP2108, + UsbId.SILABS_CP2110 + }); return supportedDevices; } diff --git a/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbId.java b/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbId.java index b837c8a..ae92a41 100644 --- a/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbId.java +++ b/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbId.java @@ -55,8 +55,11 @@ public final class UsbId { public static final int VENDOR_LEAFLABS = 0x1eaf; public static final int LEAFLABS_MAPLE = 0x0004; - public static final int VENDOR_SILAB = 0x10c4; - public static final int SILAB_CP2102 = 0xea60; + public static final int VENDOR_SILABS = 0x10c4; + public static final int SILABS_CP2102 = 0xea60; + public static final int SILABS_CP2105 = 0xea70; + public static final int SILABS_CP2108 = 0xea71; + public static final int SILABS_CP2110 = 0xea80; public static final int VENDOR_PROLIFIC = 0x067b; public static final int PROLIFIC_PL2303 = 0x2303; diff --git a/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbSerialProber.java b/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbSerialProber.java index d00bf63..222ab60 100644 --- a/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbSerialProber.java +++ b/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbSerialProber.java @@ -44,7 +44,7 @@ public class UsbSerialProber { public static UsbSerialProber getDefaultProber() { final ProbeTable probeTable = new ProbeTable(); probeTable.addDriver(CdcAcmSerialDriver.class); - probeTable.addDriver(Cp2102SerialDriver.class); + probeTable.addDriver(Cp21xxSerialDriver.class); probeTable.addDriver(FtdiSerialDriver.class); probeTable.addDriver(ProlificSerialDriver.class); return new UsbSerialProber(probeTable);