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

HAL cleanups & remove example macros #261

Merged
merged 8 commits into from
Sep 7, 2023
Merged

Conversation

MabezDev
Copy link
Member

@MabezDev MabezDev commented Sep 6, 2023

No description provided.

@MabezDev MabezDev force-pushed the hal-cleanup branch 10 times, most recently from c7d96a2 to 614fb26 Compare September 6, 2023 15:33
@MabezDev MabezDev changed the title HAL cleanups HAL cleanups & remove example macros Sep 6, 2023
@MabezDev
Copy link
Member Author

MabezDev commented Sep 6, 2023

This is now ready for review. Each commit is an individual change (+noise from example changes), so we can revert one if needed. The examples_util still exists for the last few bits, I wasn't sure what to do with them. I changed it from a separate crate to a module that is included in each example.

I hope this will get us to a spot for a first release!

@MabezDev MabezDev marked this pull request as ready for review September 6, 2023 15:43
Copy link
Contributor

@bugadani bugadani left a comment

Choose a reason for hiding this comment

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

Wow. And also I have like 4 seconds of latency between key presses, so this PR is quite hard to react to :D What the heck is wrong with github's code...

Comment on lines +3 to +14
#[cfg(feature = "esp32")]
pub use esp32_hal as hal;
#[cfg(feature = "esp32c2")]
pub use esp32c2_hal as hal;
#[cfg(feature = "esp32c3")]
pub use esp32c3_hal as hal;
#[cfg(feature = "esp32c6")]
pub use esp32c6_hal as hal;
#[cfg(feature = "esp32s2")]
pub use esp32s2_hal as hal;
#[cfg(feature = "esp32s3")]
pub use esp32s3_hal as hal;
Copy link
Contributor

Choose a reason for hiding this comment

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

You can change the examples' Cargo.toml to include the hal as an alias. hal = { package = ...

Copy link
Contributor

Choose a reason for hiding this comment

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

Does that work with multiple optional dependencies aliased to the same name? I think that's not valid toml

Copy link
Contributor

Choose a reason for hiding this comment

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

ah - forget that - we have examples per chip 🤦‍♂️ yes ... good idea

Copy link
Member Author

@MabezDev MabezDev Sep 7, 2023

Choose a reason for hiding this comment

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

I tried this but workspace deps complicate things, it seems cargo doesn't understand this:

hal = { package = "esp32-hal", workspace = true }

and instead looks for the "hal" package Caused by: dependency.hal was not found in workspace.dependencies.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh interesting ... cargo workspaces are always fun to use

Copy link
Contributor

Choose a reason for hiding this comment

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

wait I wrote my suggestion after I tried it... too bad I wasn't exact enough, I'll need to come up with the same thing again 😅

pub use esp32s3_hal as hal;

#[cfg(any(feature = "esp32c2", feature = "esp32c3"))]
pub type BootButton = crate::hal::gpio::Gpio9<crate::hal::gpio::Input<crate::hal::gpio::PullDown>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the pin is somewhat special, maybe the HAL could expose these?

pub type BootButton = crate::hal::gpio::Gpio0<crate::hal::gpio::Input<crate::hal::gpio::PullDown>>;

#[cfg(feature = "esp32c3")]
pub const SOC_NAME: &str = "ESP32-C3";
Copy link
Contributor

Choose a reason for hiding this comment

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

I find these rather silly to keep around, to be honest. But maybe the HAL build.rs could expose them as an env!() var.

Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

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

LGTM

it's definitely a bit more effort to maintain the examples now but I see it's easier to copy/paste code now

I agree it would be good to have a const of the soc-name in the HAL and maybe also good to have a way to know the boot button by just using the HAL - but given we just had a HAL release and that we can change this in a follow up PR I'd rather wait with that instead of patching all the HAL dependencies here

@MabezDev MabezDev force-pushed the hal-cleanup branch 2 times, most recently from 6dbd105 to 7345bed Compare September 7, 2023 12:40
@MabezDev
Copy link
Member Author

MabezDev commented Sep 7, 2023

Thanks for the review @bugadani, I think I'll address them in a separate PR just so we can get this merged.

@MabezDev MabezDev merged commit 03fd19a into esp-rs:main Sep 7, 2023
7 checks passed
@MabezDev MabezDev deleted the hal-cleanup branch September 7, 2023 13:03
@bugadani
Copy link
Contributor

bugadani commented Sep 7, 2023

Sorry I didn't have the time, I'll try and figure out why I suggested that dependency rename yesterday.

@bugadani
Copy link
Contributor

bugadani commented Sep 7, 2023

Right, so as a follow-up for the record:

I think I may have set hal = { package = "esp32-hal", version = "0.15.0" } yesterday, for the examples. This is not that unfortunate as each example package now has its own soc-specific feature for examples-utils, but it still duplicates the crate version. But at least the names are the same, preserving that point of copy-pastability.

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