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

Update embedded_hal to 1.0.0-alpha.9 #1

Merged
merged 9 commits into from
Dec 31, 2022
Merged

Conversation

MajorArkwolf
Copy link
Contributor

@MajorArkwolf MajorArkwolf commented Dec 4, 2022

Reason

esp-idf-hal for esp32 chips is currently using embedded_hal 1.0.0-alpha.9, which is incompatible with 1.0.0-alpha.5. Since downgrading esp-idf-hal is not an option due to needing embedded-svc the next best logical solution was to upgrade pca9535 library.

Work

  • Upgraded embedded_hal 1.0.0-alpha.5 -> 1.0.0-alpha.9
  • Changed the old Digitial types to the new ones,
    • Removed IOPin
    • Changed from Digital::blocking::{Output, Input} to Digital::{Output, Input}
    • Added trait implementation for new Digital::ErrorType for both ExpanderInputPin and ExpanderOutputPin
    • Swapped from all I2C Write and WriteRead traits to I2c trait.
    • Updated ExpanderError to use new I2c::ErrorType and Digital::ErrorType

Testing

No manual testing has been done and unit tests have not been done either. I will try and do manual testing on the esp32 board, if my PCA9535 chip works.

@TeyKey1
Copy link
Owner

TeyKey1 commented Dec 7, 2022

Hi @MajorArkwolf

I don't have much time right now, but I'll try to review and test your changes this weekend. I got a rpi and can run the tests directly on the hardware. In general, I'm still waiting for a 1.0 release of embedded hal to finally have some sort of stable baseline. I guess we'll just make a breaking minor version and get your hal update in if everything works as expected.

I hope that the wait does not cause you too much trouble

@TeyKey1 TeyKey1 self-requested a review December 8, 2022 19:20
Copy link
Owner

@TeyKey1 TeyKey1 left a comment

Choose a reason for hiding this comment

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

Can you please elaborate the reason for this change (remove borrowing interrupt pin)? Originally, the reason to pass the pin by reference was to enable the user to still be able to check the state of the pin to be able to directly detect any changes on the expander.
I can see that this can be a pain to implement in certain cases as a user, as the user needs to ensure that the pin lives as long as the expander struct. It's probably easier and makes more sense to just map an external interrupt on said pin to be notified if something changes on the expander inputs and make the expander struct own the pin.
In this case, it would be totally fine to just consume the interrupt pin as your change does. Also makes the setup easier. I'm fine with this, just wondering if that's the reason you changed it, or I missed something else.

Edit: Actually forget about that, just me being stupid :D Haven't used Rust in a while. The change is fine and makes sense.

src/pin.rs Outdated
@@ -16,37 +16,39 @@ use super::Register;
///
/// The [`ExpanderInputPin`] instance can be used with other pieces of software using [`hal`].
#[derive(Debug)]
pub struct ExpanderInputPin<'a, I2C, Io>
pub struct ExpanderInputPin<'a, I2C, Io, E>
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think it is necessary to expose the E generic here and introduce a new phantomdata type. The E generic is already defined by the error type of the provided I2C generic.

@TeyKey1
Copy link
Owner

TeyKey1 commented Dec 10, 2022

@MajorArkwolf I updated the tests and everything is passing on the hardware. Once we clarify what to do with the E generic you exposed this should be good to go.

@MajorArkwolf
Copy link
Contributor Author

Oh my apologies, I didn't realise that the removal of the borrowing interrupt pin got pushed onto this PR. I was testing something on my end.

I'll have a look into the E, I believe I needed to add it since it was not constrained but it's possible I overlooked something and took the wrong approach.

@TeyKey1
Copy link
Owner

TeyKey1 commented Dec 10, 2022

Oh my apologies, I didn't realise that the removal of the borrowing interrupt pin got pushed onto this PR. I was testing something on my end.

No worries, you actually fixed some useless code that way :D so we'll keep that in.

I'll have a look into the E, I believe I needed to add it since it was not constrained but it's possible I overlooked something and took the wrong approach.

I already tested it without exposed E generic. Works fine on my end. I can push those changes as well if you're OK with it.

@sjm42
Copy link

sjm42 commented Dec 30, 2022

Well... I hit this snag when trying to use shared-bus crate together with pca9535 since I am writing firmware for a board that is utilizing four pca9555 chips on a single i2c bus. Well, shared-bus is also using alpha.9 version.
Please merge...

@MajorArkwolf
Copy link
Contributor Author

Sorry, I haven't looked into this further since embedded_hal will likely break api in the next month or so. You could always pull in from my branch and use it temporarily in the interim.

@MajorArkwolf
Copy link
Contributor Author

Oh my apologies, I didn't realise that the removal of the borrowing interrupt pin got pushed onto this PR. I was testing something on my end.

No worries, you actually fixed some useless code that way :D so we'll keep that in.

I'll have a look into the E, I believe I needed to add it since it was not constrained but it's possible I overlooked something and took the wrong approach.

I already tested it without exposed E generic. Works fine on my end. I can push those changes as well if you're OK with it.

Oh my previous message never sent. Yeah feel free to push your changes in.

@MajorArkwolf
Copy link
Contributor Author

MajorArkwolf commented Dec 31, 2022

@TeyKey1 Okay removed the exposing E from ExpanderInputPin and ExpanderOutputPin.

It is not clear from one of your previous messages if you want the interrupt pin to stay as a borrowed ref or happy for it to be a copy. I had run into an issue using the ESP32 library because the pin didn't implement a trait (I think it was send) and therefore had issues. Let me know your thoughts, happy either way.

@TeyKey1 TeyKey1 merged commit a393b46 into TeyKey1:master Dec 31, 2022
@TeyKey1
Copy link
Owner

TeyKey1 commented Dec 31, 2022

Thank you very much @MajorArkwolf! I'll create a new cargo release today @sjm42

@sjm42
Copy link

sjm42 commented Dec 31, 2022

Oh, thanks a lot, guys! I really appreciate it.

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