]> sigrok.org Git - libsigrok.git/blobdiff - hardware/sysclk-lwla/protocol.h
sysclk-lwla: Simplify and optimize word extraction.
[libsigrok.git] / hardware / sysclk-lwla / protocol.h
index d177836e196ac95d9f8b246c070da15c3ee95963..762a17b595c5d71fb4a67ceee9a1a350f899eec1 100644 (file)
 #define NUM_PROBES     34
 #define TRIGGER_TYPES  "01fr"
 
+/* Bit mask covering all 34 channels.
+ */
+#define ALL_CHANNELS_MASK (((uint64_t)1 << NUM_PROBES) - 1)
+
 /** 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 READ_CHUNK_LEN (28 * 8)
 
-/** Calculate the required buffer size in 16-bit units for reading a given
+/** Calculate the required buffer size in 32-bit units for reading a given
  * number of device memory words.  Rounded to a multiple of 8 device words.
  */
-#define LWLA1034_MEMBUF_LEN(count) (((count) + 7) / 8 * 18)
+#define LWLA1034_MEMBUF_LEN(count) (((count) + 7) / 8 * 9)
 
 /** Maximum number of 16-bit words sent at a time during acquisition.
  * Used for allocating the libusb transfer buffer.
  */
 #define MAX_ACQ_SEND_WORDS     8 /* 5 for memory read request plus stuffing */
 
-/** Maximum number of 16-bit words received at a time during acquisition.
+/** Maximum number of 32-bit words received at a time during acquisition.
  * Round to the next multiple of the endpoint buffer size to avoid nasty
  * transfer overflow conditions on hiccups.
  */
-#define MAX_ACQ_RECV_WORDS     ((READ_CHUNK_LEN / 4 * 9 + 255) / 256 * 256)
+#define MAX_ACQ_RECV_LEN       ((READ_CHUNK_LEN / 8 * 9 + 127) / 128 * 128)
 
 /** Maximum length of a register write sequence.
  */
@@ -158,7 +162,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;
@@ -170,12 +174,12 @@ struct acquisition_state {
        /** Whether to bypass the clock divider. */
        gboolean bypass_clockdiv;
 
-       /* Payload data buffers for outgoing and incoming transfers. */
+       /* Payload data buffers for incoming and outgoing transfers. */
+       uint32_t xfer_buf_in[MAX_ACQ_RECV_LEN];
        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.