]> sigrok.org Git - libsigrok.git/commitdiff
sysclk-lwla: Use static array for LWLA1034 init sequence
authorDaniel Elstner <redacted>
Tue, 22 Dec 2015 22:42:36 +0000 (23:42 +0100)
committerDaniel Elstner <redacted>
Tue, 22 Dec 2015 22:42:36 +0000 (23:42 +0100)
Just as in the LWLA1016 initialization, make use of a static array
for the constant part of the LWLA1034 capture setup sequence.

src/hardware/sysclk-lwla/lwla1034.c

index d64641ea9d06b5106312da580a3fc3ca4d5fe293..d29a9df2ed869449d224df8a3b7c02b13f910b99 100644 (file)
@@ -377,6 +377,15 @@ static int device_init_check(const struct sr_dev_inst *sdi)
  */
 static int setup_acquisition(const struct sr_dev_inst *sdi)
 {
+       static const struct regval capture_init[] = {
+               {REG_MEM_CTRL,    MEM_CTRL_CLR_IDX},
+               {REG_MEM_CTRL,    MEM_CTRL_WRITE},
+               {REG_LONG_ADDR,   LREG_CAP_CTRL},
+               {REG_LONG_LOW,    CAP_CTRL_CLR_TIMEBASE | CAP_CTRL_FLUSH_FIFO |
+                                 CAP_CTRL_CLR_FIFOFULL | CAP_CTRL_CLR_COUNTER},
+               {REG_LONG_HIGH,   0},
+               {REG_LONG_STROBE, 0},
+       };
        uint64_t divider_count;
        uint64_t trigger_mask;
        struct dev_context *devc;
@@ -388,21 +397,11 @@ static int setup_acquisition(const struct sr_dev_inst *sdi)
        usb  = sdi->conn;
        acq  = devc->acquisition;
 
-       acq->reg_seq_pos = 0;
-       acq->reg_seq_len = 0;
-
-       lwla_queue_regval(acq, REG_MEM_CTRL, MEM_CTRL_CLR_IDX);
-       lwla_queue_regval(acq, REG_MEM_CTRL, MEM_CTRL_WRITE);
-
-       queue_long_regval(acq, LREG_CAP_CTRL,
-               CAP_CTRL_CLR_TIMEBASE | CAP_CTRL_FLUSH_FIFO |
-               CAP_CTRL_CLR_FIFOFULL | CAP_CTRL_CLR_COUNTER);
-
-       lwla_queue_regval(acq, REG_CLK_BOOST, acq->clock_boost);
-
-       ret = lwla_write_regs(usb, acq->reg_sequence, acq->reg_seq_len);
-       acq->reg_seq_len = 0;
+       ret = lwla_write_regs(usb, capture_init, ARRAY_SIZE(capture_init));
+       if (ret != SR_OK)
+               return ret;
 
+       ret = lwla_write_reg(usb, REG_CLK_BOOST, acq->clock_boost);
        if (ret != SR_OK)
                return ret;