aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf/src
diff options
context:
space:
mode:
authorQuentin Smith <[email protected]>2022-08-23 23:01:51 -0400
committerQuentin Smith <[email protected]>2022-08-23 23:01:51 -0400
commit2900ab79e7afa0ca3e0d800f8a91c3253a333db1 (patch)
treea5066235f8b1ac6c2520105db2e5c48630bc006d /embassy-nrf/src
parent14eae9ca06f63a69ccc29d5fd9e1dec3848a3e98 (diff)
parent529535194d4b5d58b31fd6a7541176105e3c63f7 (diff)
Merge remote-tracking branch 'origin/master' into nrf-pdm
Diffstat (limited to 'embassy-nrf/src')
-rw-r--r--embassy-nrf/src/buffered_uarte.rs11
-rw-r--r--embassy-nrf/src/gpio.rs21
-rw-r--r--embassy-nrf/src/gpiote.rs2
-rw-r--r--embassy-nrf/src/nvmc.rs10
-rw-r--r--embassy-nrf/src/ppi/mod.rs47
-rw-r--r--embassy-nrf/src/ppi/ppi.rs3
-rw-r--r--embassy-nrf/src/qdec.rs2
-rw-r--r--embassy-nrf/src/qspi.rs2
-rw-r--r--embassy-nrf/src/rng.rs2
-rw-r--r--embassy-nrf/src/saadc.rs2
-rw-r--r--embassy-nrf/src/spim.rs2
-rw-r--r--embassy-nrf/src/temp.rs2
-rw-r--r--embassy-nrf/src/time_driver.rs4
-rw-r--r--embassy-nrf/src/timer.rs6
-rw-r--r--embassy-nrf/src/twim.rs2
-rw-r--r--embassy-nrf/src/uarte.rs2
-rw-r--r--embassy-nrf/src/usb.rs2
17 files changed, 97 insertions, 25 deletions
diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs
index 21ff1d73b..62af544ae 100644
--- a/embassy-nrf/src/buffered_uarte.rs
+++ b/embassy-nrf/src/buffered_uarte.rs
@@ -21,7 +21,7 @@ use core::task::Poll;
21use embassy_cortex_m::peripheral::{PeripheralMutex, PeripheralState, StateStorage}; 21use embassy_cortex_m::peripheral::{PeripheralMutex, PeripheralState, StateStorage};
22use embassy_hal_common::ring_buffer::RingBuffer; 22use embassy_hal_common::ring_buffer::RingBuffer;
23use embassy_hal_common::{into_ref, PeripheralRef}; 23use embassy_hal_common::{into_ref, PeripheralRef};
24use embassy_util::waitqueue::WakerRegistration; 24use embassy_sync::waitqueue::WakerRegistration;
25use futures::future::poll_fn; 25use futures::future::poll_fn;
26// Re-export SVD variants to allow user to directly set values 26// Re-export SVD variants to allow user to directly set values
27pub use pac::uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Parity}; 27pub use pac::uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Parity};
@@ -45,8 +45,10 @@ enum TxState {
45 Transmitting(usize), 45 Transmitting(usize),
46} 46}
47 47
48/// A type for storing the state of the UARTE peripheral that can be stored in a static.
48pub struct State<'d, U: UarteInstance, T: TimerInstance>(StateStorage<StateInner<'d, U, T>>); 49pub struct State<'d, U: UarteInstance, T: TimerInstance>(StateStorage<StateInner<'d, U, T>>);
49impl<'d, U: UarteInstance, T: TimerInstance> State<'d, U, T> { 50impl<'d, U: UarteInstance, T: TimerInstance> State<'d, U, T> {
51 /// Create an instance for storing UARTE peripheral state.
50 pub fn new() -> Self { 52 pub fn new() -> Self {
51 Self(StateStorage::new()) 53 Self(StateStorage::new())
52 } 54 }
@@ -75,6 +77,12 @@ pub struct BufferedUarte<'d, U: UarteInstance, T: TimerInstance> {
75impl<'d, U: UarteInstance, T: TimerInstance> Unpin for BufferedUarte<'d, U, T> {} 77impl<'d, U: UarteInstance, T: TimerInstance> Unpin for BufferedUarte<'d, U, T> {}
76 78
77impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { 79impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> {
80 /// Create a new instance of a BufferedUarte.
81 ///
82 /// See the [module documentation](crate::buffered_uarte) for more details about the intended use.
83 ///
84 /// The BufferedUarte uses the provided state to store the buffers and peripheral state. The timer and ppi channels are used to 'emulate' idle line detection so that read operations
85 /// can return early if there is no data to receive.
78 pub fn new( 86 pub fn new(
79 state: &'d mut State<'d, U, T>, 87 state: &'d mut State<'d, U, T>,
80 peri: impl Peripheral<P = U> + 'd, 88 peri: impl Peripheral<P = U> + 'd,
@@ -178,6 +186,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> {
178 } 186 }
179 } 187 }
180 188
189 /// Adjust the baud rate to the provided value.
181 pub fn set_baudrate(&mut self, baudrate: Baudrate) { 190 pub fn set_baudrate(&mut self, baudrate: Baudrate) {
182 self.inner.with(|state| { 191 self.inner.with(|state| {
183 let r = U::regs(); 192 let r = U::regs();
diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs
index a61ff6aa5..924629908 100644
--- a/embassy-nrf/src/gpio.rs
+++ b/embassy-nrf/src/gpio.rs
@@ -1,3 +1,4 @@
1//! General purpose input/output for nRF.
1#![macro_use] 2#![macro_use]
2 3
3use core::convert::Infallible; 4use core::convert::Infallible;
@@ -26,8 +27,11 @@ pub enum Port {
26#[derive(Debug, Eq, PartialEq)] 27#[derive(Debug, Eq, PartialEq)]
27#[cfg_attr(feature = "defmt", derive(defmt::Format))] 28#[cfg_attr(feature = "defmt", derive(defmt::Format))]
28pub enum Pull { 29pub enum Pull {
30 /// No pull.
29 None, 31 None,
32 /// Internal pull-up resistor.
30 Up, 33 Up,
34 /// Internal pull-down resistor.
31 Down, 35 Down,
32} 36}
33 37
@@ -37,6 +41,7 @@ pub struct Input<'d, T: Pin> {
37} 41}
38 42
39impl<'d, T: Pin> Input<'d, T> { 43impl<'d, T: Pin> Input<'d, T> {
44 /// Create GPIO input driver for a [Pin] with the provided [Pull] configuration.
40 #[inline] 45 #[inline]
41 pub fn new(pin: impl Peripheral<P = T> + 'd, pull: Pull) -> Self { 46 pub fn new(pin: impl Peripheral<P = T> + 'd, pull: Pull) -> Self {
42 let mut pin = Flex::new(pin); 47 let mut pin = Flex::new(pin);
@@ -45,11 +50,13 @@ impl<'d, T: Pin> Input<'d, T> {
45 Self { pin } 50 Self { pin }
46 } 51 }
47 52
53 /// Test if current pin level is high.
48 #[inline] 54 #[inline]
49 pub fn is_high(&self) -> bool { 55 pub fn is_high(&self) -> bool {
50 self.pin.is_high() 56 self.pin.is_high()
51 } 57 }
52 58
59 /// Test if current pin level is low.
53 #[inline] 60 #[inline]
54 pub fn is_low(&self) -> bool { 61 pub fn is_low(&self) -> bool {
55 self.pin.is_low() 62 self.pin.is_low()
@@ -66,7 +73,9 @@ impl<'d, T: Pin> Input<'d, T> {
66#[derive(Debug, Eq, PartialEq)] 73#[derive(Debug, Eq, PartialEq)]
67#[cfg_attr(feature = "defmt", derive(defmt::Format))] 74#[cfg_attr(feature = "defmt", derive(defmt::Format))]
68pub enum Level { 75pub enum Level {
76 /// Logical low.
69 Low, 77 Low,
78 /// Logical high.
70 High, 79 High,
71} 80}
72 81
@@ -88,6 +97,7 @@ impl Into<bool> for Level {
88 } 97 }
89} 98}
90 99
100/// Drive strength settings for an output pin.
91// These numbers match DRIVE_A exactly so hopefully the compiler will unify them. 101// These numbers match DRIVE_A exactly so hopefully the compiler will unify them.
92#[derive(Clone, Copy, Debug, PartialEq)] 102#[derive(Clone, Copy, Debug, PartialEq)]
93#[cfg_attr(feature = "defmt", derive(defmt::Format))] 103#[cfg_attr(feature = "defmt", derive(defmt::Format))]
@@ -117,6 +127,7 @@ pub struct Output<'d, T: Pin> {
117} 127}
118 128
119impl<'d, T: Pin> Output<'d, T> { 129impl<'d, T: Pin> Output<'d, T> {
130 /// Create GPIO output driver for a [Pin] with the provided [Level] and [OutputDriver] configuration.
120 #[inline] 131 #[inline]
121 pub fn new(pin: impl Peripheral<P = T> + 'd, initial_output: Level, drive: OutputDrive) -> Self { 132 pub fn new(pin: impl Peripheral<P = T> + 'd, initial_output: Level, drive: OutputDrive) -> Self {
122 let mut pin = Flex::new(pin); 133 let mut pin = Flex::new(pin);
@@ -264,11 +275,13 @@ impl<'d, T: Pin> Flex<'d, T> {
264 self.pin.conf().reset(); 275 self.pin.conf().reset();
265 } 276 }
266 277
278 /// Test if current pin level is high.
267 #[inline] 279 #[inline]
268 pub fn is_high(&self) -> bool { 280 pub fn is_high(&self) -> bool {
269 !self.is_low() 281 !self.is_low()
270 } 282 }
271 283
284 /// Test if current pin level is low.
272 #[inline] 285 #[inline]
273 pub fn is_low(&self) -> bool { 286 pub fn is_low(&self) -> bool {
274 self.pin.block().in_.read().bits() & (1 << self.pin.pin()) == 0 287 self.pin.block().in_.read().bits() & (1 << self.pin.pin()) == 0
@@ -374,6 +387,7 @@ pub(crate) mod sealed {
374 } 387 }
375} 388}
376 389
390/// Interface for a Pin that can be configured by an [Input] or [Output] driver, or converted to an [AnyPin].
377pub trait Pin: Peripheral<P = Self> + Into<AnyPin> + sealed::Pin + Sized + 'static { 391pub trait Pin: Peripheral<P = Self> + Into<AnyPin> + sealed::Pin + Sized + 'static {
378 /// Number of the pin within the port (0..31) 392 /// Number of the pin within the port (0..31)
379 #[inline] 393 #[inline]
@@ -392,6 +406,7 @@ pub trait Pin: Peripheral<P = Self> + Into<AnyPin> + sealed::Pin + Sized + 'stat
392 } 406 }
393 } 407 }
394 408
409 /// Peripheral port register value
395 #[inline] 410 #[inline]
396 fn psel_bits(&self) -> u32 { 411 fn psel_bits(&self) -> u32 {
397 self.pin_port() as u32 412 self.pin_port() as u32
@@ -406,12 +421,16 @@ pub trait Pin: Peripheral<P = Self> + Into<AnyPin> + sealed::Pin + Sized + 'stat
406 } 421 }
407} 422}
408 423
409// Type-erased GPIO pin 424/// Type-erased GPIO pin
410pub struct AnyPin { 425pub struct AnyPin {
411 pin_port: u8, 426 pin_port: u8,
412} 427}
413 428
414impl AnyPin { 429impl AnyPin {
430 /// Create an [AnyPin] for a specific pin.
431 ///
432 /// # Safety
433 /// - `pin_port` should not in use by another driver.
415 #[inline] 434 #[inline]
416 pub unsafe fn steal(pin_port: u8) -> Self { 435 pub unsafe fn steal(pin_port: u8) -> Self {
417 Self { pin_port } 436 Self { pin_port }
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs
index cf49b0db0..b52035705 100644
--- a/embassy-nrf/src/gpiote.rs
+++ b/embassy-nrf/src/gpiote.rs
@@ -3,7 +3,7 @@ use core::future::Future;
3use core::task::{Context, Poll}; 3use core::task::{Context, Poll};
4 4
5use embassy_hal_common::{impl_peripheral, Peripheral, PeripheralRef}; 5use embassy_hal_common::{impl_peripheral, Peripheral, PeripheralRef};
6use embassy_util::waitqueue::AtomicWaker; 6use embassy_sync::waitqueue::AtomicWaker;
7use futures::future::poll_fn; 7use futures::future::poll_fn;
8 8
9use crate::gpio::sealed::Pin as _; 9use crate::gpio::sealed::Pin as _;
diff --git a/embassy-nrf/src/nvmc.rs b/embassy-nrf/src/nvmc.rs
index cd6100339..6f66f7a78 100644
--- a/embassy-nrf/src/nvmc.rs
+++ b/embassy-nrf/src/nvmc.rs
@@ -1,4 +1,4 @@
1//! Nvmcerature sensor interface. 1//! Non-Volatile Memory Controller (NVMC) module.
2 2
3use core::{ptr, slice}; 3use core::{ptr, slice};
4 4
@@ -10,13 +10,19 @@ use embedded_storage::nor_flash::{
10use crate::peripherals::NVMC; 10use crate::peripherals::NVMC;
11use crate::{pac, Peripheral}; 11use crate::{pac, Peripheral};
12 12
13/// Erase size of NVMC flash in bytes.
13pub const PAGE_SIZE: usize = 4096; 14pub const PAGE_SIZE: usize = 4096;
15
16/// Size of NVMC flash in bytes.
14pub const FLASH_SIZE: usize = crate::chip::FLASH_SIZE; 17pub const FLASH_SIZE: usize = crate::chip::FLASH_SIZE;
15 18
19/// Error type for NVMC operations.
16#[derive(Debug, Copy, Clone, PartialEq, Eq)] 20#[derive(Debug, Copy, Clone, PartialEq, Eq)]
17#[cfg_attr(feature = "defmt", derive(defmt::Format))] 21#[cfg_attr(feature = "defmt", derive(defmt::Format))]
18pub enum Error { 22pub enum Error {
23 /// Opration using a location not in flash.
19 OutOfBounds, 24 OutOfBounds,
25 /// Unaligned operation or using unaligned buffers.
20 Unaligned, 26 Unaligned,
21} 27}
22 28
@@ -29,11 +35,13 @@ impl NorFlashError for Error {
29 } 35 }
30} 36}
31 37
38/// Non-Volatile Memory Controller (NVMC) that implements the `embedded-storage` traits.
32pub struct Nvmc<'d> { 39pub struct Nvmc<'d> {
33 _p: PeripheralRef<'d, NVMC>, 40 _p: PeripheralRef<'d, NVMC>,
34} 41}
35 42
36impl<'d> Nvmc<'d> { 43impl<'d> Nvmc<'d> {
44 /// Create Nvmc driver.
37 pub fn new(_p: impl Peripheral<P = NVMC> + 'd) -> Self { 45 pub fn new(_p: impl Peripheral<P = NVMC> + 'd) -> Self {
38 into_ref!(_p); 46 into_ref!(_p);
39 Self { _p } 47 Self { _p }
diff --git a/embassy-nrf/src/ppi/mod.rs b/embassy-nrf/src/ppi/mod.rs
index 23ab011bc..8f5ed14cd 100644
--- a/embassy-nrf/src/ppi/mod.rs
+++ b/embassy-nrf/src/ppi/mod.rs
@@ -26,6 +26,7 @@ mod dppi;
26#[cfg(feature = "_ppi")] 26#[cfg(feature = "_ppi")]
27mod ppi; 27mod ppi;
28 28
29/// An instance of the Programmable peripheral interconnect on nRF devices.
29pub struct Ppi<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize> { 30pub struct Ppi<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize> {
30 ch: PeripheralRef<'d, C>, 31 ch: PeripheralRef<'d, C>,
31 #[cfg(feature = "_dppi")] 32 #[cfg(feature = "_dppi")]
@@ -34,20 +35,32 @@ pub struct Ppi<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize
34 tasks: [Task; TASK_COUNT], 35 tasks: [Task; TASK_COUNT],
35} 36}
36 37
38#[cfg(feature = "_dppi")]
37const REGISTER_DPPI_CONFIG_OFFSET: usize = 0x80 / core::mem::size_of::<u32>(); 39const REGISTER_DPPI_CONFIG_OFFSET: usize = 0x80 / core::mem::size_of::<u32>();
38 40
39/// Represents a task that a peripheral can do. 41/// Represents a task that a peripheral can do.
40/// When a task is subscribed to a PPI channel it will run when the channel is triggered by
41/// a published event.
42/// 42///
43/// The pointer is to a task register 43/// When a task is subscribed to a PPI channel, it will run when the channel is triggered by
44/// a published event.
44#[derive(PartialEq, Eq, Clone, Copy)] 45#[derive(PartialEq, Eq, Clone, Copy)]
45pub struct Task(pub NonNull<u32>); 46pub struct Task(NonNull<u32>);
47
46impl Task { 48impl Task {
49 /// Create a new `Task` from a task register pointer
50 ///
51 /// # Safety
52 ///
53 /// `ptr` must be a pointer to a valid `TASKS_*` register from an nRF peripheral.
54 pub unsafe fn new_unchecked(ptr: NonNull<u32>) -> Self {
55 Self(ptr)
56 }
57
47 pub(crate) fn from_reg<T>(reg: &T) -> Self { 58 pub(crate) fn from_reg<T>(reg: &T) -> Self {
48 Self(unsafe { NonNull::new_unchecked(reg as *const _ as *mut _) }) 59 Self(unsafe { NonNull::new_unchecked(reg as *const _ as *mut _) })
49 } 60 }
50 61
62 /// Address of subscription register for this task.
63 #[cfg(feature = "_dppi")]
51 pub fn subscribe_reg(&self) -> *mut u32 { 64 pub fn subscribe_reg(&self) -> *mut u32 {
52 unsafe { self.0.as_ptr().add(REGISTER_DPPI_CONFIG_OFFSET) } 65 unsafe { self.0.as_ptr().add(REGISTER_DPPI_CONFIG_OFFSET) }
53 } 66 }
@@ -59,16 +72,27 @@ impl Task {
59unsafe impl Send for Task {} 72unsafe impl Send for Task {}
60 73
61/// Represents an event that a peripheral can publish. 74/// Represents an event that a peripheral can publish.
62/// An event can be set to publish on a PPI channel when the event happens.
63/// 75///
64/// The pointer is to an event register 76/// An event can be set to publish on a PPI channel when the event happens.
65#[derive(PartialEq, Eq, Clone, Copy)] 77#[derive(PartialEq, Eq, Clone, Copy)]
66pub struct Event(pub NonNull<u32>); 78pub struct Event(NonNull<u32>);
79
67impl Event { 80impl Event {
81 /// Create a new `Event` from an event register pointer
82 ///
83 /// # Safety
84 ///
85 /// `ptr` must be a pointer to a valid `EVENTS_*` register from an nRF peripheral.
86 pub unsafe fn new_unchecked(ptr: NonNull<u32>) -> Self {
87 Self(ptr)
88 }
89
68 pub(crate) fn from_reg<T>(reg: &T) -> Self { 90 pub(crate) fn from_reg<T>(reg: &T) -> Self {
69 Self(unsafe { NonNull::new_unchecked(reg as *const _ as *mut _) }) 91 Self(unsafe { NonNull::new_unchecked(reg as *const _ as *mut _) })
70 } 92 }
71 93
94 /// Address of publish register for this event.
95 #[cfg(feature = "_dppi")]
72 pub fn publish_reg(&self) -> *mut u32 { 96 pub fn publish_reg(&self) -> *mut u32 {
73 unsafe { self.0.as_ptr().add(REGISTER_DPPI_CONFIG_OFFSET) } 97 unsafe { self.0.as_ptr().add(REGISTER_DPPI_CONFIG_OFFSET) }
74 } 98 }
@@ -87,21 +111,29 @@ pub(crate) mod sealed {
87 pub trait Group {} 111 pub trait Group {}
88} 112}
89 113
114/// Interface for PPI channels.
90pub trait Channel: sealed::Channel + Peripheral<P = Self> + Sized { 115pub trait Channel: sealed::Channel + Peripheral<P = Self> + Sized {
91 /// Returns the number of the channel 116 /// Returns the number of the channel
92 fn number(&self) -> usize; 117 fn number(&self) -> usize;
93} 118}
94 119
120/// Interface for PPI channels that can be configured.
95pub trait ConfigurableChannel: Channel + Into<AnyConfigurableChannel> { 121pub trait ConfigurableChannel: Channel + Into<AnyConfigurableChannel> {
122 /// Convert into a type erased configurable channel.
96 fn degrade(self) -> AnyConfigurableChannel; 123 fn degrade(self) -> AnyConfigurableChannel;
97} 124}
98 125
126/// Interface for PPI channels that cannot be configured.
99pub trait StaticChannel: Channel + Into<AnyStaticChannel> { 127pub trait StaticChannel: Channel + Into<AnyStaticChannel> {
128 /// Convert into a type erased static channel.
100 fn degrade(self) -> AnyStaticChannel; 129 fn degrade(self) -> AnyStaticChannel;
101} 130}
102 131
132/// Interface for a group of PPI channels.
103pub trait Group: sealed::Group + Sized { 133pub trait Group: sealed::Group + Sized {
134 /// Returns the number of the group.
104 fn number(&self) -> usize; 135 fn number(&self) -> usize;
136 /// Convert into a type erased group.
105 fn degrade(self) -> AnyGroup { 137 fn degrade(self) -> AnyGroup {
106 AnyGroup { 138 AnyGroup {
107 number: self.number() as u8, 139 number: self.number() as u8,
@@ -196,6 +228,7 @@ macro_rules! impl_ppi_channel {
196// ====================== 228// ======================
197// groups 229// groups
198 230
231/// A type erased PPI group.
199pub struct AnyGroup { 232pub struct AnyGroup {
200 number: u8, 233 number: u8,
201} 234}
diff --git a/embassy-nrf/src/ppi/ppi.rs b/embassy-nrf/src/ppi/ppi.rs
index 450a290a2..19abc4e18 100644
--- a/embassy-nrf/src/ppi/ppi.rs
+++ b/embassy-nrf/src/ppi/ppi.rs
@@ -20,6 +20,7 @@ fn regs() -> &'static pac::ppi::RegisterBlock {
20 20
21#[cfg(not(feature = "nrf51"))] // Not for nrf51 because of the fork task 21#[cfg(not(feature = "nrf51"))] // Not for nrf51 because of the fork task
22impl<'d, C: StaticChannel> Ppi<'d, C, 0, 1> { 22impl<'d, C: StaticChannel> Ppi<'d, C, 0, 1> {
23 /// Configure PPI channel to trigger `task`.
23 pub fn new_zero_to_one(ch: impl Peripheral<P = C> + 'd, task: Task) -> Self { 24 pub fn new_zero_to_one(ch: impl Peripheral<P = C> + 'd, task: Task) -> Self {
24 into_ref!(ch); 25 into_ref!(ch);
25 26
@@ -32,6 +33,7 @@ impl<'d, C: StaticChannel> Ppi<'d, C, 0, 1> {
32} 33}
33 34
34impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> { 35impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> {
36 /// Configure PPI channel to trigger `task` on `event`.
35 pub fn new_one_to_one(ch: impl Peripheral<P = C> + 'd, event: Event, task: Task) -> Self { 37 pub fn new_one_to_one(ch: impl Peripheral<P = C> + 'd, event: Event, task: Task) -> Self {
36 into_ref!(ch); 38 into_ref!(ch);
37 39
@@ -46,6 +48,7 @@ impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> {
46 48
47#[cfg(not(feature = "nrf51"))] // Not for nrf51 because of the fork task 49#[cfg(not(feature = "nrf51"))] // Not for nrf51 because of the fork task
48impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 2> { 50impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 2> {
51 /// Configure PPI channel to trigger `task1` and `task2` on `event`.
49 pub fn new_one_to_two(ch: impl Peripheral<P = C> + 'd, event: Event, task1: Task, task2: Task) -> Self { 52 pub fn new_one_to_two(ch: impl Peripheral<P = C> + 'd, event: Event, task1: Task, task2: Task) -> Self {
50 into_ref!(ch); 53 into_ref!(ch);
51 54
diff --git a/embassy-nrf/src/qdec.rs b/embassy-nrf/src/qdec.rs
index 83f2916b9..762e09715 100644
--- a/embassy-nrf/src/qdec.rs
+++ b/embassy-nrf/src/qdec.rs
@@ -3,7 +3,7 @@
3use core::task::Poll; 3use core::task::Poll;
4 4
5use embassy_hal_common::{into_ref, PeripheralRef}; 5use embassy_hal_common::{into_ref, PeripheralRef};
6use embassy_util::waitqueue::AtomicWaker; 6use embassy_sync::waitqueue::AtomicWaker;
7use futures::future::poll_fn; 7use futures::future::poll_fn;
8 8
9use crate::gpio::sealed::Pin as _; 9use crate::gpio::sealed::Pin as _;
diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs
index 6d7ebb4b1..c97cb1656 100644
--- a/embassy-nrf/src/qspi.rs
+++ b/embassy-nrf/src/qspi.rs
@@ -526,7 +526,7 @@ cfg_if::cfg_if! {
526} 526}
527 527
528pub(crate) mod sealed { 528pub(crate) mod sealed {
529 use embassy_util::waitqueue::AtomicWaker; 529 use embassy_sync::waitqueue::AtomicWaker;
530 530
531 use super::*; 531 use super::*;
532 532
diff --git a/embassy-nrf/src/rng.rs b/embassy-nrf/src/rng.rs
index 7aad561b6..42da51d0f 100644
--- a/embassy-nrf/src/rng.rs
+++ b/embassy-nrf/src/rng.rs
@@ -4,7 +4,7 @@ use core::task::Poll;
4 4
5use embassy_hal_common::drop::OnDrop; 5use embassy_hal_common::drop::OnDrop;
6use embassy_hal_common::{into_ref, PeripheralRef}; 6use embassy_hal_common::{into_ref, PeripheralRef};
7use embassy_util::waitqueue::AtomicWaker; 7use embassy_sync::waitqueue::AtomicWaker;
8use futures::future::poll_fn; 8use futures::future::poll_fn;
9 9
10use crate::interrupt::InterruptExt; 10use crate::interrupt::InterruptExt;
diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs
index f2ef46d8d..7dc66349e 100644
--- a/embassy-nrf/src/saadc.rs
+++ b/embassy-nrf/src/saadc.rs
@@ -4,7 +4,7 @@ use core::sync::atomic::{compiler_fence, Ordering};
4use core::task::Poll; 4use core::task::Poll;
5 5
6use embassy_hal_common::{impl_peripheral, into_ref, PeripheralRef}; 6use embassy_hal_common::{impl_peripheral, into_ref, PeripheralRef};
7use embassy_util::waitqueue::AtomicWaker; 7use embassy_sync::waitqueue::AtomicWaker;
8use futures::future::poll_fn; 8use futures::future::poll_fn;
9use pac::{saadc, SAADC}; 9use pac::{saadc, SAADC};
10use saadc::ch::config::{GAIN_A, REFSEL_A, RESP_A, TACQ_A}; 10use saadc::ch::config::{GAIN_A, REFSEL_A, RESP_A, TACQ_A};
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs
index 57c0c14c7..be2fc02fc 100644
--- a/embassy-nrf/src/spim.rs
+++ b/embassy-nrf/src/spim.rs
@@ -363,7 +363,7 @@ impl<'d, T: Instance> Drop for Spim<'d, T> {
363} 363}
364 364
365pub(crate) mod sealed { 365pub(crate) mod sealed {
366 use embassy_util::waitqueue::AtomicWaker; 366 use embassy_sync::waitqueue::AtomicWaker;
367 367
368 use super::*; 368 use super::*;
369 369
diff --git a/embassy-nrf/src/temp.rs b/embassy-nrf/src/temp.rs
index 1491e4268..d520fd686 100644
--- a/embassy-nrf/src/temp.rs
+++ b/embassy-nrf/src/temp.rs
@@ -4,7 +4,7 @@ use core::task::Poll;
4 4
5use embassy_hal_common::drop::OnDrop; 5use embassy_hal_common::drop::OnDrop;
6use embassy_hal_common::{into_ref, PeripheralRef}; 6use embassy_hal_common::{into_ref, PeripheralRef};
7use embassy_util::waitqueue::AtomicWaker; 7use embassy_sync::waitqueue::AtomicWaker;
8use fixed::types::I30F2; 8use fixed::types::I30F2;
9use futures::future::poll_fn; 9use futures::future::poll_fn;
10 10
diff --git a/embassy-nrf/src/time_driver.rs b/embassy-nrf/src/time_driver.rs
index b961d65a0..c32a44637 100644
--- a/embassy-nrf/src/time_driver.rs
+++ b/embassy-nrf/src/time_driver.rs
@@ -3,9 +3,9 @@ use core::sync::atomic::{compiler_fence, AtomicU32, AtomicU8, Ordering};
3use core::{mem, ptr}; 3use core::{mem, ptr};
4 4
5use critical_section::CriticalSection; 5use critical_section::CriticalSection;
6use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
7use embassy_sync::blocking_mutex::CriticalSectionMutex as Mutex;
6use embassy_time::driver::{AlarmHandle, Driver}; 8use embassy_time::driver::{AlarmHandle, Driver};
7use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex;
8use embassy_util::blocking_mutex::CriticalSectionMutex as Mutex;
9 9
10use crate::interrupt::{Interrupt, InterruptExt}; 10use crate::interrupt::{Interrupt, InterruptExt};
11use crate::{interrupt, pac}; 11use crate::{interrupt, pac};
diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs
index b3b613db2..3de5a8962 100644
--- a/embassy-nrf/src/timer.rs
+++ b/embassy-nrf/src/timer.rs
@@ -5,7 +5,7 @@ use core::task::Poll;
5 5
6use embassy_hal_common::drop::OnDrop; 6use embassy_hal_common::drop::OnDrop;
7use embassy_hal_common::{into_ref, PeripheralRef}; 7use embassy_hal_common::{into_ref, PeripheralRef};
8use embassy_util::waitqueue::AtomicWaker; 8use embassy_sync::waitqueue::AtomicWaker;
9use futures::future::poll_fn; 9use futures::future::poll_fn;
10 10
11use crate::interrupt::{Interrupt, InterruptExt}; 11use crate::interrupt::{Interrupt, InterruptExt};
@@ -40,8 +40,8 @@ macro_rules! impl_timer {
40 fn regs() -> &'static pac::timer0::RegisterBlock { 40 fn regs() -> &'static pac::timer0::RegisterBlock {
41 unsafe { &*(pac::$pac_type::ptr() as *const pac::timer0::RegisterBlock) } 41 unsafe { &*(pac::$pac_type::ptr() as *const pac::timer0::RegisterBlock) }
42 } 42 }
43 fn waker(n: usize) -> &'static ::embassy_util::waitqueue::AtomicWaker { 43 fn waker(n: usize) -> &'static ::embassy_sync::waitqueue::AtomicWaker {
44 use ::embassy_util::waitqueue::AtomicWaker; 44 use ::embassy_sync::waitqueue::AtomicWaker;
45 const NEW_AW: AtomicWaker = AtomicWaker::new(); 45 const NEW_AW: AtomicWaker = AtomicWaker::new();
46 static WAKERS: [AtomicWaker; $ccs] = [NEW_AW; $ccs]; 46 static WAKERS: [AtomicWaker; $ccs] = [NEW_AW; $ccs];
47 &WAKERS[n] 47 &WAKERS[n]
diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs
index 9587d1f40..850f6d0fa 100644
--- a/embassy-nrf/src/twim.rs
+++ b/embassy-nrf/src/twim.rs
@@ -13,9 +13,9 @@ use core::task::Poll;
13 13
14use embassy_embedded_hal::SetConfig; 14use embassy_embedded_hal::SetConfig;
15use embassy_hal_common::{into_ref, PeripheralRef}; 15use embassy_hal_common::{into_ref, PeripheralRef};
16use embassy_sync::waitqueue::AtomicWaker;
16#[cfg(feature = "time")] 17#[cfg(feature = "time")]
17use embassy_time::{Duration, Instant}; 18use embassy_time::{Duration, Instant};
18use embassy_util::waitqueue::AtomicWaker;
19use futures::future::poll_fn; 19use futures::future::poll_fn;
20 20
21use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; 21use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE};
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs
index 0d24cf65f..4347ea558 100644
--- a/embassy-nrf/src/uarte.rs
+++ b/embassy-nrf/src/uarte.rs
@@ -932,7 +932,7 @@ impl<'d, U: Instance, T: TimerInstance> UarteRxWithIdle<'d, U, T> {
932pub(crate) mod sealed { 932pub(crate) mod sealed {
933 use core::sync::atomic::AtomicU8; 933 use core::sync::atomic::AtomicU8;
934 934
935 use embassy_util::waitqueue::AtomicWaker; 935 use embassy_sync::waitqueue::AtomicWaker;
936 936
937 use super::*; 937 use super::*;
938 938
diff --git a/embassy-nrf/src/usb.rs b/embassy-nrf/src/usb.rs
index 509ee313e..688326e9c 100644
--- a/embassy-nrf/src/usb.rs
+++ b/embassy-nrf/src/usb.rs
@@ -7,10 +7,10 @@ use core::task::Poll;
7 7
8use cortex_m::peripheral::NVIC; 8use cortex_m::peripheral::NVIC;
9use embassy_hal_common::{into_ref, PeripheralRef}; 9use embassy_hal_common::{into_ref, PeripheralRef};
10use embassy_sync::waitqueue::AtomicWaker;
10pub use embassy_usb; 11pub use embassy_usb;
11use embassy_usb::driver::{self, EndpointError, Event, Unsupported}; 12use embassy_usb::driver::{self, EndpointError, Event, Unsupported};
12use embassy_usb::types::{EndpointAddress, EndpointInfo, EndpointType, UsbDirection}; 13use embassy_usb::types::{EndpointAddress, EndpointInfo, EndpointType, UsbDirection};
13use embassy_util::waitqueue::AtomicWaker;
14use futures::future::poll_fn; 14use futures::future::poll_fn;
15use futures::Future; 15use futures::Future;
16use pac::usbd::RegisterBlock; 16use pac::usbd::RegisterBlock;