X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fhantek-6xxx%2Fprotocol.c;h=a08e126c5e32a9fc7f672b23d379ac6eeabfe57c;hb=6402c379161ec138e451901c411817a55846a75b;hp=c02aa174647bb8168f1cc5f7e41f8dfacd6a0005;hpb=8d6d7d5d0db6c0a778af6b2db8c144630f85311e;p=libsigrok.git diff --git a/src/hardware/hantek-6xxx/protocol.c b/src/hardware/hantek-6xxx/protocol.c index c02aa174..a08e126c 100644 --- a/src/hardware/hantek-6xxx/protocol.c +++ b/src/hardware/hantek-6xxx/protocol.c @@ -33,10 +33,6 @@ SR_PRIV int hantek_6xxx_open(struct sr_dev_inst *sdi) devc = sdi->priv; usb = sdi->conn; - if (sdi->status == SR_ST_ACTIVE) - /* Already in use. */ - return SR_ERR; - libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist); for (i = 0; devlist[i]; i++) { libusb_get_device_descriptor(devlist[i], &des); @@ -215,6 +211,20 @@ SR_PRIV int hantek_6xxx_update_vdiv(const struct sr_dev_inst *sdi) return MIN(ret1, ret2); } +SR_PRIV int hantek_6xxx_update_coupling(const struct sr_dev_inst *sdi) +{ + struct dev_context *devc = sdi->priv; + uint8_t coupling = 0xFF & ((devc->coupling[1] << 4) | devc->coupling[0]); + + if (devc->has_coupling) { + sr_dbg("update coupling 0x%x", coupling); + return write_control(sdi, COUPLING_REG, coupling); + } else { + sr_dbg("coupling not supported"); + return SR_OK; + } +} + SR_PRIV int hantek_6xxx_update_channels(const struct sr_dev_inst *sdi) { struct dev_context *devc = sdi->priv; @@ -230,6 +240,7 @@ SR_PRIV int hantek_6xxx_init(const struct sr_dev_inst *sdi) hantek_6xxx_update_samplerate(sdi); hantek_6xxx_update_vdiv(sdi); + hantek_6xxx_update_coupling(sdi); // hantek_6xxx_update_channels(sdi); /* Only 2 channel mode supported. */ return SR_OK;