Add support for half-duplex SPI to CPy#5990
Conversation
tannewt
left a comment
There was a problem hiding this comment.
I think it'd be good to add an explicit way to setup half duplex and document it in the matching portion of shared-bindings. I think it's best to provide an explicit half duplex bool. I'm worried that the majority of folks do want read to mean read from MISO and removing the exception will make it less clear what their coding error is.
It crossed my mind to make mosi == miso mean half duplex but I suspect that'd be a common copy and paste bug.
|
I did think about that... instead of using if MISO and MOSI are defined, just let the user specify SPI_DIRECTION_2LINES_RXONLY, SPI_DIRECTION_2LINES, or SPI_DIRECTION_1LINE via a parameter when calling spi configure like: Would something like that be possible? There are 3 modes, full-duplex (normal 4-wire SPI), half-duplex (3-wire SPI with bidirectional data), and simplex (3-wire SPI with unidirectional data, RX only). Cpy was already set up to auto set SPI_DIRECTION_2LINES/full-duplex and SPI_DIRECTION_2LINES_RXONLY/simplex based on MISO/MOSO being defined. I don't think we can use a boolean, since there are 3 modes, not 2. |
|
I looked at that but only saw ways to pass bools and uints through the configure parameters, didn't see a way to pass strings. |
|
Now I'm realizing if we change the spi configure parameters, that touches all of the different ports, not just stm... hmm. |
Right, we need to change the I think a |
dhalbert
left a comment
There was a problem hiding this comment.
Thanks! Minor style request.
|
I'm guessing the too little flash failures are because I added |
|
Don't worry about these "too little flash" errors. I will push some commits that squeeze the builds that are overflowing. An unlabeled "NotImplementedError" is confusing. This happens all the time when we add functionality to tiny builds. |
dhalbert
left a comment
There was a problem hiding this comment.
Thanks for your perseverance on this!
I have a need for half-duplex SPI on a custom board. I thought it would be worth adding to CircuitPython too. I have tested this on the hardware and it is working.