-
Notifications
You must be signed in to change notification settings - Fork 69
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
Pwm channels #34
Pwm channels #34
Conversation
… TIM8 because a trait doesn't make sense. This should still be moved to the pwm module.
… all TIM3 and TIM8 channels.
…upport is known).
…annel config into the pin configuration step, and add support for TIM16 (which has only one channel) to prove out this functionality.
…larity to reference manuals.
…pins, and use typestates to ensure a channel uses one or the other, allow TIM8_CH3 to output to PB1 to use this feature.
…ry for when true complementary PWM is implemented.
…ather than in a 1-tuple.
…n't seem to be a reasonable way to make the code _truly_ safe, so better to leave the unsafe usage in place so it's obvious that this particular code is dangerous. Also remove some unneeded &s.
After merging in the most recent PR for f303 features, it now fails to build (all other devices work). Error is that port D/E/F aren't available, but that doesn't quite make sense to me. Hoping someone might have better insight as to how the previous changes might have affected this! |
This is due to different functionalities on the different sub-versions of the f303.
see: #32 |
@strom-und-spiele Ah, thanks for the clarification. Was looking in the wrong spots before! I'm a bit dubious about the ability to support sub-devices, but I see how the USB features don't leave any other option, so this makes sense. Fixed now! |
@IamfromSpace hth, The crass alternative (not supporting sub-devices) is something I think would hold back the development of this crate. |
I am all up for breaking backwards compatibility. This crate is no where near |
@strom-und-spiele @dfrankland agreed all around. Supporting subdevices seems like a must, just quite a challenge today. Having been working with a the device difference a lot lately, I’ve got some crazy ideas I’ll open a separate issue for—assuming I can get it concrete enough. For this PR these changes were simple enough and are definitely the right way to go! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to build all device features and ran a simple regression test without issues 👍
Co-Authored-By: Dylan Frankland <dfrankland@users.noreply.github.com>
Awesome, thank you! |
This supports 95% of all device/channel/pin combinations. Those that are missing seem to not yet have register support from the underlying stm32f3 crate and mostly just stm32f373 is affected.
As noted from the previous issue, this interface is a bit different from the implementation in the f1xx-hal. The key thing is that the pins are provided after the channels are returned.
In the f1xx approach there's a combinatoric explosion of possible pin combos. Just counting common pins for TIM2 there are nearly 2^11 pin combos--so a macro approach is intractable. Instead, the API enables a bring-your-own-impl for any desired pin combo working. This a clever approach and can often be quite useful, but it's also overhead for a user. This alternative approach "just works."
There are also has numerous guard rails in place while remaining intuitive. Timers/channels/pins not supported by a device cannot be accessed. Channels cannot be enabled until they have pins. Invalid pins cannot be supplied to a channel. Pins cannot be modified or shared after usage. A channel may use regular or complementary pins but not both.
When using type inference, the mechanisms behind these invariants is fairly invisible.
This is a large PR, so I'm happy to take the time to address any and all feedback. I mostly wanted to show that this approach could in fact cover all cases.
Closes #23