From: Russ Dill Date: Wed, 1 Jan 2014 00:25:51 +0000 (-0800) Subject: zeroplus: Modify analyzer_read_start to just prep for bulk reads. X-Git-Tag: libsigrok-0.3.0~343 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=aad031928e5457ea8f7e4452401d55dcb8cb4cf1;p=libsigrok.git zeroplus: Modify analyzer_read_start to just prep for bulk reads. Let the capture loop manage which samples are thrown out rather than throwing out two here. Signed-off-by: Russ Dill --- diff --git a/hardware/zeroplus-logic-cube/analyzer.c b/hardware/zeroplus-logic-cube/analyzer.c index e9780d2d..1bf1f65b 100644 --- a/hardware/zeroplus-logic-cube/analyzer.c +++ b/hardware/zeroplus-logic-cube/analyzer.c @@ -411,12 +411,10 @@ SR_PRIV void analyzer_wait(libusb_device_handle *devh, int set, int unset) SR_PRIV void analyzer_read_start(libusb_device_handle *devh) { - int i; - analyzer_write_status(devh, 3, STATUS_FLAG_20 | STATUS_FLAG_READ); - for (i = 0; i < 8; i++) - (void)gl_reg_read(devh, READ_RAM_STATUS); + /* Prep for bulk reads */ + gl_reg_read_buf(devh, READ_RAM_STATUS, NULL, 0); } SR_PRIV int analyzer_read_data(libusb_device_handle *devh, void *buffer, diff --git a/hardware/zeroplus-logic-cube/gl_usb.c b/hardware/zeroplus-logic-cube/gl_usb.c index 0bffd43a..20993286 100644 --- a/hardware/zeroplus-logic-cube/gl_usb.c +++ b/hardware/zeroplus-logic-cube/gl_usb.c @@ -132,3 +132,21 @@ SR_PRIV int gl_reg_read(libusb_device_handle *devh, unsigned int reg) ret = gl_read_data(devh); return ret; } + +SR_PRIV int gl_reg_read_buf(libusb_device_handle *devh, unsigned int reg, + unsigned char *buf, unsigned int len) +{ + int ret; + unsigned int i; + + ret = gl_write_address(devh, reg); + if (ret < 0) + return ret; + for (i = 0; i < len; i++) { + ret = gl_read_data(devh); + if (ret < 0) + return ret; + buf[i] = ret; + } + return 0; +} diff --git a/hardware/zeroplus-logic-cube/gl_usb.h b/hardware/zeroplus-logic-cube/gl_usb.h index ac588fb5..c3a33fb3 100644 --- a/hardware/zeroplus-logic-cube/gl_usb.h +++ b/hardware/zeroplus-logic-cube/gl_usb.h @@ -40,5 +40,6 @@ SR_PRIV int gl_read_bulk(libusb_device_handle *devh, void *buffer, SR_PRIV int gl_reg_write(libusb_device_handle *devh, unsigned int reg, unsigned int val); SR_PRIV int gl_reg_read(libusb_device_handle *devh, unsigned int reg); - +SR_PRIV int gl_reg_read_buf(libusb_device_handle *devh, unsigned int reg, + unsigned char *buf, unsigned int len); #endif