diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-02-20 00:27:24 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-02-20 00:27:24 +0100 |
| commit | 03ddc949a04c6dd76cb30eefb4a7bce9111cfbbc (patch) | |
| tree | 53bf70677083b5cc30f9e1a4f7f59edb0dc0102b | |
| parent | e45496900009c0049617fc4930cc5130980c0e4a (diff) | |
PeripheralMutex should be Unpin
| -rw-r--r-- | embassy-nrf-examples/src/bin/buffered_uart.rs | 2 | ||||
| -rw-r--r-- | embassy-nrf/src/util/peripheral.rs | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/embassy-nrf-examples/src/bin/buffered_uart.rs b/embassy-nrf-examples/src/bin/buffered_uart.rs index 84bc742f3..a1b2b4dd2 100644 --- a/embassy-nrf-examples/src/bin/buffered_uart.rs +++ b/embassy-nrf-examples/src/bin/buffered_uart.rs | |||
| @@ -8,6 +8,7 @@ use example_common::*; | |||
| 8 | 8 | ||
| 9 | use cortex_m_rt::entry; | 9 | use cortex_m_rt::entry; |
| 10 | use defmt::panic; | 10 | use defmt::panic; |
| 11 | use futures::pin_mut; | ||
| 11 | use nrf52840_hal as hal; | 12 | use nrf52840_hal as hal; |
| 12 | use nrf52840_hal::gpio; | 13 | use nrf52840_hal::gpio; |
| 13 | 14 | ||
| @@ -51,6 +52,7 @@ async fn run() { | |||
| 51 | buffered_uarte::Parity::EXCLUDED, | 52 | buffered_uarte::Parity::EXCLUDED, |
| 52 | buffered_uarte::Baudrate::BAUD115200, | 53 | buffered_uarte::Baudrate::BAUD115200, |
| 53 | ); | 54 | ); |
| 55 | pin_mut!(u); | ||
| 54 | 56 | ||
| 55 | info!("uarte initialized!"); | 57 | info!("uarte initialized!"); |
| 56 | 58 | ||
diff --git a/embassy-nrf/src/util/peripheral.rs b/embassy-nrf/src/util/peripheral.rs index fee343d90..6062c9d32 100644 --- a/embassy-nrf/src/util/peripheral.rs +++ b/embassy-nrf/src/util/peripheral.rs | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | use core::cell::UnsafeCell; | ||
| 2 | use core::marker::{PhantomData, PhantomPinned}; | ||
| 1 | use core::pin::Pin; | 3 | use core::pin::Pin; |
| 2 | use core::sync::atomic::{compiler_fence, Ordering}; | 4 | use core::sync::atomic::{compiler_fence, Ordering}; |
| 3 | use core::{cell::UnsafeCell, marker::PhantomData}; | ||
| 4 | 5 | ||
| 5 | use crate::fmt::*; | 6 | use crate::fmt::*; |
| 6 | use crate::interrupt::OwnedInterrupt; | 7 | use crate::interrupt::OwnedInterrupt; |
| @@ -12,14 +13,16 @@ pub trait PeripheralState { | |||
| 12 | 13 | ||
| 13 | pub struct PeripheralMutex<S: PeripheralState> { | 14 | pub struct PeripheralMutex<S: PeripheralState> { |
| 14 | inner: Option<(UnsafeCell<S>, S::Interrupt)>, | 15 | inner: Option<(UnsafeCell<S>, S::Interrupt)>, |
| 15 | not_send: PhantomData<*mut ()>, | 16 | _not_send: PhantomData<*mut ()>, |
| 17 | _pinned: PhantomPinned, | ||
| 16 | } | 18 | } |
| 17 | 19 | ||
| 18 | impl<S: PeripheralState> PeripheralMutex<S> { | 20 | impl<S: PeripheralState> PeripheralMutex<S> { |
| 19 | pub fn new(state: S, irq: S::Interrupt) -> Self { | 21 | pub fn new(state: S, irq: S::Interrupt) -> Self { |
| 20 | Self { | 22 | Self { |
| 21 | inner: Some((UnsafeCell::new(state), irq)), | 23 | inner: Some((UnsafeCell::new(state), irq)), |
| 22 | not_send: PhantomData, | 24 | _not_send: PhantomData, |
| 25 | _pinned: PhantomPinned, | ||
| 23 | } | 26 | } |
| 24 | } | 27 | } |
| 25 | 28 | ||
