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

Implement a polling async SPI interface #129

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

dflemstr
Copy link

Addresses a part of #128. The existing code was moved around and with an optimizing compiler I expect it to generate the same code as before.

There are also new polling versions of the transfer functions that don't block. The idea is that one could call these from interrupt handlers to get non-blocking/low power SPI transfers. The returned types intentionally don't implement core::future::Future since that would require waker management.

See https://github.com/dflemstr/embedded-platform/tree/master/platforms/nrf52840 for higher-level async code that could be supported by this change.

@hannobraun
Copy link
Contributor

Thank you for the pull request, @dflemstr! It seems that nobody (including me) has the time to look into it right now. Sorry!

Feel free to ping @nrf-rs/nrf52 and @nrf-rs/nrf91, to remind us, if you feel it's taken too long.

@dflemstr
Copy link
Author

Pinging @nrf-rs/nrf52 and @nrf-rs/nrf91 :)

Copy link
Member

@jonathanpallant jonathanpallant left a comment

Choose a reason for hiding this comment

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

This LGTM, but I haven't tested it.

@jonas-schievink jonas-schievink self-assigned this Feb 14, 2020
Copy link
Contributor

@jonas-schievink jonas-schievink left a comment

Choose a reason for hiding this comment

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

Haven't reviewed this in-depth (in particulat for soundness regarding lifetime variance etc.), but left a few comments. Sorry this is taking so long, I'd love to spend a lot of time I don't have to work on this HAL.

nrf52-hal-common/src/spim.rs Outdated Show resolved Hide resolved
nrf52-hal-common/src/spim.rs Outdated Show resolved Hide resolved
nrf52-hal-common/src/spim.rs Outdated Show resolved Hide resolved
nrf52-hal-common/src/spim.rs Outdated Show resolved Hide resolved
@jonas-schievink

This comment has been minimized.

nrf52-hal-common/src/spim.rs Outdated Show resolved Hide resolved
nrf52-hal-common/src/spim.rs Outdated Show resolved Hide resolved
nrf52-hal-common/src/spim.rs Outdated Show resolved Hide resolved
nrf52-hal-common/src/spim.rs Outdated Show resolved Hide resolved
nrf52-hal-common/src/spim.rs Show resolved Hide resolved
@jonas-schievink
Copy link
Contributor

I think this looks basically fine now. Have you tested this on real hardware?

@dflemstr
Copy link
Author

dflemstr commented Feb 22, 2020

I have tested it on a Particle Argon, but the SPI slave device (which is custom made...) has a few power glitches (even when using a different master device) so I would appreciate some secondary testing by someone with a more reliable SPI slave device

@jonas-schievink jonas-schievink removed their assignment Feb 24, 2020
@thalesfragoso
Copy link
Contributor

Isn't this API susceptible to the mem::forget problem ? See https://docs.rust-embedded.org/embedonomicon/dma.html#memforget

@dflemstr
Copy link
Author

@thalesfragoso how would you recommend that we fix it in this case?

@thalesfragoso
Copy link
Contributor

Right now, I see two solutions:

@dflemstr
Copy link
Author

@thalesfragoso @jonas-schievink as you might see from the PR metadata, I've decided to get some clarity around async HAL in rust-embedded/embedded-hal#206 before I'd feel comfortable with picking a direction for how to continue this PR.

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.

5 participants