-
Notifications
You must be signed in to change notification settings - Fork 208
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
base: main
Are you sure you want to change the base?
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.
@@ -127,8 +127,8 @@ pub(crate) struct PeripheralClockControl; | |||
|
|||
#[cfg(not(any(esp32c6, esp32h2)))] | |||
impl PeripheralClockControl { | |||
/// Enables and resets the given peripheral | |||
pub(crate) fn enable(peripheral: Peripheral) { | |||
/// Enables and clears reset of the given peripheral. |
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 no longer true, depending on the value of enable
.
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).
@@ -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 :)
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