]> sigrok.org Git - libsigrok.git/commitdiff
sysclk-lwla: Fix calculation of the running sample count.
authorDaniel Elstner <redacted>
Tue, 14 Jan 2014 00:28:00 +0000 (01:28 +0100)
committerUwe Hermann <redacted>
Tue, 14 Jan 2014 18:33:31 +0000 (19:33 +0100)
Field 7 of the status response is actually a duration in
milliseconds at all samplerates but 125 MHz.

hardware/sysclk-lwla/protocol.c

index 5b3dd6fc504dd3281e177242a5a46b27efcae355..3618eb11030745e51da0035a8ce298e25549f9a2 100644 (file)
@@ -341,6 +341,8 @@ static void issue_stop_capture(const struct sr_dev_inst *sdi)
  */
 static void process_capture_status(const struct sr_dev_inst *sdi)
 {
+       uint64_t duration;
+       uint64_t timescale;
        struct dev_context *devc;
        struct acquisition_state *acq;
 
@@ -358,12 +360,17 @@ static void process_capture_status(const struct sr_dev_inst *sdi)
         * in the FPGA.  These fields are definitely less than 64 bit wide
         * internally, and the unused bits occasionally even contain garbage.
         */
-       acq->mem_addr_fill    = LWLA_READ32(&acq->xfer_buf_in[0]);
-       acq->captured_samples = LWLA_READ32(&acq->xfer_buf_in[8])
-                               * (uint64_t)100000;
-       acq->capture_flags    = LWLA_READ32(&acq->xfer_buf_in[16])
+       acq->mem_addr_fill = LWLA_READ32(&acq->xfer_buf_in[0]);
+       duration           = LWLA_READ32(&acq->xfer_buf_in[8]);
+       acq->capture_flags = LWLA_READ32(&acq->xfer_buf_in[16])
                                & STATUS_FLAG_MASK;
 
+       /* The 125 MHz setting is special, and uses the same timebase
+        * for the duration field as the 100 MHz setting.
+        */
+       timescale = MIN(devc->samplerate, SR_MHZ(100));
+       acq->captured_samples = (duration * timescale) / 1000;
+
        sr_spew("Captured %lu words, %" PRIu64 " samples, flags 0x%02X",
                (unsigned long)acq->mem_addr_fill,
                acq->captured_samples, acq->capture_flags);