-
Notifications
You must be signed in to change notification settings - Fork 8
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 ctimer based pwm implementation #196
Conversation
340f22b
to
7460f7d
Compare
2620301
to
72205af
Compare
@hannobraun |
Thank you, @david-sawatzke! I intend to take a look later today.
I don't remember my reasoning back then in detail, but I think the key is this bit of documentation: Lines 48 to 51 in ba40d07
Basically, The whole thing is a huge hack anyway. I still hope that rust-embedded/svd2rust#213 will get implemented some day. |
Addendum to my comment earlier: I forgot that But yeah, all of it is a bit of a mess. I think it's fine, because it's just an internal helper, but I wouldn't mind making its constructor |
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.
Thank you, looking good!
I'm not very familiar with CTIMER and didn't review the register access code in detail, but I tested the example and it works great.
Two notes:
- I think this needs a rebase (as indicated by the SWM workaround I pointed out, which probably shouldn't compile on current master).
- I'm not sure that the naming is really on point.
start_pwm
seems to be appropriately named, but it returnsUnconfiguredPwmPin
, which seems already weird (It's not configured? I though I already started it?). The way I understand it, everything is configured and running, it just doesn't output to any pin.
Suggestion: Rename UnconfiguredPwmPin
to DetachedPwmPin
and configure
to attach
. I believe that would be clearer. (We could also use UnassignedPwmPin
and assign
, but that conflicts with the SWM nomenclature and would be confusing for that reason.)
d54a662
to
7f1e2e7
Compare
Thanks for the suggestion, it's more obvious what happens that way |
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.
Thanks, that's perfect now!
I found some typos, but I believe I'll be able to apply my own suggestions, once I've submitted this review.
src/ctimer.rs
Outdated
ct: CTIMER0, | ||
} | ||
|
||
/// An detached [`CTimerPwmPin`] |
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.
/// An detached [`CTimerPwmPin`] | |
/// A detached [`CTimerPwmPin`] |
src/ctimer.rs
Outdated
|
||
/// An detached [`CTimerPwmPin`] | ||
/// | ||
/// Use `attach` to assing an output to it |
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.
/// Use `attach` to assing an output to it | |
/// Use `attach` to assign an output to it. |
src/ctimer.rs
Outdated
} | ||
|
||
impl<CTOutput> DetachedPwmPin<CTOutput> { | ||
/// Assings a pin to an `DetachedPwmPin`, |
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.
/// Assings a pin to an `DetachedPwmPin`, | |
/// Assigns a pin to a `DetachedPwmPin`, |
Seems I don't have permissions to commit to your branch. You will have to apply the suggestions. Feel free to merge yourself, once you did that. |
7f1e2e7
to
4b93b62
Compare
As suggested by @hannobraun, makes it clearer what's going on
4b93b62
to
b7d4ae7
Compare
No description provided.