Skip to content

fix(spi): flush transmitter after write to prevent spurious reads (#1007) - #1010

Open
jdeblese wants to merge 3 commits into
atsamd-rs:masterfrom
jdeblese:master
Open

fix(spi): flush transmitter after write to prevent spurious reads (#1007)#1010
jdeblese wants to merge 3 commits into
atsamd-rs:masterfrom
jdeblese:master

Conversation

@jdeblese

Copy link
Copy Markdown

Summary

Wait for SPI write transmissions to complete before re-enabling the receiver. If you don't, then code compiled for the samd21 with optimizations is fast enough to re-enable the receiver before the write occurs, resulting in occasional spurious bytes in the receive buffer. This does disable pipelined writes (partially counteracts 8243da6).

An alternative fix suggested in rust-embedded/embedded-hal#739 would be to have the flush occur at the start of a read instead of at the end of a write. That'd allow writes to be pipelined and mixed write/read transactions to work correctly, but requires more changes. I prefer to first fix the faulty behaviour with a minimal change.

Only fixes the sync implementation (regular and DMA), as I'm not familiar enough with the async to know if this is an issue there.

Checklist

  • All new or modified code is well documented, especially public items
  • No new warnings or clippy suggestions have been introduced - CI will deny clippy warnings by default! You may #[allow] certain lints where reasonable, but ideally justify those with a short comment.

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.

2 participants