Mike Frysinger [Sat, 14 Jun 2014 02:44:40 +0000 (22:44 -0400)]
asix-sigma: fix build time warnings
We need to include unistd.h for usleep():
hardware/asix-sigma/asix-sigma.c: In function 'sigma_fpga_init_bitbang':
hardware/asix-sigma/asix-sigma.c:450:3: warning: implicit declaration of function 'usleep'
usleep(10000);
And we need to tweak the type of chunks_per_read to match dl_lines_total:
hardware/asix-sigma/asix-sigma.c: In function 'download_capture':
hardware/asix-sigma/asix-sigma.c:1161:39: warning: comparison between signed and unsigned integer expressions
dl_lines_curr = MIN(chunks_per_read, dl_lines_total);
Bert Vermeulen [Thu, 22 May 2014 23:21:58 +0000 (01:21 +0200)]
Add new triggering framework.
The new triggers consist of a set of structs and an API to manipulate
them. Both logic and analog triggers are supported, in an unlimited
number of stages.
A single struct sr_trigger containing its stages and triggers is then
added to the session.
In case of a driver where the hardware supports triggering, the struct
is then converted and used to arm the hardware trigger. Drivers without
hardware trigger support, such as fx2lafw or multimeter drivers, use it
as the basis for a software-based trigger implementation instead.
Uwe Hermann [Sun, 4 May 2014 15:44:05 +0000 (17:44 +0200)]
Unhook the Link Instruments MSO-19 from the build for now.
This driver is neither working nor has it been in a compiling state for
a long time, so unhook it from the build until it is fixed and works.
The files (api.c and protocol.[ch]) are still in git, but won't end up in
released tarballs and they don't get built (neither git nor tarballs).
This also allows us to drop the otherwise unneeded dependency on libudev.
When the MSO-19 driver comes back, it should be in a form that doesn't
require the inherently Linux-only libudev anyway. See also:
http://sigrok.org/bugzilla/show_bug.cgi?id=65
Marek Vasut [Fri, 25 Apr 2014 16:03:47 +0000 (18:03 +0200)]
asix-sigma: Init cur_sample_rate
Init the cur_sample_rate to 200kHz. This is now the default sample
rate for the ASIX Sigma if no other is specified by -c samplerate=N
on the command line. Without this change, the driver would crash on
SIGFPE because a division by zero would happen.
Marek Vasut [Sun, 20 Apr 2014 23:44:36 +0000 (01:44 +0200)]
asix-sigma: Fix the trigger handling
Due to the recent changes in the sigma driver, the trigger handling got
broken. Fix this by properly calculating and propagating the fact that
the trigger happened.
Marek Vasut [Sun, 20 Apr 2014 01:10:05 +0000 (03:10 +0200)]
asix-sigma: Rework decode_chunk_ts()
This function could have never returned correct data. Rework the decoding
logic according to the Sigma documentation. This patch also fixes the
handling of partial DRAM lines and partial DRAM clusters.
While at it, do not allocate megabytes of data on stack, just allocate 2KiB
which is plenty for all the work this function needs to do.
Marek Vasut [Sun, 20 Apr 2014 20:58:34 +0000 (22:58 +0200)]
asix-sigma: Suspend support for trailing DRAM lines
The support for trailing DRAM lines was broken. This patch starts
rework of support for this, but in order to do that, we need to
rework decode_chunk_ts() a little first.
This patch adjusts the decode_chunk_ts() a little to receive the
total amount of events in DRAM line instead of some nonsense value.
This patch temporarily removes the support for the trailing DRAM
lines until the decode_chunk_ts() is fixed to cope with this, so
yes, this patch introduces breakage!
Marek Vasut [Sun, 20 Apr 2014 20:40:38 +0000 (22:40 +0200)]
asix-sigma: Use proper structure for DRAM lines
Use proper structure instead of plain buffer of uint8_t for the contents
of DRAM in download_capture(). This is beneficial as we can interpret the
contents easily.
Marek Vasut [Sun, 20 Apr 2014 20:28:33 +0000 (22:28 +0200)]
asix-sigma: Unify calling of decode_chunk_ts()
Clean up the way decode_chunk_ts() is called a little. Introduce a variable
which will not be -1 only in case a trigger happened on the particular DRAM
line.
Marek Vasut [Sun, 20 Apr 2014 20:19:11 +0000 (22:19 +0200)]
asix-sigma: Rework download_capture() to support more than 32 lines
In the current configuration, the download capture used 32KiB buffer
for samples. This was the upper limit this function could download
from the Sigma. Even the sigma_read_dram() was only called once to
read up-to 32 DRAM line from address 0x0 in the DRAM.
This patch reworks the function to call sigma_read_dram() in a loop
in case there is need to download more than 32 DRAM lines of data
from Sigma. The data are then correctly passed for decoding to the
decoding function.
Marek Vasut [Sun, 20 Apr 2014 19:34:36 +0000 (21:34 +0200)]
asix-sigma: Remove stack-based alloc in download_capture()
Avoid allocating 32KiB of data on stack in download_capture(). Instead,
do a glib-variant of calloc(1, ) to allocate the data for the samples
which will be downloaded. This avoids explosions of stack on systems
with tight stack limits.
Furthermore, define structures describing the organisation of Sigma's
DRAM memory and start using those instead of ad-hoc preprocessor macros
defining the sizes of various structures in memory.
Marek Vasut [Sun, 20 Apr 2014 18:50:10 +0000 (20:50 +0200)]
asix-sigma: Localize variables
The trigger position, stop position and chunk in which the trigger happened
are no longer needed in the global scope. Make those variables local to the
download_capture() function.
Marek Vasut [Sun, 20 Apr 2014 18:45:40 +0000 (20:45 +0200)]
asix-sigma: Move all register I/O into download_capture()
Move all the register I/O that is necessary to do the download of samples
from Sigma into download_capture() function. This makes the downloading
code contained a bit more again.
Marek Vasut [Sun, 20 Apr 2014 18:40:00 +0000 (20:40 +0200)]
asix-sigma: Clearly separate the sample download
Reorder the sigma_capture_mode() function so that the part which handles
the download of samples from Sigma is clearly separated from the tests if
the download should be started.
Marek Vasut [Sun, 20 Apr 2014 18:30:16 +0000 (20:30 +0200)]
asix-sigma: Pull out the CAPTURE mode handler
Pull out the code handling the Sigma which is in CAPTURE mode into
a separate function. This is so we can start reworking this entire
code easily soon.
Marek Vasut [Sun, 20 Apr 2014 17:57:02 +0000 (19:57 +0200)]
asix-sigma: Read position only in CAPTURE state
Check the position of ForceStop and Trigger events only in case we
are in CAPTURE state, it's useless to do this unconditionally when
receive_data() is called.
Marek Vasut [Sun, 20 Apr 2014 17:36:40 +0000 (19:36 +0200)]
asix-sigma: Pull out the logic-mode switching
Pull out the code which switches Sigma from the FPGA programming mode
into Logic-Analyzer mode into separate function. Also, given the reply
is only ever 3-byte long, do not allocate 32 byte big buffer, but only
a 3-byte long one.
Marek Vasut [Sun, 20 Apr 2014 17:19:33 +0000 (19:19 +0200)]
asix-sigma: Cleanup the bit2bitbang
Rework the bit2bitbang function. Remarkable changes are:
- The function was renamed to sigma_fw_2_bitbang()
- We use glib function calls to work with the file
- We mmap the file containing firmware instead of opening the file
and then reading it into a buffer.
- The magic firmware transformation is now type-safe.
- Documentation and comments were added where applicable.
Marek Vasut [Sun, 20 Apr 2014 15:58:35 +0000 (17:58 +0200)]
asix-sigma: Weed out in-condition assignments
Remove all those if ((ret = foo(bar)) < 0) constructs from upload_firmware()
function. This is just a confusing programming practice, kill it. While at it,
replace all the uses of &devc->ftdic with plain ftdic , which is defined at
the begining.
Marek Vasut [Sun, 20 Apr 2014 15:49:29 +0000 (17:49 +0200)]
asix-sigma: Fix firmware path construction
The code silently assumed the firmware path can be no longer than 128 bytes.
This doesn't scale. This patch fixes it in such a way that it completely
rips out the run-time computation of firmware path and instead replaces it
with compile-time computation. It's true this makes the library grow by a
couple bytes, but makes the code cleaner.
Marek Vasut [Sun, 20 Apr 2014 15:18:31 +0000 (17:18 +0200)]
asix-sigma: Cleanup FPGA initialization
Rework the pre-firmware-upload FPGA initialization sequence so it matches
the documentation. Also, since this sequence is documented in a separate
section, wrap it into separate function.
Marek Vasut [Sun, 20 Apr 2014 15:02:05 +0000 (17:02 +0200)]
asix-sigma: Remove NUM_CHANNELS macro
The NUM_CHANNELS macro is inflexible, since in 100MHz and 200MHz modes
we don't support 16 channels. Moreover, it's only used to limit the size
of array of channel labels, which can be done in much cleaner way.
Uwe Hermann [Fri, 25 Apr 2014 16:40:59 +0000 (18:40 +0200)]
Don't include LOG_PREFIX in the Doxygen output.
(files in hardware/, input/, and output/ don't need this since none of
those directories contain API stuff and are thus not included in the
list of input files for Doxygen at all).