Skip to content

spi: allow impls returning early, add flush. #365

Merged
bors[bot] merged 2 commits into
rust-embedded:masterfrom
embassy-rs:spi-flush
Feb 24, 2022
Merged

spi: allow impls returning early, add flush. #365
bors[bot] merged 2 commits into
rust-embedded:masterfrom
embassy-rs:spi-flush

Conversation

@Dirbaio

@Dirbaio Dirbaio commented Feb 16, 2022

Copy link
Copy Markdown
Member

Fixes #264
Depends on #351

  • Document that all methods may return early, before bus is idle.
  • Add a flush method to wait for bus to be idle.

The alternative is to document that methods MUST wait for bus idle before returning, but that would be bad for performance IMO. Allowing early return means multiple successive writes can "overlap" so that bytes come out back-to-back without gaps, which is great for workloads with tons of small writes, like SPI displays with embedded-graphics.

Drivers using SpiDevice won't have to worry about this, it'll Just Work since Device impls must flush before deasserting CS. Drivers using SpiBus will have to care if they coordinate SPI activity with other GPIO activity.

@Dirbaio Dirbaio requested a review from a team as a code owner February 16, 2022 22:53
@rust-highfive

Copy link
Copy Markdown

r? @therealprof

(rust-highfive has picked a reviewer for you, use r? to override)

@ryankurte

Copy link
Copy Markdown
Contributor

a diff against #351 so this is easier to review pre that landing

Comment thread src/spi/blocking.rs Outdated
Comment thread src/spi/blocking.rs Outdated
@Dirbaio Dirbaio force-pushed the spi-flush branch 4 times, most recently from 9520962 to a0c1ed2 Compare February 18, 2022 19:20
@Dirbaio Dirbaio mentioned this pull request Feb 18, 2022
@Dirbaio

Dirbaio commented Feb 23, 2022

Copy link
Copy Markdown
Member Author

New version

  • Rebased on master
  • Expanded docs on when flush might be needed.

ryankurte
ryankurte previously approved these changes Feb 23, 2022

@ryankurte ryankurte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm~! any other comments @hal? it'd be good to get this merged before too many folks refactor their SPI impls.

@eldruin eldruin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Other the nitpick below, looks good to me!

Comment thread src/spi/blocking.rs Outdated
Co-authored-by: Diego Barrios Romero <eldruin@gmail.com>

@eldruin eldruin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@therealprof therealprof left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, too.

bors r+

@bors bors Bot merged commit a3522db into rust-embedded:master Feb 24, 2022
@eldruin eldruin added this to the v1.0.0 milestone Feb 25, 2022
@eldruin eldruin mentioned this pull request Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Review is incomplete T-hal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clarify SPI timing behaviour (currently completely broken!)

6 participants