]> sigrok.org Git - libsigrok.git/commitdiff
fx2lafw: Added a check to limit the sample rate during 16-bit sampling
authorJoel Holdsworth <redacted>
Thu, 10 May 2012 15:34:24 +0000 (16:34 +0100)
committerJoel Holdsworth <redacted>
Thu, 31 May 2012 18:53:36 +0000 (19:53 +0100)
hardware/fx2lafw/command.c
hardware/fx2lafw/fx2lafw.h

index 5346408d72660570643a2580282bb10b37face95..7053ce4289c19c278f7c91804eb52148ecabc16a 100644 (file)
@@ -66,6 +66,12 @@ SR_PRIV int command_start_acquisition(libusb_device_handle *devhdl,
        int delay = 0, ret;
 
        /* Compute the sample rate. */
+       if(samplewide && samplerate > MAX_16BIT_SAMPLE_RATE) {
+               sr_err("fx2lafw: Unable to sample at %" PRIu64 "Hz "
+                       "when collecting 16-bit samples.", samplerate);
+               return SR_ERR;
+       }
+
        if ((SR_MHZ(48) % samplerate) == 0) {
                cmd.flags = CMD_START_FLAGS_CLK_48MHZ;
                delay = SR_MHZ(48) / samplerate - 1;
index 1a726cf63b39e5e202760f6e86b46996a91404d7..c8a1d929380bf1f5fb8ef504a42fbee2e7166884 100644 (file)
@@ -35,6 +35,9 @@
 
 #define FX2LAFW_REQUIRED_VERSION_MAJOR 1
 
+#define MAX_8BIT_SAMPLE_RATE   SR_MHZ(24)
+#define MAX_16BIT_SAMPLE_RATE  SR_MHZ(12)
+
 /* 6 delay states of up to 256 clock ticks */
 #define MAX_SAMPLE_DELAY       (6 * 256)