Skip to content
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

Use blocking spi traits #29

Merged

Conversation

eldruin
Copy link
Member

@eldruin eldruin commented Nov 19, 2020

  • Shift to using blocking SPI traits for peripheral sharing ease
  • Fix updating embedded-hal version to version 0.2.3 where the digital::v2 traits were actually added.
  • Update env_logger dependency
  • Add Changelog

Thanks to @Rahix and @Maldus512
Fixes #28

Copy link

@Rahix Rahix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me at least :)

@thejpster
Copy link
Member

I only looked at this quickly, but I had a question around the chip select. Is there a risk the card will be unselected in the middle of a transaction when using a shared bus object? And if so, does the card care?

@eldruin
Copy link
Member Author

eldruin commented Dec 4, 2020

I only looked at this quickly, but I had a question around the chip select. Is there a risk the card will be unselected in the middle of a transaction when using a shared bus object? And if so, does the card care?

shared-bus allows sharing when the objects are not already borrowed so taking away the spi peripheral in the middle of a transaction is not possible.
What could happen, though, is that an interrupt arrives between the time of changing the CS pin and the use of the SPI peripheral. If in that interrupt the SPI peripheral is borrowed, a situation would come up where multiple peripherals are selected.
This is a known limitation of shared-bus and there is a proposal around a managed CS trait to solve it. See: Rahix/shared-bus#8
Other than that I believe there is no danger being added here. Even though the FullDuplex trait is being used, it is being used in a blocking way already.

@Rahix
Copy link

Rahix commented Dec 4, 2020

If in that interrupt the SPI peripheral is borrowed, a situation would come up where multiple peripherals are selected.

That is currently impossible because the bus proxy for SPI is !Send. So you'd need some unsafe code to do this.

This is a known limitation of shared-bus and there is a proposal around a managed CS trait to solve it.

Also see rust-embedded/embedded-hal#245.

@eldruin eldruin merged commit b301ac8 into rust-embedded-community:develop Dec 5, 2020
@eldruin eldruin deleted the use-blocking-spi-traits branch December 5, 2020 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider switching to embedded_hal::blocking::spi traits
3 participants