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

f4xx-hal like gpio #316

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

f4xx-hal like gpio #316

wants to merge 9 commits into from

Conversation

burrbull
Copy link
Member

No description provided.

@burrbull burrbull force-pushed the f4gpio branch 9 times, most recently from 01c1dad to 893fb64 Compare March 30, 2022 13:35
Copy link
Member

@Sh3Rm4n Sh3Rm4n left a comment

Choose a reason for hiding this comment

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

Wow, thank you very much for this effort and to keep the API aligned between f3 and f4. ❤️

This change is rather big. I'll probably have time to thoroughly review it this weekend.

@@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

No changes.
- Use const generics for pins. The MSRV was bumped to 1.59 ([#316])
Copy link
Member

Choose a reason for hiding this comment

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

As this pull request changes many things in the gpio API I'd like to have a short list of things which changed like:

  • into_af_push_pull -> into_alternate
  • downgrade().downgrade() -> erase()

Kind of like a short upgrade guide. You don't have to be too detailed. I'm fine to do it myself as well. You can also wait with that change until I finished my thorough review :)

Also, this should be listed under ### Breaking Changes

Copy link
Member Author

Choose a reason for hiding this comment

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

I can add functions with old names and mark them deprecated.

Copy link
Member

Choose a reason for hiding this comment

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

Probably it is not really worth it to add deprecation notices as the resulting code would be really messy I guess.

src/gpio.rs Outdated
//! To make a pin dynamic, use the `into_dynamic` function, and then use the `make_<mode>` functions to
//! change the mode

#![allow(missing_docs)]
Copy link
Member

Choose a reason for hiding this comment

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

Please remove this when finished. If it does make sense to not comment, some parts either add this attributes to local functions or types or use #[doc(hidden)] in case of traits with the private method convention e.g. the functions or prefixed with fn _, which (I like by the way).

pub use erased::{EPin, ErasedPin};
mod dynamic;
pub use dynamic::{Dynamic, DynamicPin};
mod hal_02;
Copy link
Member

Choose a reason for hiding this comment

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

Hm, hal_02 seem a little cryptic for a module name. Maybe use the conventional abbreviation of embeded_hal like eh

Or as it is not typed very often I'm fine with a long name like embedded_hal_v0_2 or similar.

src/gpio.rs Outdated

mod sealed {
Copy link
Member

Choose a reason for hiding this comment

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

This could probably still be named marker though I'm fine with that change.

}

/// GPIO interrupt trigger edge selection
Copy link
Member

Choose a reason for hiding this comment

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

Why are these doc comments removed?

}
}
#[inline(always)]
fn _set_high(&mut self) {
Copy link
Member

Choose a reason for hiding this comment

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

If this function is private, adding #[doc(hidden)] might make sense.

}
}
#[cfg(feature = "gpio-f302")]
gpio!(GPIOA, gpioa, PA, 'A', PAn, [
Copy link
Member

Choose a reason for hiding this comment

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

The macros here are different to the previous macros, which were auto generated by the codegen tools inside this repo.

Maybe you can adjust that tool to get your desired output. But I'm fine if you don't like to bother. codegen needs a cleanup / overhaul anyway.

But did you autogenerate this or did you adjust these invocations by hand, basing on the previous implementation?

@@ -0,0 +1,147 @@
use super::*;

pub type EPin<MODE> = ErasedPin<MODE>;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this type alias is needed. I think ErasedPin is short enough. At least this type alias should not be used in this code base to benefit readability.

@@ -0,0 +1,129 @@
use super::*;

pub type PEPin<const P: char, MODE> = PartiallyErasedPin<P, MODE>;
Copy link
Member

Choose a reason for hiding this comment

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

As the other type alias, I'm not a fan of this one. Though here the case is stronger for an alias as the original type name is long.

But I don't think this is a problem. A user might just use a type alias themself via use hal::gpio::PartiallyErasedPin as PEPin.

@@ -16,9 +16,3 @@ pub use crate::rcc::RccExt as _stm32f3xx_hal_rcc_RccExt;
pub use crate::syscfg::SysCfgExt as _stm32f3xx_hal_syscfg_SysCfgExt;
pub use crate::time::duration::Extensions as _stm32f3xx_hal_time_time_Extensions;
pub use crate::time::rate::Extensions as _stm32f3xx_hal_time_rate_Extensions;
pub use crate::{
Copy link
Member

Choose a reason for hiding this comment

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

This is an important breaking change, which should be commented especially in the Changelog.

Might also be a good idea to put this in a single commit :)

src/lib.rs Outdated Show resolved Hide resolved
@Sh3Rm4n
Copy link
Member

Sh3Rm4n commented Apr 11, 2022

Hey, sorry for the delay, I'm pretty busy right now. I hope I'll make progress on this review this week.

@burrbull
Copy link
Member Author

cc @Sh3Rm4n

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.

2 participants