aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-03-18 02:01:29 +0100
committerDario Nieuwenhuis <[email protected]>2021-03-18 18:49:10 +0100
commit0cd19a58c3dcaa689ba57da80c02af75866f7e09 (patch)
treefc27bb5c7dad30e401aa0ef9df28be9e3aacc1f5 /embassy-nrf/src
parent4b2fdd450e70270f346f302829fa493a67fe3ce1 (diff)
Remove free() from PeripheralMutex and all nrf drivers.
Diffstat (limited to 'embassy-nrf/src')
-rw-r--r--embassy-nrf/src/buffered_uarte.rs29
-rw-r--r--embassy-nrf/src/qspi.rs5
-rw-r--r--embassy-nrf/src/spim.rs5
3 files changed, 3 insertions, 36 deletions
diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs
index b1366cd9e..9b4ec6061 100644
--- a/embassy-nrf/src/buffered_uarte.rs
+++ b/embassy-nrf/src/buffered_uarte.rs
@@ -201,29 +201,6 @@ impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi
201 fn inner(self: Pin<&mut Self>) -> Pin<&mut PeripheralMutex<State<'a, U, T, P1, P2>>> { 201 fn inner(self: Pin<&mut Self>) -> Pin<&mut PeripheralMutex<State<'a, U, T, P1, P2>>> {
202 unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().inner) } 202 unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().inner) }
203 } 203 }
204
205 pub fn free(self: Pin<&mut Self>) -> (U, T, P1, P2, U::Interrupt) {
206 let (mut state, irq) = self.inner().free();
207 state.stop();
208 (
209 state.uarte,
210 state.timer,
211 state.ppi_channel_1,
212 state.ppi_channel_2,
213 irq,
214 )
215 }
216}
217
218impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi> Drop
219 for BufferedUarte<'a, U, T, P1, P2>
220{
221 fn drop(&mut self) {
222 let inner = unsafe { Pin::new_unchecked(&mut self.inner) };
223 if let Some((mut state, _irq)) = inner.try_free() {
224 state.stop();
225 }
226 }
227} 204}
228 205
229impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi> AsyncBufRead 206impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi> AsyncBufRead
@@ -293,10 +270,10 @@ impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi
293 } 270 }
294} 271}
295 272
296impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi> 273impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi> Drop
297 State<'a, U, T, P1, P2> 274 for State<'a, U, T, P1, P2>
298{ 275{
299 fn stop(&mut self) { 276 fn drop(&mut self) {
300 self.timer.tasks_stop.write(|w| unsafe { w.bits(1) }); 277 self.timer.tasks_stop.write(|w| unsafe { w.bits(1) });
301 if let RxState::Receiving = self.rx_state { 278 if let RxState::Receiving = self.rx_state {
302 self.uarte.tasks_stoprx.write(|w| unsafe { w.bits(1) }); 279 self.uarte.tasks_stoprx.write(|w| unsafe { w.bits(1) });
diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs
index f6e8175fa..026660cba 100644
--- a/embassy-nrf/src/qspi.rs
+++ b/embassy-nrf/src/qspi.rs
@@ -238,11 +238,6 @@ impl Qspi {
238 unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().inner) } 238 unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().inner) }
239 } 239 }
240 240
241 pub fn free(self: Pin<&mut Self>) -> (QSPI, interrupt::QSPI) {
242 let (state, irq) = self.inner().free();
243 (state.inner, irq)
244 }
245
246 fn wait_ready<'a>(mut self: Pin<&'a mut Self>) -> impl Future<Output = ()> + 'a { 241 fn wait_ready<'a>(mut self: Pin<&'a mut Self>) -> impl Future<Output = ()> + 'a {
247 poll_fn(move |cx| { 242 poll_fn(move |cx| {
248 self.as_mut().inner().with(|s, _irq| { 243 self.as_mut().inner().with(|s, _irq| {
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs
index 61d415e02..4a3adeb3d 100644
--- a/embassy-nrf/src/spim.rs
+++ b/embassy-nrf/src/spim.rs
@@ -120,11 +120,6 @@ impl<T: Instance> Spim<T> {
120 fn inner(self: Pin<&mut Self>) -> Pin<&mut PeripheralMutex<State<T>>> { 120 fn inner(self: Pin<&mut Self>) -> Pin<&mut PeripheralMutex<State<T>>> {
121 unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().inner) } 121 unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().inner) }
122 } 122 }
123
124 pub fn free(self: Pin<&mut Self>) -> (T, T::Interrupt) {
125 let (state, irq) = self.inner().free();
126 (state.spim, irq)
127 }
128} 123}
129 124
130impl<T: Instance> FullDuplex<u8> for Spim<T> { 125impl<T: Instance> FullDuplex<u8> for Spim<T> {