dslogic: Add #defines for timeouts and delays.
This commit is contained in:
parent
eac0c61327
commit
4df5739a9f
|
@ -30,6 +30,10 @@
|
||||||
|
|
||||||
#define FW_BUFSIZE (4 * 1024)
|
#define FW_BUFSIZE (4 * 1024)
|
||||||
|
|
||||||
|
#define FPGA_UPLOAD_DELAY (10 * 1000)
|
||||||
|
|
||||||
|
#define USB_TIMEOUT (3 * 1000)
|
||||||
|
|
||||||
int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
|
int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
|
||||||
const char *filename)
|
const char *filename)
|
||||||
{
|
{
|
||||||
|
@ -51,7 +55,7 @@ int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
|
||||||
/* Tell the device firmware is coming. */
|
/* Tell the device firmware is coming. */
|
||||||
if ((ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
|
if ((ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
|
||||||
LIBUSB_ENDPOINT_OUT, DS_CMD_FPGA_FW, 0x0000, 0x0000,
|
LIBUSB_ENDPOINT_OUT, DS_CMD_FPGA_FW, 0x0000, 0x0000,
|
||||||
NULL, 0, 3000)) < 0) {
|
NULL, 0, USB_TIMEOUT)) < 0) {
|
||||||
sr_err("Failed to upload FPGA firmware: %s.", libusb_error_name(ret));
|
sr_err("Failed to upload FPGA firmware: %s.", libusb_error_name(ret));
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +67,7 @@ int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Give the FX2 time to get ready for FPGA firmware upload. */
|
/* Give the FX2 time to get ready for FPGA firmware upload. */
|
||||||
g_usleep(10 * 1000);
|
g_usleep(FPGA_UPLOAD_DELAY);
|
||||||
|
|
||||||
sum = 0;
|
sum = 0;
|
||||||
result = SR_OK;
|
result = SR_OK;
|
||||||
|
@ -72,7 +76,7 @@ int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ((ret = libusb_bulk_transfer(usb->devhdl, 2 | LIBUSB_ENDPOINT_OUT,
|
if ((ret = libusb_bulk_transfer(usb->devhdl, 2 | LIBUSB_ENDPOINT_OUT,
|
||||||
buf, chunksize, &transferred, 1000)) < 0) {
|
buf, chunksize, &transferred, USB_TIMEOUT)) < 0) {
|
||||||
sr_err("Unable to configure FPGA firmware: %s.",
|
sr_err("Unable to configure FPGA firmware: %s.",
|
||||||
libusb_error_name(ret));
|
libusb_error_name(ret));
|
||||||
result = SR_ERR;
|
result = SR_ERR;
|
||||||
|
@ -111,7 +115,7 @@ int dslogic_start_acquisition(const struct sr_dev_inst *sdi)
|
||||||
usb = sdi->conn;
|
usb = sdi->conn;
|
||||||
ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
|
ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
|
||||||
LIBUSB_ENDPOINT_OUT, DS_CMD_START, 0x0000, 0x0000,
|
LIBUSB_ENDPOINT_OUT, DS_CMD_START, 0x0000, 0x0000,
|
||||||
(unsigned char *)&mode, sizeof(mode), 3000);
|
(unsigned char *)&mode, sizeof(mode), USB_TIMEOUT);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
sr_err("Failed to send start command: %s.", libusb_error_name(ret));
|
sr_err("Failed to send start command: %s.", libusb_error_name(ret));
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
@ -132,7 +136,7 @@ int dslogic_stop_acquisition(const struct sr_dev_inst *sdi)
|
||||||
usb = sdi->conn;
|
usb = sdi->conn;
|
||||||
ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
|
ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
|
||||||
LIBUSB_ENDPOINT_OUT, DS_CMD_START, 0x0000, 0x0000,
|
LIBUSB_ENDPOINT_OUT, DS_CMD_START, 0x0000, 0x0000,
|
||||||
(unsigned char *)&mode, sizeof(struct dslogic_mode), 3000);
|
(unsigned char *)&mode, sizeof(struct dslogic_mode), USB_TIMEOUT);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
sr_err("Failed to send stop command: %s.", libusb_error_name(ret));
|
sr_err("Failed to send stop command: %s.", libusb_error_name(ret));
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
@ -183,7 +187,7 @@ int dslogic_fpga_configure(const struct sr_dev_inst *sdi)
|
||||||
|
|
||||||
ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
|
ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
|
||||||
LIBUSB_ENDPOINT_OUT, DS_CMD_CONFIG, 0x0000, 0x0000,
|
LIBUSB_ENDPOINT_OUT, DS_CMD_CONFIG, 0x0000, 0x0000,
|
||||||
c, 3, 100);
|
c, 3, USB_TIMEOUT);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
sr_err("Failed to send FPGA configure command: %s.", libusb_error_name(ret));
|
sr_err("Failed to send FPGA configure command: %s.", libusb_error_name(ret));
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
@ -219,8 +223,7 @@ int dslogic_fpga_configure(const struct sr_dev_inst *sdi)
|
||||||
|
|
||||||
len = sizeof(struct dslogic_fpga_config);
|
len = sizeof(struct dslogic_fpga_config);
|
||||||
ret = libusb_bulk_transfer(usb->devhdl, 2 | LIBUSB_ENDPOINT_OUT,
|
ret = libusb_bulk_transfer(usb->devhdl, 2 | LIBUSB_ENDPOINT_OUT,
|
||||||
(unsigned char *)&cfg, len,
|
(unsigned char *)&cfg, len, &transferred, USB_TIMEOUT);
|
||||||
&transferred, 100);
|
|
||||||
if (ret < 0 || transferred != len) {
|
if (ret < 0 || transferred != len) {
|
||||||
sr_err("Failed to send FPGA configuration: %s.", libusb_error_name(ret));
|
sr_err("Failed to send FPGA configuration: %s.", libusb_error_name(ret));
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
|
@ -38,6 +38,8 @@ struct cmd_start_acquisition {
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
#define USB_TIMEOUT 100
|
||||||
|
|
||||||
static int command_get_fw_version(libusb_device_handle *devhdl,
|
static int command_get_fw_version(libusb_device_handle *devhdl,
|
||||||
struct version_info *vi)
|
struct version_info *vi)
|
||||||
{
|
{
|
||||||
|
@ -45,7 +47,7 @@ static int command_get_fw_version(libusb_device_handle *devhdl,
|
||||||
|
|
||||||
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
|
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
|
||||||
LIBUSB_ENDPOINT_IN, CMD_GET_FW_VERSION, 0x0000, 0x0000,
|
LIBUSB_ENDPOINT_IN, CMD_GET_FW_VERSION, 0x0000, 0x0000,
|
||||||
(unsigned char *)vi, sizeof(struct version_info), 100);
|
(unsigned char *)vi, sizeof(struct version_info), USB_TIMEOUT);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
sr_err("Unable to get version info: %s.",
|
sr_err("Unable to get version info: %s.",
|
||||||
|
@ -65,7 +67,7 @@ static int command_get_revid_version(struct sr_dev_inst *sdi, uint8_t *revid)
|
||||||
|
|
||||||
cmd = devc->dslogic ? DS_CMD_GET_REVID_VERSION : CMD_GET_REVID_VERSION;
|
cmd = devc->dslogic ? DS_CMD_GET_REVID_VERSION : CMD_GET_REVID_VERSION;
|
||||||
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
|
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
|
||||||
LIBUSB_ENDPOINT_IN, cmd, 0x0000, 0x0000, revid, 1, 100);
|
LIBUSB_ENDPOINT_IN, cmd, 0x0000, 0x0000, revid, 1, USB_TIMEOUT);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
sr_err("Unable to get REVID: %s.", libusb_error_name(ret));
|
sr_err("Unable to get REVID: %s.", libusb_error_name(ret));
|
||||||
|
@ -126,7 +128,7 @@ SR_PRIV int fx2lafw_command_start_acquisition(const struct sr_dev_inst *sdi)
|
||||||
/* Send the control message. */
|
/* Send the control message. */
|
||||||
ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
|
ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
|
||||||
LIBUSB_ENDPOINT_OUT, CMD_START, 0x0000, 0x0000,
|
LIBUSB_ENDPOINT_OUT, CMD_START, 0x0000, 0x0000,
|
||||||
(unsigned char *)&cmd, sizeof(cmd), 100);
|
(unsigned char *)&cmd, sizeof(cmd), USB_TIMEOUT);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
sr_err("Unable to send start command: %s.",
|
sr_err("Unable to send start command: %s.",
|
||||||
libusb_error_name(ret));
|
libusb_error_name(ret));
|
||||||
|
|
Loading…
Reference in New Issue