-
Notifications
You must be signed in to change notification settings - Fork 60
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
Commits on Jul 30, 2019
-
Remove duplicate
hal::PwmPin
implementationsPlease 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.
Configuration menu - View commit details
-
Copy full SHA for b3e52f8 - Browse repository at this point
Copy the full SHA b3e52f8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 185f9d8 - Browse repository at this point
Copy the full SHA 185f9d8View commit details -
Move
hal::PwmPin
implementation out of macroThe `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.
Configuration menu - View commit details
-
Copy full SHA for 691bb90 - Browse repository at this point
Copy the full SHA 691bb90View commit details -
Configuration menu - View commit details
-
Copy full SHA for 16aaa61 - Browse repository at this point
Copy the full SHA 16aaa61View commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for 64c4694 - Browse repository at this point
Copy the full SHA 64c4694View commit details -
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).
Configuration menu - View commit details
-
Copy full SHA for 4a0bafe - Browse repository at this point
Copy the full SHA 4a0bafeView commit details -
Add support for TIM3 to PWM API
It doesn't have any channels defined yet, so it can't really be used yet.
Configuration menu - View commit details
-
Copy full SHA for 4d819a0 - Browse repository at this point
Copy the full SHA 4d819a0View commit details -
Make type parameter names of
Pwm
match othersI'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.
Configuration menu - View commit details
-
Copy full SHA for c860070 - Browse repository at this point
Copy the full SHA c860070View commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for 3360ab1 - Browse repository at this point
Copy the full SHA 3360ab1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1b8b928 - Browse repository at this point
Copy the full SHA 1b8b928View commit details -
Configuration menu - View commit details
-
Copy full SHA for e91068b - Browse repository at this point
Copy the full SHA e91068bView commit details -
Configuration menu - View commit details
-
Copy full SHA for bdde0ce - Browse repository at this point
Copy the full SHA bdde0ceView commit details -
Configuration menu - View commit details
-
Copy full SHA for 908edd6 - Browse repository at this point
Copy the full SHA 908edd6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6047908 - Browse repository at this point
Copy the full SHA 6047908View commit details