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.

Signed-off-by: Marek Vasut <marex@denx.de>
This commit is contained in:
Marek Vasut 2014-04-20 20:40:00 +02:00 committed by Bert Vermeulen
parent d405193074
commit 00c8650877
1 changed files with 14 additions and 11 deletions

View File

@ -1134,23 +1134,26 @@ static int sigma_capture_mode(struct sr_dev_inst *sdi)
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
uint64_t running_msec; uint64_t running_msec;
struct timeval tv; struct timeval tv;
int numchunks;
uint8_t modestatus; uint8_t modestatus;
/* Get the current position. */ uint32_t stoppos, triggerpos;
sigma_read_pos(&devc->state.stoppos, &devc->state.triggerpos,
devc);
numchunks = (devc->state.stoppos + 511) / 512; /* Check if the selected sampling duration passed. */
/* Check if the timer has expired, or memory is full. */
gettimeofday(&tv, 0); gettimeofday(&tv, 0);
running_msec = (tv.tv_sec - devc->start_tv.tv_sec) * 1000 + running_msec = (tv.tv_sec - devc->start_tv.tv_sec) * 1000 +
(tv.tv_usec - devc->start_tv.tv_usec) / 1000; (tv.tv_usec - devc->start_tv.tv_usec) / 1000;
if (running_msec >= devc->limit_msec)
goto download;
if (running_msec < devc->limit_msec && numchunks < 32767) /* Get the position in DRAM to which the FPGA is writing now. */
/* Still capturing. */ sigma_read_pos(&stoppos, &triggerpos, devc);
return TRUE; /* Test if DRAM is full and if so, download the data. */
if ((stoppos >> 9) == 32767)
goto download;
return TRUE;
download:
/* Stop acquisition. */ /* Stop acquisition. */
sigma_set_register(WRITE_MODE, 0x11, devc); sigma_set_register(WRITE_MODE, 0x11, devc);