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

Clean up PWM code, fix race conditions, improve STM32L0x2 support #21

Merged
merged 14 commits into from
Aug 1, 2019
Merged

Clean up PWM code, fix race conditions, improve STM32L0x2 support #21

merged 14 commits into from
Aug 1, 2019

Commits on Jul 30, 2019

  1. Remove duplicate hal::PwmPin implementations

    Please note that I found some incorrect uses of `unsafe` while making
    this change. I've clearly marked them with comments in this commit, but
    they were there before.
    hannobraun committed Jul 30, 2019
    Configuration menu
    Copy the full SHA
    b3e52f8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    185f9d8 View commit details
    Browse the repository at this point in the history
  3. Move hal::PwmPin implementation out of macro

    The `channels!` macro is not flexible enough to support all the channels
    on STM32L0x2. This means I need to refactor or replace it, and moving
    stuff out of it is a good step in preparation for that.
    hannobraun committed Jul 30, 2019
    Configuration menu
    Copy the full SHA
    691bb90 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    16aaa61 View commit details
    Browse the repository at this point in the history
  5. Add pwm::Timer

    As noted in a previous commit, the current structure of the `pwm` is not
    flexible enough to support the capabilities of STM32L0x2 fully.
    Specifically the approach of defining the channels in sets that all use
    the same alternate function number does not match the hardware.
    
    I believe a better approach is to define each channel separately, as
    that provides the most flexibility. I also believe it will be simpler to
    make each channel accessible as a separate struct, which requires having
    a main struct that has them as fields. This main struct is the new
    `pwm::Timer` struct which is added in this commit.
    
    In addition, I've taken the chance to clean up the PWM initialization a
    bit:
    - I've removed the `PwmExt` struct, replacing it with a constructor.
      This is simple and straight-forward.
    - I've replace the old macro with a simpler, more lightweight one. This
      means more code lives outside of the macro, which has a number of
      advantages.
    hannobraun committed Jul 30, 2019
    Configuration menu
    Copy the full SHA
    64c4694 View commit details
    Browse the repository at this point in the history
  6. Make PWM example easier to observe

    Move the duty cycle changes into the loop (no more missing the beginning
    and having to restart the program), and reduce the delay between them
    (faster to verify that the program works as intended).
    hannobraun committed Jul 30, 2019
    Configuration menu
    Copy the full SHA
    4a0bafe View commit details
    Browse the repository at this point in the history
  7. Add support for TIM3 to PWM API

    It doesn't have any channels defined yet, so it can't really be used
    yet.
    hannobraun committed Jul 30, 2019
    Configuration menu
    Copy the full SHA
    4d819a0 View commit details
    Browse the repository at this point in the history
  8. Make type parameter names of Pwm match others

    I'm a bit torn about this change, because it seems a bit less readable
    when looking only at the struct. Unfortunately I can't name them
    `Instance` and `Channel`, as that would conflict with the trait names.
    
    However, this makes the struct consistent with most of the rest of the
    module, which should improve readability overall. Plus, the
    all-uppercase names look weird, as they are usually used for constants
    and statics, not types.
    hannobraun committed Jul 30, 2019
    Configuration menu
    Copy the full SHA
    c860070 View commit details
    Browse the repository at this point in the history
  9. Make PWM channels assignable separately

    With this new structure, the whole configuration is much more flexible
    now, as each channel can be defined and assigned separately.
    hannobraun committed Jul 30, 2019
    Configuration menu
    Copy the full SHA
    3360ab1 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    1b8b928 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    e91068b View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    bdde0ce View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    908edd6 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    6047908 View commit details
    Browse the repository at this point in the history