SR_PRIV int scanaplus_get_device_id(struct dev_context *devc) { int ret; uint16_t val1, val2; /* FTDI EEPROM indices 16+17 contain the 3 device ID bytes. */ if ((ret = ftdi_read_eeprom_location(devc->ftdic, 16, &val1)) < 0) { sr_err("Failed to read EEPROM index 16 (%d): %s.", ret, ftdi_get_error_string(devc->ftdic)); return SR_ERR; } if ((ret = ftdi_read_eeprom_location(devc->ftdic, 17, &val2)) < 0) { sr_err("Failed to read EEPROM index 17 (%d): %s.", ret, ftdi_get_error_string(devc->ftdic)); return SR_ERR; } /* * Note: Bit 7 of the three bytes must not be used, apparently. * * Even though the three bits can be either 0 or 1 (we've seen both * in actual ScanaPLUS devices), the device ID as sent to the FPGA * has bit 7 of each byte zero'd out. * * It is unknown whether bit 7 of these bytes has any meaning, * whether it's used somewhere, or whether it can be simply ignored. */ devc->devid[0] = ((val1 >> 0) & 0xff) & ~(1 << 7); devc->devid[1] = ((val1 >> 8) & 0xff) & ~(1 << 7); devc->devid[2] = ((val2 >> 0) & 0xff) & ~(1 << 7); return SR_OK; }
int Eeprom::read_location(int eeprom_addr, unsigned short *eeprom_val) { return ftdi_read_eeprom_location(d->context, eeprom_addr, eeprom_val); }