aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-02-20 00:27:24 +0100
committerDario Nieuwenhuis <[email protected]>2021-02-20 00:27:24 +0100
commit03ddc949a04c6dd76cb30eefb4a7bce9111cfbbc (patch)
tree53bf70677083b5cc30f9e1a4f7f59edb0dc0102b
parente45496900009c0049617fc4930cc5130980c0e4a (diff)
PeripheralMutex should be Unpin
-rw-r--r--embassy-nrf-examples/src/bin/buffered_uart.rs2
-rw-r--r--embassy-nrf/src/util/peripheral.rs9
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
9use cortex_m_rt::entry; 9use cortex_m_rt::entry;
10use defmt::panic; 10use defmt::panic;
11use futures::pin_mut;
11use nrf52840_hal as hal; 12use nrf52840_hal as hal;
12use nrf52840_hal::gpio; 13use 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 @@
1use core::cell::UnsafeCell;
2use core::marker::{PhantomData, PhantomPinned};
1use core::pin::Pin; 3use core::pin::Pin;
2use core::sync::atomic::{compiler_fence, Ordering}; 4use core::sync::atomic::{compiler_fence, Ordering};
3use core::{cell::UnsafeCell, marker::PhantomData};
4 5
5use crate::fmt::*; 6use crate::fmt::*;
6use crate::interrupt::OwnedInterrupt; 7use crate::interrupt::OwnedInterrupt;
@@ -12,14 +13,16 @@ pub trait PeripheralState {
12 13
13pub struct PeripheralMutex<S: PeripheralState> { 14pub 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
18impl<S: PeripheralState> PeripheralMutex<S> { 20impl<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