]> sigrok.org Git - libsigrok.git/blobdiff - hardware/fx2lafw/fx2lafw.c
fx2lafw: Implemented control of sample rates
[libsigrok.git] / hardware / fx2lafw / fx2lafw.c
index b0bd0e6067b6cb06db6924b3ef2eab9ac94a1ba9..cb9963f52eac11389219968cc17570200dc264af 100644 (file)
@@ -78,6 +78,7 @@ static struct sr_samplerates fx2lafw_samplerates = {
 static GSList *dev_insts = NULL;
 static libusb_context *usb_context = NULL;
 
+static int hw_dev_config_set(int dev_index, int hwcap, void *value);
 static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id);
 
 /**
@@ -369,6 +370,13 @@ static int hw_dev_open(int dev_index)
                return SR_ERR;
        }
 
+       if (ctx->cur_samplerate == 0) {
+               /* Samplerate hasn't been set; default to the slowest one. */
+               if (hw_dev_config_set(dev_index, SR_HWCAP_SAMPLERATE,
+                   &fx2lafw_supported_samplerates[0]) == SR_ERR)
+                       return SR_ERR;
+       }
+
        return SR_OK;
 }
 
@@ -617,7 +625,8 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
                return SR_ERR_MALLOC;
        }
 
-       if ((err = command_start_acquisition (ctx->usb->devhdl)) != SR_OK) {
+       if ((err = command_start_acquisition (ctx->usb->devhdl,
+               ctx->cur_samplerate)) != SR_OK) {
                return err;
        }