From fff304b3de85d63c1df404ab3abc17a2ac42844a Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 4 Nov 2024 18:41:31 +0100 Subject: [PATCH 1/2] nrf/pwm: fix bad pin assignment. --- embassy-nrf/src/pwm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs index c8f1e0b09..ad88029b0 100644 --- a/embassy-nrf/src/pwm.rs +++ b/embassy-nrf/src/pwm.rs @@ -681,7 +681,7 @@ impl<'d, T: Instance> SimplePwm<'d, T> { pin.set_low(); pin.conf().write(|w| w.set_dir(gpiovals::Dir::OUTPUT)); } - r.psel().out(i).write_value(ch0.psel_bits()); + r.psel().out(i).write_value(ch.psel_bits()); } let pwm = Self { From f51ee98aef323b6d88e04ec4b3521a04d97485f9 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 4 Nov 2024 18:41:58 +0100 Subject: [PATCH 2/2] nrf/pwm: disconnect input. --- embassy-nrf/src/pwm.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs index ad88029b0..7f1f568f4 100644 --- a/embassy-nrf/src/pwm.rs +++ b/embassy-nrf/src/pwm.rs @@ -132,6 +132,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { pin.set_low(); pin.conf().write(|w| { w.set_dir(gpiovals::Dir::OUTPUT); + w.set_input(gpiovals::Input::DISCONNECT); w.set_drive(convert_drive(config.ch0_drive)); }); } @@ -139,6 +140,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { pin.set_low(); pin.conf().write(|w| { w.set_dir(gpiovals::Dir::OUTPUT); + w.set_input(gpiovals::Input::DISCONNECT); w.set_drive(convert_drive(config.ch1_drive)); }); } @@ -146,6 +148,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { pin.set_low(); pin.conf().write(|w| { w.set_dir(gpiovals::Dir::OUTPUT); + w.set_input(gpiovals::Input::DISCONNECT); w.set_drive(convert_drive(config.ch2_drive)); }); } @@ -153,6 +156,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { pin.set_low(); pin.conf().write(|w| { w.set_dir(gpiovals::Dir::OUTPUT); + w.set_input(gpiovals::Input::DISCONNECT); w.set_drive(convert_drive(config.ch3_drive)); }); } @@ -679,7 +683,12 @@ impl<'d, T: Instance> SimplePwm<'d, T> { for (i, ch) in [&ch0, &ch1, &ch2, &ch3].into_iter().enumerate() { if let Some(pin) = ch { pin.set_low(); - pin.conf().write(|w| w.set_dir(gpiovals::Dir::OUTPUT)); + + pin.conf().write(|w| { + w.set_dir(gpiovals::Dir::OUTPUT); + w.set_input(gpiovals::Input::DISCONNECT); + w.set_drive(gpiovals::Drive::S0S1); + }); } r.psel().out(i).write_value(ch.psel_bits()); }