Description
This library has suffered somewhat from function creep caused by useful features being added in conjunction with a fear of breaking the existing API.
I think it's worth reviewing what functionality an SPI library should constitute- taking into account #83 and the possibility of reading/writing bytearrays. But before we dive into what could be a time consuming nightmare it migh tbe worth reviewing the current functionality and attempting to whittle the codebase down to a maintainable core.
Right now as near as I can tell from code-review xfer and xfer2 are functionality identical unless the library is compiled with -DSPIDEV_SINGLE
. I'm unaware of how this library is packaged for RPi (I have asked who I believe to be the relevant individual) but this flag is not referenced or set anywhere in the packaging visible in this repository. The library is shipped on PyPi without this flag set. The lack of any functional difference between xfer and xfer2 was noticed in #35 and #25 and has remained unchanged since.
I don't believe there's any reason to have a first-class method that handles re-asserting chip-select between "blocks" (in this case, we mean bytes).
- Nobody has asked for it (xfer does not de-assert CS between bytes #35 notwithstanding)
- nobody has discovered or mentioned
-DSPIDEV_SINGLE
- anyone who desires this behaviour can simply invoke xfer byte-by-byte from Python (or ask for it)
I propose we quietly roll xfer
and xfer2
into a single function and drop the -DSPIDEV_SINGLE
code path altogether. Along with dropping some of the Python version checks this constitutes a significant reduction in code that needs maintained and testing in future.
Right now there are also inexplicable minor differences (allowing/disallowing threads) between xfer and xfer2 that should be ironed out, so this would be a good opportunity to reconcile those.