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.
This commit is contained in:
Russ Dill 2013-12-02 22:00:30 -08:00 committed by Bert Vermeulen
parent c38e64c742
commit b9a5614dbf
1 changed files with 15 additions and 16 deletions

View File

@ -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) SR_PRIV void set_triggerbar(struct dev_context *devc)
{ {
unsigned int ramsize, n, triggerbar; unsigned int trigger_depth, triggerbar, ramsize_trigger;
ramsize = get_memory_size(devc->memory_size) / 4; trigger_depth = get_memory_size(devc->memory_size) / 4;
if (devc->trigger) { if (devc->limit_samples < trigger_depth)
n = ramsize; trigger_depth = devc->limit_samples;
if (devc->max_sample_depth < n) triggerbar = trigger_depth * devc->capture_ratio / 100;
n = devc->max_sample_depth;
if (devc->limit_samples < n) ramsize_trigger = trigger_depth - triggerbar;
n = devc->limit_samples; /* Matches USB packet captures from official app/driver */
n = n * devc->capture_ratio / 100; if (triggerbar > 2)
if (n > ramsize - 8) triggerbar -= 2;
triggerbar = ramsize - 8; else {
else ramsize_trigger -= 1;
triggerbar = n;
} else {
triggerbar = 0; triggerbar = 0;
} }
analyzer_set_triggerbar_address(triggerbar); 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("triggerbar_address = %d(0x%x)", triggerbar, triggerbar);
sr_dbg("ramsize_triggerbar_address = %d(0x%x)", sr_dbg("ramsize_triggerbar_address = %d(0x%x)",
ramsize - triggerbar, ramsize - triggerbar); ramsize_trigger, ramsize_trigger);
} }