Remove free() from PeripheralMutex and all nrf drivers.

This commit is contained in:
Dario Nieuwenhuis
2021-03-18 02:01:29 +01:00
parent 4b2fdd450e
commit 0cd19a58c3
4 changed files with 23 additions and 93 deletions

View File

@ -201,29 +201,6 @@ impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi
fn inner(self: Pin<&mut Self>) -> Pin<&mut PeripheralMutex<State<'a, U, T, P1, P2>>> {
unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().inner) }
}
pub fn free(self: Pin<&mut Self>) -> (U, T, P1, P2, U::Interrupt) {
let (mut state, irq) = self.inner().free();
state.stop();
(
state.uarte,
state.timer,
state.ppi_channel_1,
state.ppi_channel_2,
irq,
)
}
}
impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi> Drop
for BufferedUarte<'a, U, T, P1, P2>
{
fn drop(&mut self) {
let inner = unsafe { Pin::new_unchecked(&mut self.inner) };
if let Some((mut state, _irq)) = inner.try_free() {
state.stop();
}
}
}
impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi> AsyncBufRead
@ -293,10 +270,10 @@ impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi
}
}
impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi>
State<'a, U, T, P1, P2>
impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi> Drop
for State<'a, U, T, P1, P2>
{
fn stop(&mut self) {
fn drop(&mut self) {
self.timer.tasks_stop.write(|w| unsafe { w.bits(1) });
if let RxState::Receiving = self.rx_state {
self.uarte.tasks_stoprx.write(|w| unsafe { w.bits(1) });

View File

@ -238,11 +238,6 @@ impl Qspi {
unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().inner) }
}
pub fn free(self: Pin<&mut Self>) -> (QSPI, interrupt::QSPI) {
let (state, irq) = self.inner().free();
(state.inner, irq)
}
fn wait_ready<'a>(mut self: Pin<&'a mut Self>) -> impl Future<Output = ()> + 'a {
poll_fn(move |cx| {
self.as_mut().inner().with(|s, _irq| {

View File

@ -120,11 +120,6 @@ impl<T: Instance> Spim<T> {
fn inner(self: Pin<&mut Self>) -> Pin<&mut PeripheralMutex<State<T>>> {
unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().inner) }
}
pub fn free(self: Pin<&mut Self>) -> (T, T::Interrupt) {
let (state, irq) = self.inner().free();
(state.spim, irq)
}
}
impl<T: Instance> FullDuplex<u8> for Spim<T> {