Update examples

This commit is contained in:
Grant Miller
2024-09-06 13:53:49 -05:00
parent cfc76cec71
commit 1a8977db78
6 changed files with 37 additions and 38 deletions

View File

@@ -47,10 +47,10 @@ async fn main(spawner: Spawner) {
unwrap!(spawner.spawn(blinky(p.PB1)));
// Connect PB1 and PA8 with a 1k Ohm resistor
let ch1 = PwmPin::new_ch1(p.PA8, OutputType::PushPull);
let mut pwm = SimplePwm::new(p.TIM1, Some(ch1), None, None, None, khz(1), Default::default());
pwm.enable(Channel::Ch1);
pwm.set_duty(Channel::Ch1, 50);
let ch1_pin = PwmPin::new_ch1(p.PA8, OutputType::PushPull);
let mut pwm = SimplePwm::new(p.TIM1, Some(ch1_pin), None, None, None, khz(1), Default::default());
pwm.ch1().enable();
pwm.ch1().set_duty_cycle(50);
let ch1 = CapturePin::new_ch1(p.PA0, Pull::None);
let mut ic = InputCapture::new(p.TIM2, Some(ch1), None, None, None, Irqs, khz(1000), Default::default());

View File

@@ -43,11 +43,10 @@ async fn main(spawner: Spawner) {
unwrap!(spawner.spawn(blinky(p.PB1)));
// Connect PA8 and PA6 with a 1k Ohm resistor
let ch1 = PwmPin::new_ch1(p.PA8, OutputType::PushPull);
let mut pwm = SimplePwm::new(p.TIM1, Some(ch1), None, None, None, khz(1), Default::default());
let max = pwm.get_max_duty();
pwm.set_duty(Channel::Ch1, max / 4);
pwm.enable(Channel::Ch1);
let ch1_pin = PwmPin::new_ch1(p.PA8, OutputType::PushPull);
let mut pwm = SimplePwm::new(p.TIM1, Some(ch1_pin), None, None, None, khz(1), Default::default());
pwm.ch1().set_duty_cycle_fraction(1, 4);
pwm.ch1().enable();
let mut pwm_input = PwmInput::new(p.TIM2, p.PA0, Pull::None, khz(1000));
pwm_input.enable();