]> sigrok.org Git - libsigrok.git/blobdiff - hardware/fx2lafw/fx2lafw.c
fx2lafw: Added support for default Cypess FX2 without EEPROM
[libsigrok.git] / hardware / fx2lafw / fx2lafw.c
index 42d994d953ac55764e3782996797edee932a5201..01c460f7dc647cc43f25907502987745e02004e5 100644 (file)
@@ -50,6 +50,12 @@ static const struct fx2lafw_profile supported_fx2[] = {
        { 0x0925, 0x3881, "Saleae", "Logic", NULL,
                FIRMWARE_DIR "/fx2lafw-saleae-logic.fw", 8 },
 
+       /*
+        * Default Cypress FX2 without EEPROM
+        */
+       { 0x04B4, 0x8613, "Cypress", "FX2", NULL,
+               FIRMWARE_DIR "/fx2lafw-cypress-fx2.fw", 8 },
+
        { 0, 0, 0, 0, 0, 0, 0 }
 };
 
@@ -79,6 +85,9 @@ static const char *probe_names[] = {
 };
 
 static uint64_t supported_samplerates[] = {
+       SR_KHZ(200),
+       SR_KHZ(250),
+       SR_KHZ(500),
        SR_MHZ(1),
        SR_MHZ(2),
        SR_MHZ(3),
@@ -164,6 +173,7 @@ static int fx2lafw_dev_open(int dev_index)
        struct libusb_device_descriptor des;
        struct sr_dev_inst *sdi;
        struct context *ctx;
+       struct version_info vi;
        int ret, skip, i;
 
        if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
@@ -217,16 +227,32 @@ static int fx2lafw_dev_open(int dev_index)
                                 * so we don't know the address yet.
                                 */
                                ctx->usb->address = libusb_get_device_address(devlist[i]);
-
-                       sdi->status = SR_ST_ACTIVE;
-                       sr_info("fx2lafw: Opened device %d on %d.%d "
-                               "interface %d.", sdi->index, ctx->usb->bus,
-                               ctx->usb->address, USB_INTERFACE);
                } else {
                        sr_err("fx2lafw: Failed to open device: %d.", ret);
+                       break;
+               }
+
+               ret = command_get_fw_version(ctx->usb->devhdl, &vi);
+               if (ret != SR_OK) {
+                       sr_err("fx2lafw: Failed to retrieve "
+                              "firmware version information.");
+                       break;
+               }
+
+               if (vi.major != FX2LAFW_VERSION_MAJOR ||
+                   vi.minor != FX2LAFW_VERSION_MINOR) {
+                       sr_err("fx2lafw: Expected firmware version %d.%02d "
+                              "got %d.%02d.", FX2LAFW_VERSION_MAJOR,
+                              FX2LAFW_VERSION_MINOR, vi.major, vi.minor);
+                       break;
                }
 
-               /* if we made it here, we handled the device one way or another */
+               sdi->status = SR_ST_ACTIVE;
+               sr_info("fx2lafw: Opened device %d on %d.%d "
+                       "interface %d, firmware version %d.%02d",
+                       sdi->index, ctx->usb->bus, ctx->usb->address,
+                       USB_INTERFACE, vi.major, vi.minor);
+
                break;
        }
        libusb_free_device_list(devlist, 1);
@@ -405,8 +431,8 @@ static int hw_dev_open(int dev_index)
        ctx = sdi->priv;
 
        /*
-        * if the firmware was recently uploaded, wait up to MAX_RENUM_DELAY ms
-        * for the FX2 to renumerate
+        * If the firmware was recently uploaded, wait up to MAX_RENUM_DELAY ms
+        * for the FX2 to renumerate.
         */
        ret = 0;
        if (GTV_TO_MSEC(ctx->fw_updated) > 0) {