-
Notifications
You must be signed in to change notification settings - Fork 219
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 initial Drop for numerous drivers #2484
Conversation
083f1d5
to
3c56f1f
Compare
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.
I'm slightly worried about placing peripherals back into reset. Since we always call reset
before/after enable, I think we might do the following changes:
fn reset
should just assert reset, and shouldn't release it.
fn enable
should just release the reset, and enable clocks
fn disbale
should just disable clocks and not assert reset.
REF_COUNTER.fetch_sub(1, Relaxed); | ||
if REF_COUNTER.load(Relaxed) == 0 { |
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.
REF_COUNTER.fetch_sub(1, Relaxed); | |
if REF_COUNTER.load(Relaxed) == 0 { | |
if REF_COUNTER.fetch_sub(1, Relaxed) == 1 { |
There's no reason to read one more time.
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 Drop also means new_internal
should no longer enable clocks. Otherwise it's possible to create Rmt (enables clocks), then drop it (it won't disable clocks because no Channels have been created).
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.
Yes, this is a failed try for peripherals that has Channels/Operators etc. We come up with this idea with @bjoernQ but yeah, it's not quite good yet. I just wanted to keep it here (for now) to show what kind of issues we have to solve (or think of).
@@ -314,7 +314,7 @@ where | |||
fn new_inner(usb_device: impl Peripheral<P = USB_DEVICE> + 'd) -> Self { | |||
// Do NOT reset the peripheral. Doing so will result in a broken USB JTAG | |||
// connection. | |||
PeripheralClockControl::enable(crate::system::Peripheral::UsbDevice); | |||
PeripheralClockControl::enable(crate::system::Peripheral::UsbDevice, true); |
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.
Just noting that we'll have to make sure dropping UsbSerialJtag doesn't reset the peripheral. Which is borderline impossible to do now :)
3c56f1f
to
87c4e8e
Compare
Closed via #2544 |
Thank you for your contribution!
We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:
Submission Checklist 📝
cargo xtask fmt-packages
command to ensure that all changed code is formatted correctly.CHANGELOG.md
in the proper section.Extra:
Pull Request Details 📖
Description
Please provide a clear and concise description of your changes, including the motivation behind these changes. The context is crucial for the reviewers.
Testing
Describe how you tested your changes.
I will add more info about status/issues I've encountered etc later today or tomorrow morning. Opening as a draft until then.
cc #1382