zeroplus-logic-cube: Use new trigger API.
This commit is contained in:
parent
bbe7e48a88
commit
28731bab29
|
@ -488,29 +488,43 @@ SR_PRIV void analyzer_configure(libusb_device_handle *devh)
|
||||||
__analyzer_set_compression(devh, g_compression);
|
__analyzer_set_compression(devh, g_compression);
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV void analyzer_add_trigger(int channel, int type)
|
SR_PRIV int analyzer_add_triggers(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
switch (type) {
|
struct dev_context *devc;
|
||||||
case TRIGGER_HIGH:
|
struct sr_trigger *trigger;
|
||||||
g_trigger_status[channel / 4] |= 1 << (channel % 4 * 2);
|
struct sr_trigger_stage *stage;
|
||||||
break;
|
struct sr_trigger_match *match;
|
||||||
case TRIGGER_LOW:
|
GSList *l, *m;
|
||||||
g_trigger_status[channel / 4] |= 2 << (channel % 4 * 2);
|
int channel;
|
||||||
break;
|
|
||||||
#if 0
|
devc = sdi->priv;
|
||||||
case TRIGGER_POSEDGE:
|
|
||||||
g_trigger_status[8] = 0x40 | channel;
|
if (!(trigger = sr_session_trigger_get()))
|
||||||
break;
|
return SR_OK;
|
||||||
case TRIGGER_NEGEDGE:
|
|
||||||
g_trigger_status[8] = 0x80 | channel;
|
for (l = trigger->stages; l; l = l->next) {
|
||||||
break;
|
stage = l->data;
|
||||||
case TRIGGER_ANYEDGE:
|
for (m = stage->matches; m; m = m->next) {
|
||||||
g_trigger_status[8] = 0xc0 | channel;
|
match = m->data;
|
||||||
break;
|
devc->trigger = 1;
|
||||||
#endif
|
if (!match->channel->enabled)
|
||||||
default:
|
/* Ignore disabled channels with a trigger. */
|
||||||
break;
|
continue;
|
||||||
|
channel = match->channel->index;
|
||||||
|
switch (match->match) {
|
||||||
|
case SR_TRIGGER_ZERO:
|
||||||
|
g_trigger_status[channel / 4] |= 2 << (channel % 4 * 2);
|
||||||
|
case SR_TRIGGER_ONE:
|
||||||
|
g_trigger_status[channel / 4] |= 1 << (channel % 4 * 2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sr_err("Unsupported match %d", match->match);
|
||||||
|
return SR_ERR;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV void analyzer_add_filter(int channel, int type)
|
SR_PRIV void analyzer_add_filter(int channel, int type)
|
||||||
|
|
|
@ -74,14 +74,6 @@
|
||||||
#define COMPRESSION_ENABLE 0x8001
|
#define COMPRESSION_ENABLE 0x8001
|
||||||
#define COMPRESSION_DOUBLE 0x8002
|
#define COMPRESSION_DOUBLE 0x8002
|
||||||
|
|
||||||
enum {
|
|
||||||
TRIGGER_HIGH = 0,
|
|
||||||
TRIGGER_LOW,
|
|
||||||
TRIGGER_POSEDGE,
|
|
||||||
TRIGGER_NEGEDGE,
|
|
||||||
TRIGGER_ANYEDGE,
|
|
||||||
};
|
|
||||||
|
|
||||||
SR_PRIV void analyzer_set_freq(int freq, int scale);
|
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_ramsize_trigger_address(unsigned int address);
|
||||||
SR_PRIV void analyzer_set_triggerbar_address(unsigned int address);
|
SR_PRIV void analyzer_set_triggerbar_address(unsigned int address);
|
||||||
|
@ -89,7 +81,7 @@ SR_PRIV unsigned int analyzer_get_ramsize_trigger_address(void );
|
||||||
SR_PRIV unsigned int analyzer_get_triggerbar_address(void);
|
SR_PRIV unsigned int analyzer_get_triggerbar_address(void);
|
||||||
SR_PRIV void analyzer_set_compression(unsigned int type);
|
SR_PRIV void analyzer_set_compression(unsigned int type);
|
||||||
SR_PRIV void analyzer_set_memory_size(unsigned int size);
|
SR_PRIV void analyzer_set_memory_size(unsigned int size);
|
||||||
SR_PRIV void analyzer_add_trigger(int channel, int type);
|
SR_PRIV int analyzer_add_triggers(const struct sr_dev_inst *sdi);
|
||||||
SR_PRIV void analyzer_set_trigger_count(int count);
|
SR_PRIV void analyzer_set_trigger_count(int count);
|
||||||
SR_PRIV void analyzer_add_filter(int channel, int type);
|
SR_PRIV void analyzer_add_filter(int channel, int type);
|
||||||
SR_PRIV void analyzer_set_voltage_threshold(int thresh);
|
SR_PRIV void analyzer_set_voltage_threshold(int thresh);
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#define USB_INTERFACE 0
|
#define USB_INTERFACE 0
|
||||||
#define USB_CONFIGURATION 1
|
#define USB_CONFIGURATION 1
|
||||||
#define NUM_TRIGGER_STAGES 4
|
#define NUM_TRIGGER_STAGES 4
|
||||||
#define TRIGGER_TYPE "01"
|
|
||||||
#define PACKET_SIZE 2048 /* ?? */
|
#define PACKET_SIZE 2048 /* ?? */
|
||||||
|
|
||||||
//#define ZP_EXPERIMENTAL
|
//#define ZP_EXPERIMENTAL
|
||||||
|
@ -56,12 +55,17 @@ static const struct zp_model zeroplus_models[] = {
|
||||||
static const int32_t hwcaps[] = {
|
static const int32_t hwcaps[] = {
|
||||||
SR_CONF_LOGIC_ANALYZER,
|
SR_CONF_LOGIC_ANALYZER,
|
||||||
SR_CONF_SAMPLERATE,
|
SR_CONF_SAMPLERATE,
|
||||||
SR_CONF_TRIGGER_TYPE,
|
SR_CONF_TRIGGER_MATCH,
|
||||||
SR_CONF_CAPTURE_RATIO,
|
SR_CONF_CAPTURE_RATIO,
|
||||||
SR_CONF_VOLTAGE_THRESHOLD,
|
SR_CONF_VOLTAGE_THRESHOLD,
|
||||||
SR_CONF_LIMIT_SAMPLES,
|
SR_CONF_LIMIT_SAMPLES,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const int32_t trigger_matches[] = {
|
||||||
|
SR_TRIGGER_ZERO,
|
||||||
|
SR_TRIGGER_ONE,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ZEROPLUS LAP-C (16032) numbers the 16 channels A0-A7 and B0-B7.
|
* ZEROPLUS LAP-C (16032) numbers the 16 channels A0-A7 and B0-B7.
|
||||||
* We currently ignore other untested/unsupported devices here.
|
* We currently ignore other untested/unsupported devices here.
|
||||||
|
@ -124,95 +128,6 @@ const uint64_t samplerates_200[] = {
|
||||||
|
|
||||||
static int dev_close(struct sr_dev_inst *sdi);
|
static int dev_close(struct sr_dev_inst *sdi);
|
||||||
|
|
||||||
#if 0
|
|
||||||
static int configure_channels(const struct sr_dev_inst *sdi)
|
|
||||||
{
|
|
||||||
struct dev_context *devc;
|
|
||||||
const struct sr_channel *ch;
|
|
||||||
const GSList *l;
|
|
||||||
int channel_bit, stage, i;
|
|
||||||
char *tc;
|
|
||||||
|
|
||||||
/* Note: sdi and sdi->priv are non-NULL, the caller checked this. */
|
|
||||||
devc = sdi->priv;
|
|
||||||
|
|
||||||
devc->channel_mask = 0;
|
|
||||||
for (i = 0; i < NUM_TRIGGER_STAGES; i++) {
|
|
||||||
devc->trigger_mask[i] = 0;
|
|
||||||
devc->trigger_value[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
stage = -1;
|
|
||||||
for (l = sdi->channels; l; l = l->next) {
|
|
||||||
ch = (struct sr_channel *)l->data;
|
|
||||||
if (ch->enabled == FALSE)
|
|
||||||
continue;
|
|
||||||
channel_bit = 1 << (ch->index);
|
|
||||||
devc->channel_mask |= channel_bit;
|
|
||||||
|
|
||||||
if (ch->trigger) {
|
|
||||||
stage = 0;
|
|
||||||
for (tc = ch->trigger; *tc; tc++) {
|
|
||||||
devc->trigger_mask[stage] |= channel_bit;
|
|
||||||
if (*tc == '1')
|
|
||||||
devc->trigger_value[stage] |= channel_bit;
|
|
||||||
stage++;
|
|
||||||
if (stage > NUM_TRIGGER_STAGES)
|
|
||||||
return SR_ERR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return SR_OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int configure_channels(const struct sr_dev_inst *sdi)
|
|
||||||
{
|
|
||||||
struct dev_context *devc;
|
|
||||||
const GSList *l;
|
|
||||||
const struct sr_channel *ch;
|
|
||||||
char *tc;
|
|
||||||
int type;
|
|
||||||
|
|
||||||
/* Note: sdi and sdi->priv are non-NULL, the caller checked this. */
|
|
||||||
devc = sdi->priv;
|
|
||||||
|
|
||||||
for (l = sdi->channels; l; l = l->next) {
|
|
||||||
ch = (struct sr_channel *)l->data;
|
|
||||||
if (ch->enabled == FALSE)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((tc = ch->trigger)) {
|
|
||||||
switch (*tc) {
|
|
||||||
case '1':
|
|
||||||
type = TRIGGER_HIGH;
|
|
||||||
break;
|
|
||||||
case '0':
|
|
||||||
type = TRIGGER_LOW;
|
|
||||||
break;
|
|
||||||
#if 0
|
|
||||||
case 'r':
|
|
||||||
type = TRIGGER_POSEDGE;
|
|
||||||
break;
|
|
||||||
case 'f':
|
|
||||||
type = TRIGGER_NEGEDGE;
|
|
||||||
break;
|
|
||||||
case 'c':
|
|
||||||
type = TRIGGER_ANYEDGE;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
return SR_ERR;
|
|
||||||
}
|
|
||||||
analyzer_add_trigger(ch->index, type);
|
|
||||||
devc->trigger = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return SR_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate)
|
SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -576,8 +491,10 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
|
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
|
||||||
*data = g_variant_builder_end(&gvb);
|
*data = g_variant_builder_end(&gvb);
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_TYPE:
|
case SR_CONF_TRIGGER_MATCH:
|
||||||
*data = g_variant_new_string(TRIGGER_TYPE);
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
||||||
|
trigger_matches, ARRAY_SIZE(trigger_matches),
|
||||||
|
sizeof(int32_t));
|
||||||
break;
|
break;
|
||||||
case SR_CONF_VOLTAGE_THRESHOLD:
|
case SR_CONF_VOLTAGE_THRESHOLD:
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
|
g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
|
||||||
|
@ -635,8 +552,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configure_channels(sdi) != SR_OK) {
|
if (analyzer_add_triggers(sdi) != SR_OK) {
|
||||||
sr_err("Failed to configure channels.");
|
sr_err("Failed to configure triggers.");
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue