mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 14:53:03 +00:00
disconnect pwm pins on drop
This commit is contained in:
parent
3b7af2f4ed
commit
5f28153b81
@ -237,24 +237,30 @@ impl<'d, T: Instance> SequencePwm<'d, T> {
|
||||
|
||||
impl<'a, T: Instance> Drop for SequencePwm<'a, T> {
|
||||
fn drop(&mut self) {
|
||||
let r = T::regs();
|
||||
|
||||
self.stop();
|
||||
self.disable();
|
||||
|
||||
if let Some(pin) = &self.ch0 {
|
||||
pin.set_low();
|
||||
pin.conf().write(|w| w);
|
||||
r.psel.out[0].write(|w| unsafe { w.bits(0x80000000) });
|
||||
}
|
||||
if let Some(pin) = &self.ch1 {
|
||||
pin.set_low();
|
||||
pin.conf().write(|w| w);
|
||||
r.psel.out[1].write(|w| unsafe { w.bits(0x80000000) });
|
||||
}
|
||||
if let Some(pin) = &self.ch2 {
|
||||
pin.set_low();
|
||||
pin.conf().write(|w| w);
|
||||
r.psel.out[2].write(|w| unsafe { w.bits(0x80000000) });
|
||||
}
|
||||
if let Some(pin) = &self.ch3 {
|
||||
pin.set_low();
|
||||
pin.conf().write(|w| w);
|
||||
r.psel.out[3].write(|w| unsafe { w.bits(0x80000000) });
|
||||
}
|
||||
|
||||
info!("pwm drop: done");
|
||||
@ -522,24 +528,30 @@ impl<'d, T: Instance> SimplePwm<'d, T> {
|
||||
|
||||
impl<'a, T: Instance> Drop for SimplePwm<'a, T> {
|
||||
fn drop(&mut self) {
|
||||
let r = T::regs();
|
||||
|
||||
self.stop();
|
||||
self.disable();
|
||||
|
||||
if let Some(pin) = &self.ch0 {
|
||||
pin.set_low();
|
||||
pin.conf().write(|w| w);
|
||||
r.psel.out[0].write(|w| unsafe { w.bits(0x80000000) });
|
||||
}
|
||||
if let Some(pin) = &self.ch1 {
|
||||
pin.set_low();
|
||||
pin.conf().write(|w| w);
|
||||
r.psel.out[1].write(|w| unsafe { w.bits(0x80000000) });
|
||||
}
|
||||
if let Some(pin) = &self.ch2 {
|
||||
pin.set_low();
|
||||
pin.conf().write(|w| w);
|
||||
r.psel.out[2].write(|w| unsafe { w.bits(0x80000000) });
|
||||
}
|
||||
if let Some(pin) = &self.ch3 {
|
||||
pin.set_low();
|
||||
pin.conf().write(|w| w);
|
||||
r.psel.out[3].write(|w| unsafe { w.bits(0x80000000) });
|
||||
}
|
||||
|
||||
info!("pwm drop: done");
|
||||
|
Loading…
Reference in New Issue
Block a user