Skip to content

GPIO pins should have inherent infallible methods #748

Open
@jonathanpallant

Description

If you are writing a basic fn main() -> ! in Rust, there are two pitfalls using the rp-hal as it is:

  1. You don't get any useful methods on your GPIO pins unless you import the right embedded-hal traits
  2. The embedded-hal traits insist the methods (like fn set_high()) return a Result<(), Self::Error> even though on RP2040 setting a pin high cannot fail. We set type Error = core::convert:Infallible but this still has to be handled with .unwrap() or let _ = , otherwise you get a warning.

We should implement inherent methods on the type called set_high() and set_low() which return nothing. We can defer to these methods in the implementation of the embedded-hal methods, and then only people using the traits (i.e. driver authors) have to worry about the return type.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions