sr_err("Cannot communicate to MCU firmware.");
return ret;
}
+
+ /*
+ * Also complete the hardware configuration (FPGA bitstream)
+ * when MCU firmware communication became operational. Either
+ * failure is considered fatal when probing for the device.
+ */
ret = la2016_identify_device(sdi, show_message);
+ if (ret == SR_OK) {
+ ret = la2016_init_hardware(sdi);
+ }
+
la2016_close_usb(usb);
return ret;
return ret;
}
+ /*
+ * Setup a default configuration of device features. This
+ * affects the logic threshold, PWM channels, and similar.
+ */
+ ret = la2016_init_params(sdi);
+ if (ret != SR_OK) {
+ sr_err("Cannot initialize device's hardware.");
+ return ret;
+ }
+
return SR_OK;
}
if (!usb->devhdl)
return SR_ERR_BUG;
- la2016_deinit_device(sdi);
+ la2016_deinit_hardware(sdi);
sr_info("Closing device on %d.%d (logical) / %s (physical) interface %d.",
usb->bus, usb->address, sdi->connection_id, USB_INTERFACE);
return SR_OK;
}
-SR_PRIV int la2016_init_device(const struct sr_dev_inst *sdi)
+SR_PRIV int la2016_init_hardware(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
const char *bitstream_fn;
sr_warn("Unexpected run state, want 0x85e9, got 0x%04x.", state);
}
- if ((ret = ctrl_out(sdi, CMD_BULK_RESET, 0x00, 0, NULL, 0)) != SR_OK) {
+ ret = ctrl_out(sdi, CMD_BULK_RESET, 0x00, 0, NULL, 0);
+ if (ret != SR_OK) {
sr_err("Cannot reset USB bulk transfer.");
return ret;
}
sr_dbg("Device should be initialized.");
+ return SR_OK;
+}
+
+SR_PRIV int la2016_init_params(const struct sr_dev_inst *sdi)
+{
+ int ret;
+
ret = set_defaults(sdi);
if (ret != SR_OK)
return ret;
return SR_OK;
}
-SR_PRIV int la2016_deinit_device(const struct sr_dev_inst *sdi)
+SR_PRIV int la2016_deinit_hardware(const struct sr_dev_inst *sdi)
{
int ret;
- if ((ret = ctrl_out(sdi, CMD_FPGA_ENABLE, 0x00, 0, NULL, 0)) != SR_OK) {
+ ret = ctrl_out(sdi, CMD_FPGA_ENABLE, 0x00, 0, NULL, 0);
+ if (ret != SR_OK) {
sr_err("Cannot deinitialize device's FPGA.");
return ret;
}
SR_PRIV int la2016_receive_data(int fd, int revents, void *cb_data);
SR_PRIV int la2016_identify_device(const struct sr_dev_inst *sdi,
gboolean show_message);
-SR_PRIV int la2016_init_device(const struct sr_dev_inst *sdi);
-SR_PRIV int la2016_deinit_device(const struct sr_dev_inst *sdi);
+SR_PRIV int la2016_init_hardware(const struct sr_dev_inst *sdi);
+SR_PRIV int la2016_init_params(const struct sr_dev_inst *sdi);
+SR_PRIV int la2016_deinit_hardware(const struct sr_dev_inst *sdi);
#endif