Implement the configuration setting TRIGGER_SOURCE with the
choices CH (logic channels) and TRG (external trigger input).
Also implement the TRIGGER_SLOPE setting for selecting the
edge to trigger on (rising or falling).
It turns out that all LWLA protocol responses consist either
of 32-bit units or of 32-bit units combined into 64-bit units.
Thus it makes sense to double the basic unit size for reading
from 16 bit to 32 bit.
We cannot do the same for command messages though, as those
actually do use 16-bit quantities in some places, and 32-bit
arguments are not always aligned to 32-bit boundaries.
(acquisition_state.xfer_buf_in): Change unit type to uint32_t,
and update related macros and code accordingly.
(LWLA_TO_UINT32): New macro to replace LWLA_READ32, operating
directly on 32-bit values instead of pointers to 16-bit units.
Make use of a compiler-recognized idiom for bitwise rotation
to efficiently swap the 16-bit halves of a 32-bit word.
(LWLA_TO_UINT16): New macro to replace LWLA_READ16.
(LWLA_READ64): Remove unused macro.
(LWLA_WORD_[0123]): Slightly simplify 16-bit word extraction.
Move setup of channels and trigger masks to the new probe
configuration callback. Although the actual hardware setup
still happens just before acquisition, the new approach
already has the advantage that invalid settings are caught
early.
Also, it turns out that the LWLA1034 allows triggering on
channels which are not enabled for data acquisition. This
feature is now supported as well.
(process_sample_data): When expanding run-length samples into
session packets, calculate the number of samples to write in
advance while honoring all constraints. This is cleaner than
checking constraints within the expansion loop. Also, the new
logic always fills up packets exactly to whatever limit applies
first, thereby removing the need for truncation after the fact.
Allow the acquisition to be constrained by time in addition to
a sample count limit. Since the LWLA protocol actually provides
only a duration natively, implement the sample count limit on top
of the new duration limit.
With this change, limiting an acquisition in external clock mode
should finally work properly.