eblot / pyspiflash

SPI data flash device drivers (pure Python)
MIT License
39 stars 30 forks source link

Support constructor that take an SPI object #1

Closed axel-h closed 4 years ago

axel-h commented 8 years ago

Please add a constructor that takes an "spi" object (ie an SPI Controller port) , so the calling application can take care of creating this and finding the proper FTDI device is kept out of scope. Currently I'm using this code to implement this:

def getFtdiSpiFlash(spi): jedec = pyspiflash.serialflash.SerialFlashManager.read_jedec_id(spi) if not jedec: raise AssertionError("Unable to read JEDEC ID") flash = pyspiflash.serialflash.SerialFlashManager._get_flash(spi, jedec)

However, It would be nice to keep the jedec part internal to pyspiflash again and drop this helper.

The background for this request is, that is improves usage in environment where multiple FTDI devices are used. In the bigger picture, certain USB ports are assigned to certain devices/boards/TestSockets..., so devices are selected by the "USB port-path". Any fallback to VID/PID/Serial works, but it suffers from practical problem like people borrowing and thus accidentally (ex)changing devices, as they all look the same....

eblot commented 8 years ago

Can you provide a patch (using a pull request)? It would be easier to understand your request. Be sure to write it against v0.4.0 as the code has been recently updated. Thanks.

eblot commented 4 years ago

Now available in v0.6.0