uint8_t sample_delay_l;
};
-struct dslogic_fpga_config {
+struct fpga_config {
uint32_t sync;
uint16_t mode_header;
* Get the session trigger and configure the FPGA structure
* accordingly.
*/
-static void set_trigger(const struct sr_dev_inst *sdi,
- struct dslogic_fpga_config *cfg)
+static void set_trigger(const struct sr_dev_inst *sdi, struct fpga_config *cfg)
{
struct sr_trigger *trigger;
struct sr_trigger_stage *stage;
cfg->ch_en = enabled_channel_mask(sdi);
- cfg->trig_mask0[0] = 0xffff;
- cfg->trig_mask1[0] = 0xffff;
-
- cfg->trig_value0[0] = 0;
- cfg->trig_value1[0] = 0;
-
- cfg->trig_edge0[0] = 0;
- cfg->trig_edge1[0] = 0;
-
- cfg->trig_logic0[0] = 2;
- cfg->trig_logic1[0] = 2;
-
- cfg->trig_count[0] = 0;
-
- cfg->trig_glb = num_enabled_channels << 4;
-
- for (i = 1; i < NUM_TRIGGER_STAGES; i++) {
+ for (i = 0; i < NUM_TRIGGER_STAGES; i++) {
cfg->trig_mask0[i] = 0xffff;
cfg->trig_mask1[i] = 0xffff;
cfg->trig_value0[i] = 0;
}
}
- cfg->trig_glb |= num_trigger_stages;
+ cfg->trig_glb = (num_enabled_channels << 4) | (num_trigger_stages - 1);
}
static int fpga_configure(const struct sr_dev_inst *sdi)
struct dev_context *devc;
struct sr_usb_dev_inst *usb;
uint8_t c[3];
- struct dslogic_fpga_config cfg;
+ struct fpga_config cfg;
uint16_t v16;
uint32_t v32;
int transferred, len, ret;
WL32(&cfg.end_sync, DS_CFG_END);
/* Pass in the length of a fixed-size struct. Really. */
- len = sizeof(struct dslogic_fpga_config) / 2;
+ len = sizeof(struct fpga_config) / 2;
c[0] = len & 0xff;
c[1] = (len >> 8) & 0xff;
c[2] = (len >> 16) & 0xff;
set_trigger(sdi, &cfg);
- len = sizeof(struct dslogic_fpga_config);
+ len = sizeof(struct fpga_config);
ret = libusb_bulk_transfer(usb->devhdl, 2 | LIBUSB_ENDPOINT_OUT,
(unsigned char *)&cfg, len, &transferred, USB_TIMEOUT);
if (ret < 0 || transferred != len) {
struct dev_context *devc;
struct drv_context *drvc;
struct version_info vi;
- int ret, i, device_count;
+ int ret = SR_ERR, i, device_count;
uint8_t revid;
char connection_id[64];
devc = sdi->priv;
usb = sdi->conn;
- if (sdi->status == SR_ST_ACTIVE)
- /* Device is already in use. */
- return SR_ERR;
-
device_count = libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
if (device_count < 0) {
sr_err("Failed to get device list: %s.",
if ((sdi->status == SR_ST_INITIALIZING) ||
(sdi->status == SR_ST_INACTIVE)) {
- /*
- * Check device by its physical USB bus/port address.
- */
+ /* Check device by its physical USB bus/port address. */
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (strcmp(sdi->connection_id, connection_id))
/* This is not the one. */
} else {
sr_err("Failed to open device: %s.",
libusb_error_name(ret));
+ ret = SR_ERR;
break;
}
if ((ret = libusb_detach_kernel_driver(usb->devhdl, USB_INTERFACE)) < 0) {
sr_err("Failed to detach kernel driver: %s.",
libusb_error_name(ret));
- return SR_ERR;
+ ret = SR_ERR;
+ break;
}
}
}
sr_err("Expected firmware version %d.x, "
"got %d.%d.", DSLOGIC_REQUIRED_VERSION_MAJOR,
vi.major, vi.minor);
+ ret = SR_ERR;
break;
}
- sdi->status = SR_ST_ACTIVE;
sr_info("Opened device on %d.%d (logical) / %s (physical), "
"interface %d, firmware %d.%d.",
usb->bus, usb->address, connection_id,
sr_info("Detected REVID=%d, it's a Cypress CY7C68013%s.",
revid, (revid != 1) ? " (FX2)" : "A (FX2LP)");
+ ret = SR_OK;
+
break;
}
- libusb_free_device_list(devlist, 1);
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR;
+ libusb_free_device_list(devlist, 1);
- return SR_OK;
+ return ret;
}
SR_PRIV struct dev_context *dslogic_dev_new(void)