* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <glib.h>
+#include <glib/gstdio.h>
#include "protocol.h"
-
-/* Protocol commands */
-#define CMD_GET_FW_VERSION 0xb0
-#define CMD_START 0xb1
-#define CMD_GET_REVID_VERSION 0xb2
-
-#define CMD_START_FLAGS_WIDE_POS 5
-#define CMD_START_FLAGS_CLK_SRC_POS 6
-
-#define CMD_START_FLAGS_SAMPLE_8BIT (0 << CMD_START_FLAGS_WIDE_POS)
-#define CMD_START_FLAGS_SAMPLE_16BIT (1 << CMD_START_FLAGS_WIDE_POS)
-
-#define CMD_START_FLAGS_CLK_30MHZ (0 << CMD_START_FLAGS_CLK_SRC_POS)
-#define CMD_START_FLAGS_CLK_48MHZ (1 << CMD_START_FLAGS_CLK_SRC_POS)
+#include "dslogic.h"
#pragma pack(push, 1)
static int command_get_revid_version(struct sr_dev_inst *sdi, uint8_t *revid)
{
+ struct dev_context *devc = sdi->priv;
struct sr_usb_dev_inst *usb = sdi->conn;
libusb_device_handle *devhdl = usb->devhdl;
- int ret;
+ int cmd, ret;
+ cmd = devc->dslogic ? DS_CMD_GET_REVID_VERSION : CMD_GET_REVID_VERSION;
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
- LIBUSB_ENDPOINT_IN, CMD_GET_REVID_VERSION, 0x0000, 0x0000,
- revid, 1, 100);
+ LIBUSB_ENDPOINT_IN, cmd, 0x0000, 0x0000, revid, 1, 100);
if (ret < 0) {
sr_err("Unable to get REVID: %s.", libusb_error_name(ret));
delay = SR_MHZ(30) / samplerate - 1;
}
- sr_info("GPIF delay = %d, clocksource = %sMHz.", delay,
+ sr_dbg("GPIF delay = %d, clocksource = %sMHz.", delay,
(cmd.flags & CMD_START_FLAGS_CLK_48MHZ) ? "48" : "30");
if (delay <= 0 || delay > MAX_SAMPLE_DELAY) {
/**
* Check the USB configuration to determine if this is an fx2lafw device.
*
- * @return TRUE if the device's configuration profile match fx2lafw
+ * @return TRUE if the device's configuration profile matches fx2lafw
* configuration, FALSE otherwise.
*/
-SR_PRIV gboolean fx2lafw_check_conf_profile(libusb_device *dev)
+SR_PRIV gboolean match_manuf_prod(libusb_device *dev, const char *manufacturer,
+ const char *product)
{
struct libusb_device_descriptor des;
struct libusb_device_handle *hdl;
break;
if (libusb_get_string_descriptor_ascii(hdl,
- des.iManufacturer, strdesc, sizeof(strdesc)) < 0)
+ des.iManufacturer, strdesc, sizeof(strdesc)) < 0)
break;
- if (strncmp((const char *)strdesc, "sigrok", 6))
+ if (strcmp((const char *)strdesc, manufacturer))
break;
if (libusb_get_string_descriptor_ascii(hdl,
des.iProduct, strdesc, sizeof(strdesc)) < 0)
break;
- if (strncmp((const char *)strdesc, "fx2lafw", 7))
+ if (strcmp((const char *)strdesc, product))
break;
- /* If we made it here, it must be an fx2lafw. */
ret = TRUE;
}
if (hdl)
return;
}
- sr_info("receive_transfer(): status %d received %d bytes.",
+ sr_dbg("receive_transfer(): status %d received %d bytes.",
transfer->status, transfer->actual_length);
/* Save incoming transfer before reusing the transfer struct. */