summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
inline | side by side (from parent 1:
64172b1)
Complete all of the MCU firmware load, device type identification, FPGA
bitstream load, and FPGA initialization by the end of scan(). This gives
an easily usable device of known capabilities for the remaining driver
lifetime, which just needs to get opened by connection ID (which was
retrieved during scan).
I still don't like how the driver's open() configures PWM without user
provided specs. And enforcing the logic threshold is redundant before
acquisition start. This needs more attention later.
sr_err("Cannot communicate to MCU firmware.");
return ret;
}
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);
ret = la2016_identify_device(sdi, show_message);
+ if (ret == SR_OK) {
+ ret = la2016_init_hardware(sdi);
+ }
+
la2016_close_usb(usb);
return ret;
la2016_close_usb(usb);
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;
+ }
+
if (!usb->devhdl)
return SR_ERR_BUG;
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);
sr_info("Closing device on %d.%d (logical) / %s (physical) interface %d.",
usb->bus, usb->address, sdi->connection_id, USB_INTERFACE);
-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;
{
struct dev_context *devc;
const char *bitstream_fn;
sr_warn("Unexpected run state, want 0x85e9, got 0x%04x.", state);
}
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.");
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;
ret = set_defaults(sdi);
if (ret != SR_OK)
return ret;
-SR_PRIV int la2016_deinit_device(const struct sr_dev_inst *sdi)
+SR_PRIV int la2016_deinit_hardware(const struct sr_dev_inst *sdi)
- 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_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_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);