X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fasix-sigma%2Fasix-sigma.c;h=59acdcb1dcaa657d8822c0db5e91eb4a1e649777;hb=46641facd4ad8de4a93910d7089c7b289b412443;hp=d2543a4db91c6240280f188efd44249d91617bcd;hpb=3513d965699c663c329955f1a96f79fce73dcc6e;p=libsigrok.git diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index d2543a4d..59acdcb1 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -947,10 +947,12 @@ static uint16_t sigma_dram_cluster_ts(struct sigma_dram_cluster *cluster) * For 50 MHz and below, events contain one sample for each channel, * spread 20 ns apart. */ -static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts, +static int decode_chunk_ts(struct sigma_dram_line *dram_line, uint16_t *lastts, uint16_t *lastsample, int triggerpos, - uint16_t limit_chunk, void *cb_data) + uint16_t events_in_line, void *cb_data) { + uint8_t *buf = (uint8_t *)dram_line; + struct sigma_dram_cluster *dram_cluster; struct sr_dev_inst *sdi = cb_data; struct dev_context *devc = sdi->priv; uint16_t tsdiff, ts; @@ -977,15 +979,12 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts, } /* For each ts. */ - for (i = 0; i < 64; ++i) { - ts = *(uint16_t *) &buf[i * 16]; + for (i = 0; i < (events_in_line / 7); i++) { + dram_cluster = &dram_line->cluster[i]; + ts = sigma_dram_cluster_ts(dram_cluster); tsdiff = ts - *lastts; *lastts = ts; - /* Decode partial chunk. */ - if (limit_chunk && ts > limit_chunk) - return SR_OK; - /* Pad last sample up to current point. */ numpad = tsdiff * devc->samples_per_event - clustersize; if (numpad > 0) { @@ -1083,7 +1082,6 @@ static int download_capture(struct sr_dev_inst *sdi) struct dev_context *devc = sdi->priv; const int chunks_per_read = 32; struct sigma_dram_line *dram_line; - unsigned char *buf; int bufsz; uint32_t stoppos, triggerpos; struct sr_datafeed_packet packet; @@ -1091,15 +1089,13 @@ static int download_capture(struct sr_dev_inst *sdi) uint32_t i; uint32_t dl_lines_total, dl_lines_curr, dl_lines_done; - uint32_t dl_trailing_events; + uint32_t dl_events_in_line = 64 * 7; uint32_t trg_line = ~0; dram_line = g_try_malloc0(chunks_per_read * sizeof(*dram_line)); if (!dram_line) return FALSE; - buf = (unsigned char *)dram_line; - sr_info("Downloading sample data."); /* Stop acquisition. */ @@ -1122,7 +1118,6 @@ static int download_capture(struct sr_dev_inst *sdi) * line can be only partial, containing less than 64 clusters. */ dl_lines_total = (stoppos >> 9) + 1; - dl_trailing_events = stoppos & 0x1ff; dl_lines_done = 0; @@ -1130,7 +1125,8 @@ static int download_capture(struct sr_dev_inst *sdi) /* We can download only up-to 32 DRAM lines in one go! */ dl_lines_curr = MIN(chunks_per_read, dl_lines_total); - bufsz = sigma_read_dram(dl_lines_done, dl_lines_curr, buf, devc); + bufsz = sigma_read_dram(dl_lines_done, dl_lines_curr, + (uint8_t *)dram_line, devc); /* TODO: Check bufsz. For now, just avoid compiler warnings. */ (void)bufsz; @@ -1142,20 +1138,20 @@ static int download_capture(struct sr_dev_inst *sdi) } for (i = 0; i < dl_lines_curr; i++) { - uint32_t dl_limit = 0; int trigger_line = -1; /* The last "DRAM line" can be only partially full. */ if (dl_lines_done + i == dl_lines_total - 1) - dl_limit = dl_trailing_events; + dl_events_in_line = stoppos & 0x1ff; /* Test if the trigger happened on this line. */ if (dl_lines_done + i == trg_line) trigger_line = trg_line; - decode_chunk_ts(buf + (i * CHUNK_SIZE), + decode_chunk_ts(dram_line + i, &devc->state.lastts, &devc->state.lastsample, - trigger_line, dl_limit, sdi); + trigger_line, + dl_events_in_line, sdi); } dl_lines_done += dl_lines_curr;