Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Howdy,
I'd like to submit some changes to the SPI module. Long story short, I need to write 16-bit data to a TLV5614 and don't care about return data, as there is none. The default
FullDuplex
implementations had two issues: they only use 8-bits and they throw an error if theOVR
bit is set which happens when writing but not reading from the data register.The 8-bit-only problem was solved by creating a new
SpiDataSize
enum that is passed in when instantiating the SPI object.For the second problem, the first attempt was to add trait implementations for
FullDuplex<u16>
, but the logic would have differed fromFullDuplex<u8>
and that didn't seem right.The second attempt was to add
unchecked_send_u8
andunchecked_send_u16
functions to the defaultimpl SPI
. These are functions used write to the data register blindly, it is up to the user to check the status register. However, the data was not properly outputting on the SPI bus, which required theis_busy
function to check if the SPI bus is busy. This is used in the other two functions as a blocking check before writing to the data register.Attached is a picture from a Seleae logic analyzer showing data (12 words, 0x0001 through 0x000C) written to the SPI bus using a 20MHz SPI clock using the
unchecked_send_u16
function.