Skip to content
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: fix examples for custom Pins trait #74

Merged
merged 1 commit into from
Jul 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
The second example selects PC8 and PC9 channels for TIM3 PWM output:

```
struct MyChannels(PB5<Alternate<PushPull>>);
struct MyChannels(PC8<Alternate<PushPull>>, PC9<Alternate<PushPull>>);

impl Pins<TIM3> for MyChannels {
const REMAP: u8 = 0b11; // use TIM3 AFIO remapping for PC6, PC7, PC8, PC9 pins
Expand Down Expand Up @@ -115,18 +115,21 @@

let device: pac::Peripherals = ..;

let (c1, c2) = device.TIM3.pwm(
let (mut c1, mut c2) = device.TIM3.pwm(
MyChannels(p1, p2),
&mut afio.mapr,
100.hz(),
clocks,
&mut rcc.apb1
);

// Set the duty cycle of channel 0 to 50%
// Set the duty cycle of channels C1 and C2 to 50% and 25% respectively
c1.set_duty(c1.get_max_duty() / 2);
c2.set_duty(c2.get_max_duty() / 4);

// PWM outputs are disabled by default
c1.enable()
c2.enable()

```
*/
Expand Down