]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/asix-sigma/api.c
sr_dev_open(): Set status to SR_ST_ACTIVE upon success.
[libsigrok.git] / src / hardware / asix-sigma / api.c
index 5bcce1d9ac3ced56d068dece5803d5588d1b7745..50a1d489ed51fa22d03a9778f1426afed2ce0b34 100644 (file)
@@ -50,13 +50,14 @@ static const uint32_t devopts[] = {
 #endif
 };
 
+#if ASIX_SIGMA_WITH_TRIGGER
 static const int32_t trigger_matches[] = {
        SR_TRIGGER_ZERO,
        SR_TRIGGER_ONE,
        SR_TRIGGER_RISING,
        SR_TRIGGER_FALLING,
 };
-
+#endif
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
@@ -102,7 +103,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sr_info("Found ASIX SIGMA - Serial: %s", serial_txt);
 
        devc->cur_samplerate = samplerates[0];
-       devc->period_ps = 0;
        devc->limit_msec = 0;
        devc->limit_samples = 0;
        devc->cur_firmware = -1;
@@ -140,18 +140,13 @@ static int dev_open(struct sr_dev_inst *sdi)
 
        devc = sdi->priv;
 
-       /* Make sure it's an ASIX SIGMA. */
        if ((ret = ftdi_usb_open_desc(&devc->ftdic,
-               USB_VENDOR, USB_PRODUCT, USB_DESCRIPTION, NULL)) < 0) {
-
-               sr_err("ftdi_usb_open failed: %s",
-                      ftdi_get_error_string(&devc->ftdic));
-
-               return 0;
+                       USB_VENDOR, USB_PRODUCT, USB_DESCRIPTION, NULL)) < 0) {
+               sr_err("Failed to open device (%d): %s.",
+                      ret, ftdi_get_error_string(&devc->ftdic));
+               return SR_ERR;
        }
 
-       sdi->status = SR_ST_ACTIVE;
-
        return SR_OK;
 }
 
@@ -161,9 +156,7 @@ static int dev_close(struct sr_dev_inst *sdi)
 
        devc = sdi->priv;
 
-       /* TODO */
-       if (sdi->status == SR_ST_ACTIVE)
-               ftdi_usb_close(&devc->ftdic);
+       ftdi_usb_close(&devc->ftdic);
 
        sdi->status = SR_ST_INACTIVE;
 
@@ -212,9 +205,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
 
        (void)cg;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        devc = sdi->priv;
 
        ret = SR_OK;
@@ -299,9 +289,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        uint8_t clock_bytes[sizeof(clockselect)];
        size_t clock_idx;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        devc = sdi->priv;
 
        if (sigma_convert_trigger(sdi) != SR_OK) {
@@ -389,7 +376,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
                           (devc->capture_ratio * 255) / 100, devc);
 
        /* Start acqusition. */
-       gettimeofday(&devc->start_tv, 0);
+       devc->start_time = g_get_monotonic_time();
        regval =  WMR_TRGRES | WMR_SDRAMWRITEEN;
 #if ASIX_SIGMA_WITH_TRIGGER
        regval |= WMR_TRGEN;