Skip to content

[Discussion] Read and Ignore traits for blocking SPI operations #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
austinglaser opened this issue Mar 2, 2018 · 2 comments
Closed

Comments

@austinglaser
Copy link
Contributor

austinglaser commented Mar 2, 2018

Currently, there are the blocking::spi::Transfer and blocking::spi::Write traits. However, there times when one might want to read data out of a slave, without caring about what gets transmitted -- a blocking::spi::Read

This could be done with the blocking::spi::Transfer trait, but a separate trait provides two advantages:

  • No need to allocate a dummy buffer to pass in as words
  • An implementer of blocking::spi::Read could allow the MOSI pin to be optional

Going even further, there are times when a driver simply requires some clock cycles on the bus -- but will not be shifting meaningful data either in or out. This may seem like a corner case, but I've encountered this exact situation when configuring an ice40 FPGA. For reference, see page 19 of the programming and configuration manual. It's also a requirement for some commodity SPI flash devices.

This could be served by a blocking::spi::Ignore trait, which just takes a number of bytes to ignore.

@ryankurte
Copy link
Contributor

If the chip select component was split out / explicit this would also allow the combination of write and read operations in a single transaction (ie. assert chip select, write command + address, read values, de-assert chip select), which I think is an elegant approach to resolving some difficulty allocating statically sized arrays for operations with two components (setup+write, setup+read).

@ryankurte
Copy link
Contributor

This was discussed in #178 (comment) (note that this was closed in favour of #191 with only the SPI component), with the conclusion that Ignore is equivalent to Write and Read is equivalent to Transfer with a zeroed array which is preferable as it matches the physical implementation on the device.

Unless there is something else outstanding I believe that resolves this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants