static int g_filter_status[8] = { 0 };
static int g_filter_enable = 0;
+static int g_ext_clock = 0;
+static ext_clock_edge_t g_ext_clock_edge = LAPC_CLOCK_EDGE_RISING;
+
static int g_freq_value = 1;
static int g_freq_scale = FREQ_SCALE_MHZ;
static int g_memory_size = MEMORY_SIZE_8K;
gl_reg_write(devh, MEMORY_LENGTH, g_memory_size);
/* Sele_Inside_Outside_Clock */
- gl_reg_write(devh, CLOCK_SOURCE, 0x03);
+ if (!g_ext_clock)
+ gl_reg_write(devh, CLOCK_SOURCE, 0x01);
+ else {
+ if (g_ext_clock_edge == LAPC_CLOCK_EDGE_RISING)
+ gl_reg_write(devh, CLOCK_SOURCE, 0x02);
+ else
+ gl_reg_write(devh, CLOCK_SOURCE, 0x0);
+ }
/* Set_Trigger_Status */
for (i = 0; i < 8; i++)
g_trigger_count = count;
}
+SR_PRIV void analyzer_set_ext_clock(int enable, ext_clock_edge_t edge)
+{
+ g_ext_clock = enable;
+ g_ext_clock_edge = edge;
+}
+
SR_PRIV void analyzer_set_freq(int freq, int scale)
{
g_freq_value = freq;
#include <libusb.h>
#include <libsigrok/libsigrok.h>
+#include "protocol.h"
#define STATUS_FLAG_NONE 0x00
#define STATUS_FLAG_RESET 0x01
#define COMPRESSION_ENABLE 0x8001
#define COMPRESSION_DOUBLE 0x8002
+SR_PRIV void analyzer_set_ext_clock(int enable, ext_clock_edge_t edge);
SR_PRIV void analyzer_set_freq(int freq, int scale);
SR_PRIV void analyzer_set_ramsize_trigger_address(unsigned int address);
SR_PRIV void analyzer_set_triggerbar_address(unsigned int address);
*/
#include <config.h>
+#include "analyzer.h"
#include "protocol.h"
#define USB_INTERFACE 0
SR_CONF_TRIGGER_MATCH | SR_CONF_LIST,
SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET,
SR_CONF_VOLTAGE_THRESHOLD | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+ SR_CONF_EXTERNAL_CLOCK | SR_CONF_GET | SR_CONF_SET,
+ SR_CONF_CLOCK_EDGE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+};
+
+static const char *ext_clock_edges[] = {
+ [LAPC_CLOCK_EDGE_RISING] = "rising",
+ [LAPC_CLOCK_EDGE_FALLING] = "falling",
};
static const int32_t trigger_matches[] = {
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc;
+ const char *ext_clock_text;
(void)cg;
case SR_CONF_VOLTAGE_THRESHOLD:
*data = std_gvar_tuple_double(devc->cur_threshold, devc->cur_threshold);
break;
+ case SR_CONF_EXTERNAL_CLOCK:
+ *data = g_variant_new_boolean(devc->use_ext_clock);
+ break;
+ case SR_CONF_CLOCK_EDGE:
+ ext_clock_text = ext_clock_edges[devc->ext_clock_edge];
+ *data = g_variant_new_string(ext_clock_text);
+ break;
default:
return SR_ERR_NA;
}
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc;
+ int idx;
gdouble low, high;
(void)cg;
case SR_CONF_VOLTAGE_THRESHOLD:
g_variant_get(data, "(dd)", &low, &high);
return set_voltage_threshold(devc, (low + high) / 2.0);
+ case SR_CONF_EXTERNAL_CLOCK:
+ devc->use_ext_clock = g_variant_get_boolean(data);
+ analyzer_set_ext_clock(devc->use_ext_clock, (ext_clock_edge_t)devc->ext_clock_edge);
+ break;
+ case SR_CONF_CLOCK_EDGE:
+ idx = std_str_idx(data, ARRAY_AND_SIZE(ext_clock_edges));
+ if (idx < 0)
+ return SR_ERR_ARG;
+ devc->ext_clock_edge = (ext_clock_edge_t)idx;
+ analyzer_set_ext_clock(devc->use_ext_clock, devc->ext_clock_edge);
+ break;
default:
return SR_ERR_NA;
}
devc = sdi->priv;
*data = std_gvar_tuple_u64(0, devc->max_sample_depth);
break;
+ case SR_CONF_CLOCK_EDGE:
+ *data = g_variant_new_strv(ARRAY_AND_SIZE(ext_clock_edges));
+ break;
+
default:
return SR_ERR_NA;
}
#include <libusb.h>
#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
-#include "analyzer.h"
#define LOG_PREFIX "zeroplus-logic-cube"
+typedef enum {
+ LAPC_CLOCK_EDGE_RISING,
+ LAPC_CLOCK_EDGE_FALLING,
+} ext_clock_edge_t;
+
struct zp_model;
struct dev_context {
uint64_t cur_samplerate;
uint64_t capture_ratio;
double cur_threshold;
const struct zp_model *prof;
+ gboolean use_ext_clock;
+ ext_clock_edge_t ext_clock_edge;
};
SR_PRIV size_t get_memory_size(int type);