Skip to content

Commit 5c738d1

Browse files
committed
pwm: update example
1 parent 33a01f0 commit 5c738d1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

examples/pwm.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use hal::stm32;
1111
use hal::time::RateExtU32;
1212
use stm32g4xx_hal as hal;
1313
extern crate cortex_m_rt as rt;
14+
use embedded_hal_one::pwm::SetDutyCycle;
1415

1516
#[macro_use]
1617
mod utils;
@@ -26,8 +27,9 @@ fn main() -> ! {
2627

2728
let mut pwm = dp.TIM1.pwm(pin, 100.Hz(), &mut rcc);
2829

29-
pwm.set_duty(pwm.get_max_duty() / 2);
30+
// TODO: maybe also have Pwm::enable() as a method outside the trait?
3031
pwm.enable();
32+
pwm.set_duty_cycle_fraction(1, 3).unwrap();
3133

3234
loop {
3335
cortex_m::asm::nop()

0 commit comments

Comments
 (0)