-
Notifications
You must be signed in to change notification settings - Fork 172
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 remap: another try #147
Conversation
TIM Remaps should be in |
I will help with testing in the next few days. BTW, friendly reminder, you need to update document section in src/pwm.rs. Alternatively, you may just remove it and add another 1-2 sections into pwm_custom.rs example to show how to use different PWM mappings. Regards, |
move Remap to timer.rs, add gpio::Mode
Rebased. cc @TheZoq2 |
@burrbull , |
Ok, now I see wave notation now. No idea why. I did a quick search through TRM, but couldn't find anything useful so far. The fastest option is just to give it a try. |
Hi @burrbull , Just for the record... On BluePill all the TIM/PWM configurations available on that package work properly on all 4 channels. Here is the list of supported timers/mappings/pins combinations:
In several cases Note that for now these are the reference results that were obtained w/o your PR. Regards, |
This example is based on new PWM implementation in stm32f1xx HAL: see stm32-rs/stm32f1xx-hal#147 Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
Ok, PWM testing is completed for all the 4-channels combinations available on BluePill. Besides, random selection of 1/2/3-channels combinations has been tested as well. No testing for pwm_input and QEI from me though... In brief, using this implementation is very convenient. With this implementation it is hard to end up with a misconfigured PWM. Full example is available here. Note that test example explicitly specifies all the mappings in the form Tested-by: Sergey Matyukevich geomatsi@gmail.com Regards, |
@@ -14,10 +14,10 @@ | |||
```rust |
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.
The whole document subsection about pre-defined channel combinations can be removed.
feature = "stm32f105", | ||
))] | ||
impl Timer<TIM1> { | ||
pub fn pwm_input<REMAP, PINS, T>( |
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 am not familiar with using pwm_input and qei. So the question based on comparison with pwm
implementation. I assume it is not pwm_input<REMAP, P, PINS, T>
just because only (Ch1, Ch2) are allowed for pwm_input mode as well as QEI mode. Is this correct ? Or more configurations are supported, but this is current limitation of stm32f1xx_hal ?
where | ||
REMAP: Remap<Periph = TIM>, | ||
P1: Ch1<REMAP> + gpio::Mode<Input<Floating>>, | ||
P2: Ch2<REMAP> + gpio::Mode<Input<Floating>> {} |
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.
@geomatsi pwm_input use other Pins
trait/implementation with only first two channels. I did not change this.
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.
Looks good overall (though i'm not super familiar with PWM input or QEI). I left some nitpick comments, mostly related to docs
CHANGELOG.md
Outdated
@@ -19,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). | |||
|
|||
### Breaking changes | |||
|
|||
- Implement more pin combinations for PWM configuration, added PWM for TIM1 |
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.
This doesn't seem like a breaking change, or am I missing something?
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.
If someone use old custom API, now he need to rewrite his code. So yes, it is breaking change.
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.
Ah yea, makes sense. Perhaps the changelog should clarify that though
examples/pwm_custom.rs
Outdated
@@ -58,12 +34,12 @@ fn main() -> ! { | |||
let p0 = pb4.into_alternate_push_pull(&mut gpiob.crl); | |||
let p1 = gpiob.pb5.into_alternate_push_pull(&mut gpiob.crl); | |||
|
|||
//let pa1 = gpioa.pa1.into_alternate_push_pull(&mut gpioa.crl); |
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.
Remove unused comments
examples/pwm_custom.rs
Outdated
timer::Timer, | ||
//timer::Tim2NoRemap, |
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.
Unused comment
src/pwm.rs
Outdated
@@ -28,227 +28,157 @@ | |||
|
|||
// Put the timer in PWM mode using the specified pins | |||
// with a frequency of 100 hz. | |||
// In some cases you need to specify remap you need, especcially for TIM2: |
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.
Would be nice to point users to where they can find what remaps they can specify.
Also double 'c' in especially
Perfect, thanks! |
This is something average between #124 and #146.
But it's need for testing.
cc @geomatsi