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

Document implicit assumption in non-blocking spi trait #120

Merged
merged 4 commits into from
Sep 16, 2020

Conversation

david-sawatzke
Copy link
Contributor

@david-sawatzke david-sawatzke commented Jan 2, 2019

It should only be able to read the data returned by the last write call. Otherwise the overflow handling isn't really possible when doing only write calls (at least on stm32f0). @therealprof and me came to this conclusion after chatting on irc that this is the intended usage of this api.

@david-sawatzke david-sawatzke changed the title Document implicit assumption in non-blocking spi trait & update default write trait Document implicit assumption in non-blocking spi trait Jan 2, 2019
@david-sawatzke
Copy link
Contributor Author

Removed the change for the default implementation, otherwise releasing cs after doing a blocking write will lead to unintended consequences

@eldruin
Copy link
Member

eldruin commented Feb 15, 2019

Any progress here?

@david-sawatzke
Copy link
Contributor Author

david-sawatzke commented Feb 18, 2019

I've thought about this a bit more: If any hal (with hardware fifos) wants an efficient implementation with these restraints, they'd have to count the current spi transactions. This would also make utilizing the receive fifo pretty much impossible. This slows bidirectional communication (which, in my experience, is pretty uncommon) down, especially when considering techniques like dmas or platforms like linux.

In contrast leaving it like it's currently often implemented (just giving an error if the receive fifo overflows and otherwise returning the oldest byte) makes it uncertain when the fifo overflows, forcing chip independent implementations to read after every write (and worse, if the peripheral is somehow shared, making off-by-one errors possible). But it enables chip-specific implementations to utilize the receive fifo to it's full potential.

I'm not happy with both solutions, but the proposed one sounds a lot better to me. Open to alternatives

As-is, this PR is done, not needing any changes, but some discussion could improve it.

(I think) This is also a breaking change, since existing implementations didn't have to consider any restraints.

src/spi.rs Show resolved Hide resolved
@Disasm Disasm added S-waiting-on-author Author needs to make changes to address reviewer comments T-hal labels Feb 22, 2019
@Disasm
Copy link
Member

Disasm commented Feb 23, 2019

It seems we need more discussion here. Will you be able to participate in our weekly meeting? Next will be on Feb 26.

@david-sawatzke
Copy link
Contributor Author

As this hasn't been resolved yet, I'd like to try & get this (or some alternative) into v1.0.

@eldruin
Copy link
Member

eldruin commented Sep 14, 2020

Any progress here?

@david-sawatzke
Copy link
Contributor Author

david-sawatzke commented Sep 14, 2020

This is basically ready as-is. If we want to do the simpler, but way less useful alternative of unspecified behaviour for unpaired read & send calls, that would also work. I don't care much either way, I just want there to be some thought given to it & documented instead of "the most convenient interpretation".

src/spi.rs Outdated Show resolved Hide resolved
Co-authored-by: Vadim Kaushan <admin@disasm.info>
Copy link
Contributor

@therealprof therealprof left a comment

Choose a reason for hiding this comment

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

LGTM

bors r+

@bors
Copy link
Contributor

bors bot commented Sep 16, 2020

👎 Rejected by code reviews

@therealprof
Copy link
Contributor

bors r+

@bors
Copy link
Contributor

bors bot commented Sep 16, 2020

👎 Rejected by code reviews

@david-sawatzke
Copy link
Contributor Author

Maybe the unresolved review? I've resolved it, might work now.

@therealprof
Copy link
Contributor

bors r+

@bors
Copy link
Contributor

bors bot commented Sep 16, 2020

👎 Rejected by code reviews

@therealprof
Copy link
Contributor

Nope, bors is picky about that. @Disasm will need to explicitly approve to get rid of the concern.

@Disasm
Copy link
Member

Disasm commented Sep 16, 2020

bors r=therealprof

@bors
Copy link
Contributor

bors bot commented Sep 16, 2020

🔒 Permission denied

Existing reviewers: click here to make Disasm a reviewer

@therealprof
Copy link
Contributor

bors r+

@bors bors bot merged commit ea5b5ce into rust-embedded:master Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Author needs to make changes to address reviewer comments T-hal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants