-
Notifications
You must be signed in to change notification settings - Fork 134
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 parameters for more control over general purpose timer CR1. #337
Add parameters for more control over general purpose timer CR1. #337
Conversation
I… guess? 🤷♂ I think @rleh and @se-bi have more stake in the Timer APIs than me, what do you think? |
At @roboterclubaachen it is common to write the registers directly for complex timer configurations. |
See this #275 (comment):
Depending on how much abstraction we consider suitable, the user should not care about the hardware. modm::Pwm<Gpio> pwm{100_kHz /* frequency */};
pwm.setDutyCycle(50_pct); Or the user wants to run a DC or BLDC/PMSM motor: librobots2::motor::Bldc<Timer, Pins, ...> ... Or measure a pulse width. And so on... For more complex timer configurations I would suggest to directly access the registers. Since it is easily possible and well documented (in STs datasheets) to access the registers I don't think we need an pass-through wrapper. |
I agree that the interface should be clear and unambiguous. The code documentation has this warning:
I am not persuaded that directly accessing registers is the way I want to use it¹ as it kind of breaks the programming paradigm. ¹: The usage, and possibly alternative solution, being outside of modm. |
True, we did that for a case with AdvancedTimer and the I-want-it-to-work-now situation... (But i would suggest to bring that stuff also into modm, I remember it as quite error prune to get what we wanted out of the documentation into the registers, better for the future to use the ready-to-go solution...)
I would agree here, since also the General Purpose Timer (I hope the "basic" one is meant *) is the same or very similar for stm32 devices or at least some families*? * Correct if i am wrong... Regarding:
Bools..:man_shrugging: |
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.
Don't get me wrong: I don't mind merging this pull request at all.
That's right. |
Yes!
Ok, I will rebase and merge these changes. |
22a7a2c
to
711e79f
Compare
@salkinium: Is it a general policy to merge ff-only for this repository, or why the rebase? I could attempt to comply with that in future. |
Yes, otherwise the history is full of merge commits which creates a lot of noise. |
For compatibility reasons with legacy code I need more control over the
TIMx->CR1
register. Thus I added more parameters. Default values render the previous behavior.I am not sure, if this is the best / correct solution?