It doesn't currently mesh well with libsigrok, but at least the support is there.
static int g_ramsize_triggerbar_addr = 2 * 1024;
static int g_triggerbar_addr = 0;
static int g_compression = COMPRESSION_NONE;
+static int g_thresh = 0x31; /* 1.5V */
/* Maybe unk specifies an "endpoint" or "register" of sorts. */
static int analyzer_write_status(libusb_device_handle *devh, unsigned char unk,
__analyzer_set_trigger_count(devh, g_trigger_count);
/* Set_Trigger_Level */
- gl_reg_write(devh, TRIGGER_LEVEL0, 0x31);
- gl_reg_write(devh, TRIGGER_LEVEL1, 0x31);
- gl_reg_write(devh, TRIGGER_LEVEL2, 0x31);
- gl_reg_write(devh, TRIGGER_LEVEL3, 0x31);
+ gl_reg_write(devh, TRIGGER_LEVEL0, g_thresh);
+ gl_reg_write(devh, TRIGGER_LEVEL1, g_thresh);
+ gl_reg_write(devh, TRIGGER_LEVEL2, g_thresh);
+ gl_reg_write(devh, TRIGGER_LEVEL3, g_thresh);
/* Size of actual memory >> 2 */
__analyzer_set_ramsize_trigger_address(devh, g_ramsize_triggerbar_addr);
g_compression = type;
}
+SR_PRIV void analyzer_set_voltage_threshold(int thresh)
+{
+ g_thresh = thresh;
+}
+
SR_PRIV void analyzer_wait_button(libusb_device_handle *devh)
{
analyzer_wait(devh, STATUS_BUTTON_PRESSED, 0);
SR_PRIV void analyzer_add_trigger(int channel, int type);
SR_PRIV void analyzer_set_trigger_count(int count);
SR_PRIV void analyzer_add_filter(int channel, int type);
+SR_PRIV void analyzer_set_voltage_threshold(int thresh);
SR_PRIV unsigned int analyzer_read_status(libusb_device_handle *devh);
SR_PRIV unsigned int analyzer_read_id(libusb_device_handle *devh);
SR_CONF_LOGIC_ANALYZER,
SR_CONF_SAMPLERATE,
SR_CONF_CAPTURE_RATIO,
+ SR_CONF_VOLTAGE_THRESHOLD,
SR_CONF_LIMIT_SAMPLES,
};
devc->cur_samplerate = SR_MHZ(1);
}
+ if (devc->cur_threshold == 0)
+ set_voltage_threshold(devc, 1.5);
+
return SR_OK;
}
} else
return SR_ERR;
break;
+ case SR_CONF_VOLTAGE_THRESHOLD:
+ if (sdi) {
+ GVariant *range[2];
+ devc = sdi->priv;
+ range[0] = g_variant_new_double(devc->cur_threshold);
+ range[1] = g_variant_new_double(devc->cur_threshold);
+ *data = g_variant_new_tuple(range, 2);
+ } else
+ return SR_ERR;
+ break;
default:
return SR_ERR_NA;
}
const struct sr_probe_group *probe_group)
{
struct dev_context *devc;
+ gdouble low, high;
(void)probe_group;
return set_limit_samples(devc, g_variant_get_uint64(data));
case SR_CONF_CAPTURE_RATIO:
return set_capture_ratio(devc, g_variant_get_uint64(data));
+ case SR_CONF_VOLTAGE_THRESHOLD:
+ g_variant_get(data, "(dd)", &low, &high);
+ return set_voltage_threshold(devc, (low + high) / 2.0);
default:
return SR_ERR_NA;
}
struct dev_context *devc;
GVariant *gvar;
GVariantBuilder gvb;
+ double v;
+ GVariant *range[2];
(void)probe_group;
case SR_CONF_TRIGGER_TYPE:
*data = g_variant_new_string(TRIGGER_TYPE);
break;
+ case SR_CONF_VOLTAGE_THRESHOLD:
+ g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
+ for (v = -6.0; v <= 6.0; v += 0.1) {
+ range[0] = g_variant_new_double(v);
+ range[1] = g_variant_new_double(v);
+ gvar = g_variant_new_tuple(range, 2);
+ g_variant_builder_add_value(&gvb, gvar);
+ }
+ *data = g_variant_builder_end(&gvb);
+ break;
default:
return SR_ERR_NA;
}
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <math.h>
#include "protocol.h"
SR_PRIV unsigned int get_memory_size(int type)
return SR_OK;
}
+SR_PRIV int set_voltage_threshold(struct dev_context *devc, double thresh)
+{
+ if (thresh > 6.0)
+ thresh = 6.0;
+ if (thresh < -6.0)
+ thresh = -6.0;
+
+ devc->cur_threshold = thresh;
+
+ analyzer_set_voltage_threshold((int) round(-9.1*thresh + 62.6));
+
+ sr_info("Setting voltage threshold to %fV.", devc->cur_threshold);
+
+ return SR_OK;
+}
+
SR_PRIV void set_triggerbar(struct dev_context *devc)
{
unsigned int trigger_depth, triggerbar, ramsize_trigger;
// uint8_t trigger_buffer[NUM_TRIGGER_STAGES];
int trigger;
unsigned int capture_ratio;
+ double cur_threshold;
const struct zp_model *prof;
};
SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate);
SR_PRIV int set_limit_samples(struct dev_context *devc, uint64_t samples);
SR_PRIV int set_capture_ratio(struct dev_context *devc, uint64_t ratio);
+SR_PRIV int set_voltage_threshold(struct dev_context *devc, double thresh);
SR_PRIV void set_triggerbar(struct dev_context *devc);
#endif