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

add initial embedded-hal v1 implementations for pins, delays & PWM #470

Merged
merged 5 commits into from
Dec 24, 2023

Commits on Dec 24, 2023

  1. add embedded-hal=1.0.0 dependency

    this does not yet implement any 1.0.0 APIs, this is just a first step to
    make them available for implementation.
    
    the existing v0.2 dependency is being kept but is internally renamed to
    `embedded-hal-v0`. the re-export as `avr_hal_generic::hal` still points
    to v0.
    
    v1 APIs can now be implemented step-by-step. once all APIs are
    implemented the v0 APIs can be removed as a breaking change.
    rursprung committed Dec 24, 2023
    Configuration menu
    Copy the full SHA
    7d0f50f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7bd7c8f View commit details
    Browse the repository at this point in the history
  3. implement embedded-hal v1 DelayUs

    the implementation for nanoseconds will only do so with
    microsecond-accuracy as there's currently no implementation for ns.
    this is ok(-ish), as the trait allows to delay for longer than
    specified. if an implementation with us-accuracy can be done this can be
    done so later as a follow-up.
    
    the ns-implementation is done explicitly as the blanket implementation
    would otherwise transform it into us-calls which then lose precision.
    the ms-implementation was left to the blanket-implementation as it
    correctly steps it down to ns, as is also done for the old v0
    implementations.
    rursprung committed Dec 24, 2023
    Configuration menu
    Copy the full SHA
    b076377 View commit details
    Browse the repository at this point in the history
  4. add uno blinking example using only embedded-hal traits

    this is the same as `uno-blink.rs`, however the actual blinking is done
    by a function which does not make any use of any `avr-hal` specific
    APIs, instead it solely relies on `embedded-hal` v1 traits.
    
    note that the current v1.0.0-rc.3 version of `embedded-hal` still has
    `toggle` as a separate trait fn on `ToggleableOutputPin`, however that
    has been removed and v1.0.0 will ship with a blanket impl of `toggle` in
    `StatefulOutputPin`. so when updating to v1.0.0 the manual
    `set_low`/`set_high` calls can be removed, making the implementation
    equivalent to `uno-blink.rs`.
    rursprung committed Dec 24, 2023
    Configuration menu
    Copy the full SHA
    0abafde View commit details
    Browse the repository at this point in the history
  5. implement embedded-hal v1 SetDutyCycle

    this also ships with an example making use of it. note that the fading
    of the new example is faster than the existing `uno-simple-pwm.rs`
    example, since the latter fades with 255 steps while the new example
    uses 0 - 100% percent (and thus only sleeps 200 * 10ms instead of
    512 * 10ms).
    rursprung committed Dec 24, 2023
    Configuration menu
    Copy the full SHA
    0d8b3e5 View commit details
    Browse the repository at this point in the history