sdi = sr_dev_inst_new(0, SR_ST_INACTIVE,
"Sump", "Logic Analyzer", "v1.0");
sdi->driver = di;
- devc = ols_dev_new();
for (i = 0; i < 32; i++) {
if (!(probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE,
ols_probe_names[i])))
return 0;
sdi->probes = g_slist_append(sdi->probes, probe);
}
+ devc = ols_dev_new();
sdi->priv = devc;
}
+ /* Configure samplerate and divider. */
+ if (ols_set_samplerate(sdi, DEFAULT_SAMPLERATE) != SR_OK)
+ sr_dbg("Failed to set default samplerate (%"PRIu64").",
+ DEFAULT_SAMPLERATE);
+ /* Clear trigger masks, values and stages. */
+ ols_configure_probes(sdi);
devc->serial = serial;
+
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
if (send_shortcommand(devc->serial, CMD_RUN) != SR_OK)
return SR_ERR;
+ /* Reset all operational states. */
+ devc->num_transfers = devc->num_samples = devc->num_bytes = 0;
+
/* Send header packet to the session bus. */
std_session_send_df_header(cb_data, DRIVER_LOG_DOMAIN);
return SR_OK;
}
-/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
/* Avoid compiler warnings. */
{
struct dev_context *devc;
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
+ if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
sr_err("Device context malloc failed.");
return NULL;
}
+ /* Device-specific settings */
+ devc->max_samples = devc->max_samplerate = devc->protocol_version = 0;
+
+ /* Acquisition settings */
+ devc->limit_samples = devc->capture_ratio = 0;
devc->trigger_at = -1;
devc->probe_mask = 0xffffffff;
- devc->cur_samplerate = SR_KHZ(200);
+ devc->flag_reg = 0;
+
devc->serial = NULL;
return devc;
#define SERIAL_SPEED B115200
#define CLOCK_RATE SR_MHZ(100)
#define MIN_NUM_SAMPLES 4
+#define DEFAULT_SAMPLERATE SR_KHZ(200)
/* Command opcodes */
#define CMD_RESET 0x00
/* Private, per-device-instance driver context. */
struct dev_context {
- uint32_t max_samplerate;
+ struct sr_serial_dev_inst *serial;
+
+ /* Fixed device settings */
uint32_t max_samples;
+ uint32_t max_samplerate;
uint32_t protocol_version;
+ /* Acquisition settings */
uint64_t cur_samplerate;
uint32_t cur_samplerate_divider;
uint64_t limit_samples;
- /* Current state of the flag register */
- uint32_t flag_reg;
-
- /* Pre/post trigger capture ratio, in percentage.
- * 0 means no pre-trigger data. */
int capture_ratio;
int trigger_at;
uint32_t probe_mask;
uint32_t trigger_mask[4];
uint32_t trigger_value[4];
int num_stages;
+ uint32_t flag_reg;
+ /* Operational states */
unsigned int num_transfers;
unsigned int num_samples;
- int rle_count;
int num_bytes;
+
+ /* Temporary variables */
+ int rle_count;
unsigned char sample[4];
unsigned char tmp_sample[4];
unsigned char *raw_sample_buf;
-
- struct sr_serial_dev_inst *serial;
};