From: Daniel Elstner Date: Tue, 22 Dec 2015 22:42:36 +0000 (+0100) Subject: sysclk-lwla: Use static array for LWLA1034 init sequence X-Git-Tag: libsigrok-0.4.0~62 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1d80e1c64140bb74857042751c460962b445cb35;p=libsigrok.git sysclk-lwla: Use static array for LWLA1034 init sequence Just as in the LWLA1016 initialization, make use of a static array for the constant part of the LWLA1034 capture setup sequence. --- diff --git a/src/hardware/sysclk-lwla/lwla1034.c b/src/hardware/sysclk-lwla/lwla1034.c index d64641ea..d29a9df2 100644 --- a/src/hardware/sysclk-lwla/lwla1034.c +++ b/src/hardware/sysclk-lwla/lwla1034.c @@ -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;