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

Overhaul peripheral signal system, first run #2388

Merged
merged 10 commits into from
Oct 25, 2024
Merged

Conversation

bugadani
Copy link
Contributor

@bugadani bugadani commented Oct 22, 2024

This PR (also part of #2341) removes logic from the PeripheralInput and PeripheralOutput traits, and updates peripherals to use these traits, acquire the type-erased signals and work with those.

GPIO pins no longer have to implement signal functions directly, which is I think a big plus as it allows removing duplicate code from the gpio module.

As this PR is quite large, I did not complete all allowed cleanup opportunities.

@bugadani bugadani force-pushed the gpio branch 3 times, most recently from d32893e to d650388 Compare October 22, 2024 15:40
@bugadani bugadani marked this pull request as ready for review October 22, 2024 16:19
@bugadani bugadani force-pushed the gpio branch 2 times, most recently from f1f810a to bf8fb0b Compare October 23, 2024 08:40
esp-hal/CHANGELOG.md Outdated Show resolved Hide resolved
impl<P: OutputPin> PeripheralOutput for P {}

impl PeripheralInput for InputSignal {}
impl PeripheralInput for OutputSignal {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why have OutputSignal and OutputConnection implement PeripheralInput?

I noticed in the drivers that used to ask for bidirectional signals (i.e. impl PeripheralInput + PeripheralOutput), they've been changed to now just ask for PeripheralOutput, and this impl here allows that to work, but I don't see/understand the motive for that.

I suppose there's no such thing as an output-only pin, so on the hardware level it doesn't matter.

I still liked being able to see what the driver actually needed though. input, output or both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose there's no such thing as an output-only pin, so on the hardware level it doesn't matter.

Exactly this. PeripheralInput + PeripheralOutput is just the same thing written in more words.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would a naming change help here? e.g. PeripheralInputOutput?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess, but we also don't call our GPIO traits InputOutputPin

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we had naming like that before 🤔 but not anymore 😄

@bugadani bugadani force-pushed the gpio branch 4 times, most recently from 66ef39f to b753900 Compare October 24, 2024 11:04
Copy link
Collaborator

@Dominaezzz Dominaezzz left a comment

Choose a reason for hiding this comment

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

LGTM. I'm a bit skeptical about the input+output thing but let's see where it goes.
Once #2273 is sorted, my skepticism will be gone.

@bjoernQ bjoernQ added this pull request to the merge queue Oct 25, 2024
Merged via the queue into esp-rs:main with commit 561b582 Oct 25, 2024
28 checks passed
@bugadani bugadani deleted the gpio branch October 25, 2024 07:26
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.

3 participants