#include "libsigrok-internal.h"
#include "protocol.h"
-/*
- * Default device configuration. Must be applicable to any of the
- * supported devices (no model specific default values yet). Specific
- * firmware implementation details unfortunately won't let us detect
- * and keep using previously configured values.
- */
-#define LA2016_DFLT_SAMPLERATE SR_MHZ(100)
-#define LA2016_DFLT_SAMPLEDEPTH (5 * 1000 * 1000)
-#define LA2016_DFLT_CAPT_RATIO 5 /* Capture ratio, in percent. */
-
static const uint32_t scanopts[] = {
SR_CONF_CONN,
};
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;
}
sr_sw_limits_init(&devc->sw_limits);
- devc->sw_limits.limit_samples = LA2016_DFLT_SAMPLEDEPTH;
- devc->capture_ratio = LA2016_DFLT_CAPT_RATIO;
- devc->cur_samplerate = LA2016_DFLT_SAMPLERATE;
+ devc->sw_limits.limit_samples = 0;
+ devc->capture_ratio = 50;
+ devc->cur_samplerate = devc->model->samplerate;
devc->threshold_voltage_idx = 0;
devc->threshold_voltage = logic_threshold_value[devc->threshold_voltage_idx];
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);
*data = std_gvar_samplerates(ARRAY_AND_SIZE(rates_100mhz));
break;
case SR_CONF_LIMIT_SAMPLES:
- *data = std_gvar_tuple_u64(LA2016_NUM_SAMPLES_MIN,
- LA2016_NUM_SAMPLES_MAX);
+ *data = std_gvar_tuple_u64(0, LA2016_NUM_SAMPLES_MAX);
break;
case SR_CONF_VOLTAGE_THRESHOLD:
*data = std_gvar_min_max_step_thresholds(