-
Notifications
You must be signed in to change notification settings - Fork 806
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
Add set_config
method to RP SPI driver
#3419
Conversation
embassy-rp/src/spi.rs
Outdated
|
||
// change stuff | ||
p.cpsr().write(|w| w.set_cpsdvsr(presc)); | ||
p.cr0().write(|w| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is copypasted from new_inner
. could you extract it to a private function fn apply_config()
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the CI failure, I see that the SetConfig
trait in the embassy-embedded-hal actually does what I want, so this change may not be needed. Should we consider changing the trait implementation to disable/reenable the peripheral as the set_frequency
method does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whatever's needed for it to work. I don't know if it's required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Pico SDK disables the driver before changing frequencies, as does the set_frequency
method. I've updated to add a private apply_config
method and then reused the Spi
struct's set_config
method in the trait implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would also be a breaking change as the methods could conflict depending on Trait in scope or not - I propose we just remove the proposed Spi set_config
method and update the Trait implementation to disable/reenable the driver at the expense of some code duplication - I'll wait for your thoughts before touching again. Thanks for all your work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't worry about breaking changes, nextreleasewill be breaking anyway due to other changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
|
Add a `set_config` method to `Spi` to allow reconfiguring SPI mode after creation. The existing implementation of the `embassy-embedded-hal` trait `SetConfig` is changed to use the new method. Existing uses of `SetConfig` trait may need to explicitly call the trait method to maintain current return type.
07e0f75
to
96362b3
Compare
Squashed all the commits and cleaned up the PR description. I think the CI is running cached tests so the modified |
fixed+rebased it for you at #3600 (next time please tick the "allow maintainers to push" box, so I can rebase without creating a new PR. Thanks!) |
Add set_config method to RP SPI driver (rebased #3419)
Add a
set_config
method toSpi
struct to allow reconfiguring SPI mode after creation.The existing implementation of the
embassy-embedded-hal
traitSetConfig
is changed to use the new method.Existing uses of
SetConfig
trait may need to explicitly call the trait method to maintain current return type.