From: v1ne Date: Tue, 31 Mar 2020 16:48:30 +0000 (+0200) Subject: ols: Symbolic name for magic value, reflect units in variable names X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=a2b1a53bb41336756688f98aeecb16072ec95543;p=libsigrok.git ols: Symbolic name for magic value, reflect units in variable names Reviewed-By: Wolfram Sang --- diff --git a/src/hardware/openbench-logic-sniffer/api.c b/src/hardware/openbench-logic-sniffer/api.c index 5cf415df..c8915fbb 100644 --- a/src/hardware/openbench-logic-sniffer/api.c +++ b/src/hardware/openbench-logic-sniffer/api.c @@ -440,7 +440,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) return SR_ERR; delaycount = readcount * (1 - devc->capture_ratio / 100.0); - devc->trigger_at = (readcount - delaycount) * 4 - devc->num_stages; + devc->trigger_at_smpl = (readcount - delaycount) * 4 - devc->num_stages; for (i = 0; i <= devc->num_stages; i++) { sr_dbg("Setting OLS stage %d trigger.", i); if ((ret = set_trigger(sdi, i)) != SR_OK) diff --git a/src/hardware/openbench-logic-sniffer/protocol.c b/src/hardware/openbench-logic-sniffer/protocol.c index 36a091c7..a1b16806 100644 --- a/src/hardware/openbench-logic-sniffer/protocol.c +++ b/src/hardware/openbench-logic-sniffer/protocol.c @@ -134,7 +134,7 @@ SR_PRIV struct dev_context *ols_dev_new(void) struct dev_context *devc; devc = g_malloc0(sizeof(struct dev_context)); - devc->trigger_at = -1; + devc->trigger_at_smpl = OLS_NO_TRIGGER; return devc; } @@ -491,16 +491,16 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data) sr_dbg("Received %d bytes, %d samples, %d decompressed samples.", devc->cnt_bytes, devc->cnt_samples, devc->cnt_samples_rle); - if (devc->trigger_at != -1) { + if (devc->trigger_at_smpl != OLS_NO_TRIGGER) { /* * A trigger was set up, so we need to tell the frontend * about it. */ - if (devc->trigger_at > 0) { + if (devc->trigger_at_smpl > 0) { /* There are pre-trigger samples, send those first. */ packet.type = SR_DF_LOGIC; packet.payload = &logic; - logic.length = devc->trigger_at * 4; + logic.length = devc->trigger_at_smpl * 4; logic.unitsize = 4; logic.data = devc->raw_sample_buf + (devc->limit_samples - devc->num_samples) * 4; @@ -513,9 +513,9 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data) /* Send post-trigger samples. */ packet.type = SR_DF_LOGIC; packet.payload = &logic; - logic.length = (devc->num_samples * 4) - (devc->trigger_at * 4); + logic.length = (devc->num_samples * 4) - (devc->trigger_at_smpl * 4); logic.unitsize = 4; - logic.data = devc->raw_sample_buf + devc->trigger_at * 4 + + logic.data = devc->raw_sample_buf + devc->trigger_at_smpl * 4 + (devc->limit_samples - devc->num_samples) * 4; sr_session_send(sdi, &packet); } else { diff --git a/src/hardware/openbench-logic-sniffer/protocol.h b/src/hardware/openbench-logic-sniffer/protocol.h index eb7478c5..2303c3fd 100644 --- a/src/hardware/openbench-logic-sniffer/protocol.h +++ b/src/hardware/openbench-logic-sniffer/protocol.h @@ -65,6 +65,9 @@ #define FLAG_FILTER (1 << 1) #define FLAG_DEMUX (1 << 0) +/* Capture context magic numbers */ +#define OLS_NO_TRIGGER (-1) + struct dev_context { /* constant device properties: */ int max_channels; @@ -77,7 +80,7 @@ struct dev_context { uint32_t cur_samplerate_divider; uint64_t limit_samples; uint64_t capture_ratio; - int trigger_at; + int trigger_at_smpl; uint32_t channel_mask; uint32_t trigger_mask[NUM_TRIGGER_STAGES]; uint32_t trigger_value[NUM_TRIGGER_STAGES];