From: Russ Dill Date: Tue, 3 Dec 2013 06:00:30 +0000 (-0800) Subject: zeroplus: Rework triggerbar/trigger address logic X-Git-Tag: libsigrok-0.3.0~473 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b9a5614dbf88d0046e4c1f22e1b8b7666c4f52f8;p=libsigrok.git zeroplus: Rework triggerbar/trigger address logic This reworks the triggerbar/trigger address logic to match the values sent by the windows app for all models (The zerominus tool was used to reprogram the USB device ID on a single device). Additionally, the DONT_CARE_TRIGGERBAR register is always set by the windows app and does not seem to indicate that these registers are "don't care"'s. --- diff --git a/hardware/zeroplus-logic-cube/protocol.c b/hardware/zeroplus-logic-cube/protocol.c index 158b77ca..0f68350e 100644 --- a/hardware/zeroplus-logic-cube/protocol.c +++ b/hardware/zeroplus-logic-cube/protocol.c @@ -93,27 +93,26 @@ SR_PRIV int set_capture_ratio(struct dev_context *devc, uint64_t ratio) SR_PRIV void set_triggerbar(struct dev_context *devc) { - unsigned int ramsize, n, triggerbar; - - ramsize = get_memory_size(devc->memory_size) / 4; - if (devc->trigger) { - n = ramsize; - if (devc->max_sample_depth < n) - n = devc->max_sample_depth; - if (devc->limit_samples < n) - n = devc->limit_samples; - n = n * devc->capture_ratio / 100; - if (n > ramsize - 8) - triggerbar = ramsize - 8; - else - triggerbar = n; - } else { + unsigned int trigger_depth, triggerbar, ramsize_trigger; + + trigger_depth = get_memory_size(devc->memory_size) / 4; + if (devc->limit_samples < trigger_depth) + trigger_depth = devc->limit_samples; + triggerbar = trigger_depth * devc->capture_ratio / 100; + + ramsize_trigger = trigger_depth - triggerbar; + /* Matches USB packet captures from official app/driver */ + if (triggerbar > 2) + triggerbar -= 2; + else { + ramsize_trigger -= 1; triggerbar = 0; } + analyzer_set_triggerbar_address(triggerbar); - analyzer_set_ramsize_trigger_address(ramsize - triggerbar); + analyzer_set_ramsize_trigger_address(ramsize_trigger); sr_dbg("triggerbar_address = %d(0x%x)", triggerbar, triggerbar); sr_dbg("ramsize_triggerbar_address = %d(0x%x)", - ramsize - triggerbar, ramsize - triggerbar); + ramsize_trigger, ramsize_trigger); }