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,
while (1) {
status = gl_reg_read(devh, DEV_STATUS);
- if ((status & set) && ((status & unset) == 0))
+ if ((!set || (status & set)) && ((status & unset) == 0))
return;
}
}
SR_PRIV void analyzer_read_start(libusb_device_handle *devh)
{
- int i;
-
analyzer_write_status(devh, 3, STATUS_FLAG_20 | STATUS_FLAG_READ);
- for (i = 0; i < 8; i++)
- (void)gl_reg_read(devh, READ_RAM_STATUS);
+ /* Prep for bulk reads */
+ gl_reg_read_buf(devh, READ_RAM_STATUS, NULL, 0);
}
SR_PRIV int analyzer_read_data(libusb_device_handle *devh, void *buffer,
__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);
__analyzer_set_triggerbar_address(devh, g_triggerbar_addr);
/* Set_Dont_Care_TriggerBar */
- if (g_triggerbar_addr)
- gl_reg_write(devh, DONT_CARE_TRIGGERBAR, 0x00);
- else
- gl_reg_write(devh, DONT_CARE_TRIGGERBAR, 0x01);
+ gl_reg_write(devh, DONT_CARE_TRIGGERBAR, 0x01);
/* Enable_Status */
analyzer_set_filter(devh);
__analyzer_set_compression(devh, g_compression);
}
-SR_PRIV void analyzer_add_trigger(int channel, int type)
-{
- switch (type) {
- case TRIGGER_HIGH:
- g_trigger_status[channel / 4] |= 1 << (channel % 4 * 2);
- break;
- case TRIGGER_LOW:
- g_trigger_status[channel / 4] |= 2 << (channel % 4 * 2);
- break;
-#if 0
- case TRIGGER_POSEDGE:
- g_trigger_status[8] = 0x40 | channel;
- break;
- case TRIGGER_NEGEDGE:
- g_trigger_status[8] = 0x80 | channel;
- break;
- case TRIGGER_ANYEDGE:
- g_trigger_status[8] = 0xc0 | channel;
- break;
-#endif
- default:
- break;
+SR_PRIV int analyzer_add_triggers(const struct sr_dev_inst *sdi)
+{
+ struct dev_context *devc;
+ struct sr_trigger *trigger;
+ struct sr_trigger_stage *stage;
+ struct sr_trigger_match *match;
+ GSList *l, *m;
+ int channel;
+
+ devc = sdi->priv;
+
+ if (!(trigger = sr_session_trigger_get(sdi->session)))
+ return SR_OK;
+
+ for (l = trigger->stages; l; l = l->next) {
+ stage = l->data;
+ for (m = stage->matches; m; m = m->next) {
+ match = m->data;
+ devc->trigger = 1;
+ if (!match->channel->enabled)
+ /* Ignore disabled channels with a trigger. */
+ 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)
g_ramsize_triggerbar_addr = address;
}
+SR_PRIV unsigned int analyzer_get_ramsize_trigger_address(void)
+{
+ return g_ramsize_triggerbar_addr;
+}
+
SR_PRIV void analyzer_set_triggerbar_address(unsigned int address)
{
g_triggerbar_addr = address;
}
+SR_PRIV unsigned int analyzer_get_triggerbar_address(void)
+{
+ return g_triggerbar_addr;
+}
+
SR_PRIV unsigned int analyzer_read_status(libusb_device_handle *devh)
{
return gl_reg_read(devh, DEV_STATUS);
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_wait_data(libusb_device_handle *devh)
{
- analyzer_wait(devh, STATUS_READY | 8, STATUS_BUSY);
+ analyzer_wait(devh, 0, STATUS_BUSY);
}
SR_PRIV int analyzer_decompress(void *input, unsigned int input_len,