Commit Graph

23 Commits

Author SHA1 Message Date
Uwe Hermann a6c12f3f70 Drop unneeded comments. 2014-01-30 17:52:44 +01:00
Daniel Elstner 6358f0a956 sysclk-lwla: Implement SR_CONF_CLOCK_EDGE setting. 2014-01-30 12:04:42 +01:00
Daniel Elstner e6e54bd253 sysclk-lwla: Add support for external trigger input.
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).
2014-01-28 23:34:53 +01:00
Daniel Elstner e0df15d436 sysclk-lwla: Simplify and optimize word extraction.
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.
2014-01-28 23:34:53 +01:00
Daniel Elstner 5413df1952 sysclk-lwla: Limit use of SR_ERR_ARG to user-supplied arguments.
The return code SR_ERR_ARG is intended for reporting unsupported
or inapplicable device configuration settings and is not a hard
error.  In order to indicate failure of internal sanity checks,
use SR_ERR_BUG instead.
2014-01-28 23:26:16 +01:00
Daniel Elstner c2066c2104 sysclk-lwla: Load bitstream files in RBF format.
Modify the bitstream loading routine to work directly with the
Raw Binary Files (.rbf) generated by Altera tools.  Previously,
a custom format was used which was basically an RBF preceded by
a 4-byte header specifying the transfer length.
2014-01-25 20:44:42 +01:00
Daniel Elstner ee38c8ba3e sysclk-lwla: Implement config_commit() callback.
Move pre-acquisition hardware setup to the new config_commit()
callback.  At the moment, the only setting applied at commit
time is switching the clock source, which involves uploading
a new bitstream to the FPGA.
2014-01-23 02:43:16 +01:00
Daniel Elstner 43db343618 sysclk-lwla: Implement config_probe_set() callback.
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.
2014-01-23 02:36:13 +01:00
Daniel Elstner 50cad98d1b sysclk-lwla: Do not reset drv_context.instances on scan.
Apparently, frontends may call scan() more than once to accumulate
multiple devices, so do not reset the instance list pointer at the
start of each scan.  Also, number devices continuously across scans.
2014-01-23 02:36:13 +01:00
Daniel Elstner 99c76642aa sysclk-lwla: Advertise SR_CONF_CONN option. 2014-01-23 02:36:13 +01:00
Daniel Elstner 9497f49ef8 sysclk-lwla: Improve message log output.
Report settings at acquisition start as informational messages.
Print a message when the the trigger condition has been met.
Demote some other messages from information to debug, and use
the %zu format for printing size_t values.
2014-01-18 19:09:56 +01:00
Daniel Elstner 2cfd16a316 sysclk-lwla: Streamline packet output logic.
(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.
2014-01-18 17:36:23 +01:00
Daniel Elstner 29d587670d sysclk-lwla: Implement SR_CONF_LIMIT_MSEC.
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.
2014-01-18 16:08:39 +01:00
Daniel Elstner 0b92c32cb8 sysclk-lwla: Make use of the probe index again.
(configure_probes): sr_probe::index has been un-deprecated,
so use it instead of relying on the list order.
2014-01-15 21:44:59 +01:00
Daniel Elstner d02d475442 sysclk-lwla: Bypass divider in external clock mode.
(lwla_setup_acquisition): Set the clock divider bypass
flag to 1 for the external clock modes as well.
(capture_setup): Set the clock divide count to 0 if an
external clock source is selected.
2014-01-15 21:44:59 +01:00
Daniel Elstner 313c7a7da2 sysclk-lwla: Utility functions clean-up and semantic fixes.
(lwla_send_bitstream): Unref the mapped file earlier in order
to simplify the error handling.
(lwla_receive_reply): Do not treat a reply buffer length of
zero as silent no-op.  That logic was left over from an earlier
iteration, before the distinction between reply buffer size and
expected read length was introduced.
2014-01-15 21:44:59 +01:00
Daniel Elstner 60e2fa0a03 sysclk-lwla: Remove unused dev_context::next_state. 2014-01-15 21:44:59 +01:00
Daniel Elstner 945e4343e2 sysclk-lwla: Avoid warning due to bogus range check.
(lwla_set_clock_source): Checking whether an enum value is greater
than or equal to zero apparently results in a warning with some
compilers.  Assign the enum to an unsigned variable to avoid this,
and return SR_ERR_BUG if the range is exceeded, as this indicates
a bug in the driver code itself.
2014-01-15 21:43:54 +01:00
Uwe Hermann 1f98295dfa sysclk-lwla: Fix probe name issue.
The g_ascii_formatd() function expects the "format" argument to start
with a '%' character, e.g. it should be "%f" or such (this is not
clearly documented in the glib API docs, but visible from the source code).

The usage of "CH%f" for example will trigger an assertion and thus make the
LWLA device unusable in practice (e.g. in PulseView on Windows no probenames
would be shown, and sampling wouldn't work).

Example:
  GLib-CRITICAL **: g_ascii_formatd: assertion 'format[0] == '%'' failed

(not exposed in all glib versions or builds of glib on all distros
apparently, some may need G_MESSAGES_DEBUG=all or other measures)

From the glib g_ascii_formatd() code:
  g_return_val_if_fail (format[0] == '%', NULL);

We now use g_snprintf() instead for simplicity. This has been tested to
fix this specific issue (i.e. the probenames now do show up in PulseView).

This closes bug #270.
2014-01-14 19:52:26 +01:00
Daniel Elstner 7ebe9b9e7e sysclk-lwla: Honor SR_CONF_CONN at scan time. 2014-01-14 19:33:31 +01:00
Daniel Elstner 8a3ddd8815 sysclk-lwla: Fix calculation of the running sample count.
Field 7 of the status response is actually a duration in
milliseconds at all samplerates but 125 MHz.
2014-01-14 19:33:31 +01:00
Daniel Elstner 5874e88d83 sysclk-lwla: Implement support for the LWLA1034. 2014-01-14 19:33:31 +01:00
Daniel Elstner aeaad0b0b5 sysclk-lwla: Initial driver skeleton. 2014-01-14 19:33:31 +01:00