From: Joel Holdsworth Date: Mon, 7 May 2012 11:40:52 +0000 (+0100) Subject: fx2lafw: Added support for 100kHz and 50kHz sampling X-Git-Tag: libsigrok-0.1.1~22 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=897c1a2ee5c7397a4ab281a5c83f8f5c34ea0aa1;p=libsigrok.git fx2lafw: Added support for 100kHz and 50kHz sampling --- diff --git a/hardware/fx2lafw/command.c b/hardware/fx2lafw/command.c index bb47d2d1..fe16506a 100644 --- a/hardware/fx2lafw/command.c +++ b/hardware/fx2lafw/command.c @@ -18,6 +18,8 @@ */ #include + +#include "fx2lafw.h" #include "command.h" #include "sigrok.h" #include "sigrok-internal.h" @@ -71,14 +73,14 @@ SR_PRIV int command_start_acquisition(libusb_device_handle *devhdl, delay = SR_MHZ(30) / samplerate - 1; } - /* Note: sample_delay=0 is treated as sample_delay=256. */ - if (delay <= 0 || delay > 256) { + if (delay <= 0 || delay > MAX_SAMPLE_DELAY) { sr_err("fx2lafw: Unable to sample at %" PRIu64 "Hz.", samplerate); return SR_ERR; } - cmd.sample_delay = delay; + cmd.sample_delay_h = (delay >> 8) & 0x00FF; + cmd.sample_delay_l = delay & 0x00FF; /* Send the control message. */ ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR | diff --git a/hardware/fx2lafw/command.h b/hardware/fx2lafw/command.h index 0ab3e85e..70c4fdaf 100644 --- a/hardware/fx2lafw/command.h +++ b/hardware/fx2lafw/command.h @@ -41,7 +41,8 @@ struct version_info { struct cmd_start_acquisition { uint8_t flags; - uint8_t sample_delay; + uint8_t sample_delay_h; + uint8_t sample_delay_l; }; #pragma pack(pop) diff --git a/hardware/fx2lafw/fx2lafw.c b/hardware/fx2lafw/fx2lafw.c index 11b43f08..89bb18bf 100644 --- a/hardware/fx2lafw/fx2lafw.c +++ b/hardware/fx2lafw/fx2lafw.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include "config.h" #include "sigrok.h" @@ -95,6 +94,8 @@ static const char *probe_names[] = { }; static uint64_t supported_samplerates[] = { + SR_KHZ(50), + SR_KHZ(100), SR_KHZ(200), SR_KHZ(250), SR_KHZ(500), diff --git a/hardware/fx2lafw/fx2lafw.h b/hardware/fx2lafw/fx2lafw.h index b03e86ab..15b1e20c 100644 --- a/hardware/fx2lafw/fx2lafw.h +++ b/hardware/fx2lafw/fx2lafw.h @@ -17,6 +17,8 @@ * along with this program. If not, see . */ +#include + #ifndef LIBSIGROK_HARDWARE_FX2LAFW_FX2LAFW_H #define LIBSIGROK_HARDWARE_FX2LAFW_FX2LAFW_H @@ -32,6 +34,7 @@ #define FX2LAFW_VERSION_MAJOR 1 #define FX2LAFW_VERSION_MINOR 0 +#define MAX_SAMPLE_DELAY (6*256) /* 6 delay states of up to 256 clock ticks*/ /* Software trigger implementation: positive values indicate trigger stage. */ #define TRIGGER_FIRED -1