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
This commit is contained in:
Felix Hädicke 2013-06-05 23:37:55 +02:00 committed by mike wakerly
parent 8abc3be1f1
commit e62e95be2e
3 changed files with 29 additions and 23 deletions

View File

@ -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) {
@ -347,9 +347,12 @@ public class Cp2102SerialDriver implements UsbSerialDriver {
public static Map<Integer, int[]> getSupportedDevices() {
final Map<Integer, int[]> supportedDevices = new LinkedHashMap<Integer, int[]>();
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;
}

View File

@ -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;

View File

@ -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);