]> sigrok.org Git - libsigrok.git/blobdiff - hardware/sysclk-lwla/protocol.h
sysclk-lwla: Streamline packet output logic.
[libsigrok.git] / hardware / sysclk-lwla / protocol.h
index 21bfe72994629ce293328e28066f373dbd6d7d74..f8b64ac6515719d1ac9994b1b5c9cf1bb80e0062 100644 (file)
@@ -44,7 +44,7 @@
 /** Unit and packet size for the sigrok logic datafeed.
  */
 #define UNIT_SIZE      ((NUM_PROBES + 7) / 8)
-#define PACKET_SIZE    (10000 * UNIT_SIZE)     /* bytes */
+#define PACKET_LENGTH  10000   /* units */
 
 /** Size of the acquisition buffer in device memory units.
  */
  */
 #define DEFAULT_SAMPLERATE     SR_MHZ(125)
 
+/** Maximum configurable sample count limit.
+ */
+#define MAX_LIMIT_SAMPLES      (UINT64_C(1) << 48)
+
+/** Maximum configurable capture duration in milliseconds.
+ */
+#define MAX_LIMIT_MSEC         (UINT64_C(1) << 32)
+
 /** LWLA clock sources.
  */
 enum clock_source {
@@ -133,10 +141,15 @@ struct acquisition_state {
        uint64_t sample;
        uint64_t run_len;
 
-       /** Number of samples acquired so far. */
-       uint64_t captured_samples;
+       /** Maximum number of samples to process. */
+       uint64_t samples_max;
        /** Number of samples sent to the session bus. */
-       uint64_t transferred_samples;
+       uint64_t samples_done;
+
+       /** Maximum duration of capture, in milliseconds. */
+       uint64_t duration_max;
+       /** Running capture duration since trigger event. */
+       uint64_t duration_now;
 
        /** Capture memory fill level. */
        size_t mem_addr_fill;
@@ -145,7 +158,7 @@ struct acquisition_state {
        size_t mem_addr_next;
        size_t mem_addr_stop;
 
-       size_t out_offset;
+       size_t out_index;
 
        struct libusb_transfer *xfer_in;
        struct libusb_transfer *xfer_out;
@@ -154,12 +167,15 @@ struct acquisition_state {
 
        enum rle_state rle;
 
+       /** Whether to bypass the clock divider. */
+       gboolean bypass_clockdiv;
+
        /* Payload data buffers for outgoing and incoming transfers. */
        uint16_t xfer_buf_out[MAX_ACQ_SEND_WORDS];
        uint16_t xfer_buf_in[MAX_ACQ_RECV_WORDS];
 
        /* Payload buffer for sigrok logic packets. */
-       uint8_t out_packet[PACKET_SIZE];
+       uint8_t out_packet[PACKET_LENGTH * UNIT_SIZE];
 };
 
 /** Private, per-device-instance driver context.
@@ -168,6 +184,9 @@ struct dev_context {
        /** The samplerate selected by the user. */
        uint64_t samplerate;
 
+       /** The maximimum sampling duration, in milliseconds. */
+       uint64_t limit_msec;
+
        /** The maximimum number of samples to acquire. */
        uint64_t limit_samples;