#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,
const char *filename)
{
/* Tell the device firmware is coming. */
if ((ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
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));
return SR_ERR;
}
}
/* Give the FX2 time to get ready for FPGA firmware upload. */
- g_usleep(10 * 1000);
+ g_usleep(FPGA_UPLOAD_DELAY);
sum = 0;
result = SR_OK;
break;
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.",
libusb_error_name(ret));
result = SR_ERR;
usb = sdi->conn;
ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_OUT, DS_CMD_START, 0x0000, 0x0000,
- (unsigned char *)&mode, sizeof(mode), 3000);
+ (unsigned char *)&mode, sizeof(mode), USB_TIMEOUT);
if (ret < 0) {
sr_err("Failed to send start command: %s.", libusb_error_name(ret));
return SR_ERR;
usb = sdi->conn;
ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
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) {
sr_err("Failed to send stop command: %s.", libusb_error_name(ret));
return SR_ERR;
ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_OUT, DS_CMD_CONFIG, 0x0000, 0x0000,
- c, 3, 100);
+ c, 3, USB_TIMEOUT);
if (ret < 0) {
sr_err("Failed to send FPGA configure command: %s.", libusb_error_name(ret));
return SR_ERR;
len = sizeof(struct dslogic_fpga_config);
ret = libusb_bulk_transfer(usb->devhdl, 2 | LIBUSB_ENDPOINT_OUT,
- (unsigned char *)&cfg, len,
- &transferred, 100);
+ (unsigned char *)&cfg, len, &transferred, USB_TIMEOUT);
if (ret < 0 || transferred != len) {
sr_err("Failed to send FPGA configuration: %s.", libusb_error_name(ret));
return SR_ERR;
#pragma pack(pop)
+#define USB_TIMEOUT 100
+
static int command_get_fw_version(libusb_device_handle *devhdl,
struct version_info *vi)
{
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
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) {
sr_err("Unable to get version info: %s.",
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, 0x0000, 0x0000, revid, 1, 100);
+ LIBUSB_ENDPOINT_IN, cmd, 0x0000, 0x0000, revid, 1, USB_TIMEOUT);
if (ret < 0) {
sr_err("Unable to get REVID: %s.", libusb_error_name(ret));
/* Send the control message. */
ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_OUT, CMD_START, 0x0000, 0x0000,
- (unsigned char *)&cmd, sizeof(cmd), 100);
+ (unsigned char *)&cmd, sizeof(cmd), USB_TIMEOUT);
if (ret < 0) {
sr_err("Unable to send start command: %s.",
libusb_error_name(ret));