nrf/spim: disable and deconfigure pins on drop.
This commit is contained in:
parent
39c420733f
commit
42abeca493
1 changed files with 19 additions and 0 deletions
|
@ -14,6 +14,7 @@ use traits::spi::FullDuplex;
|
||||||
use crate::gpio::sealed::Pin as _;
|
use crate::gpio::sealed::Pin as _;
|
||||||
use crate::gpio::{OptionalPin, Pin as GpioPin};
|
use crate::gpio::{OptionalPin, Pin as GpioPin};
|
||||||
use crate::interrupt::Interrupt;
|
use crate::interrupt::Interrupt;
|
||||||
|
use crate::{fmt::*, gpio};
|
||||||
use crate::{pac, util::slice_in_ram_or};
|
use crate::{pac, util::slice_in_ram_or};
|
||||||
|
|
||||||
pub use embedded_hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3};
|
pub use embedded_hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3};
|
||||||
|
@ -153,6 +154,24 @@ impl<'d, T: Instance> Spim<'d, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'d, T: Instance> Drop for Spim<'d, T> {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
info!("spim drop");
|
||||||
|
|
||||||
|
// TODO check for abort, wait for xxxstopped
|
||||||
|
|
||||||
|
// disable!
|
||||||
|
let r = T::regs();
|
||||||
|
r.enable.write(|w| w.enable().disabled());
|
||||||
|
|
||||||
|
gpio::deconfigure_pin(r.psel.sck.read().bits());
|
||||||
|
gpio::deconfigure_pin(r.psel.miso.read().bits());
|
||||||
|
gpio::deconfigure_pin(r.psel.mosi.read().bits());
|
||||||
|
|
||||||
|
info!("spim drop: done");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'d, T: Instance> FullDuplex<u8> for Spim<'d, T> {
|
impl<'d, T: Instance> FullDuplex<u8> for Spim<'d, T> {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue