diff options
author | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2022-06-11 05:08:57 +0200 |
---|---|---|
committer | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2022-06-12 21:45:38 +0200 |
commit | 5085100df2845745f13715669c18a785a374a879 (patch) | |
tree | d24d264b23753d628e58fa3b92da77a78e28ce35 /embassy-nrf | |
parent | db344c2bda55bd0352a43720788185cc4d3a420e (diff) | |
download | embassy-5085100df2845745f13715669c18a785a374a879.zip |
Add embassy-cortex-m crate.
- Move Interrupt and InterruptExecutor from `embassy` to `embassy-cortex-m`.
- Move Unborrow from `embassy` to `embassy-hal-common` (nothing in `embassy` requires it anymore)
- Move PeripheralMutex from `embassy-hal-common` to `embassy-cortex-m`.
Diffstat (limited to 'embassy-nrf')
31 files changed, 54 insertions, 53 deletions
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index bf903af6..f1e6815a 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -66,6 +66,7 @@ _gpio-p1 = [] [dependencies] embassy = { version = "0.1.0", path = "../embassy" } +embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-3"]} embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["nrf"]} embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } embassy-usb = {version = "0.1.0", path = "../embassy-usb", optional=true } diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs index 6972d625..ef3ccdc9 100644 --- a/embassy-nrf/src/buffered_uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs @@ -13,15 +13,15 @@ //! //! Please also see [crate::uarte] to understand when [BufferedUarte] should be used. +use crate::interrupt::InterruptExt; +use crate::Unborrow; use core::cmp::min; use core::future::Future; use core::marker::PhantomData; use core::sync::atomic::{compiler_fence, Ordering}; use core::task::Poll; -use embassy::interrupt::InterruptExt; -use embassy::util::Unborrow; use embassy::waitqueue::WakerRegistration; -use embassy_hal_common::peripheral::{PeripheralMutex, PeripheralState, StateStorage}; +use embassy_cortex_m::peripheral::{PeripheralMutex, PeripheralState, StateStorage}; use embassy_hal_common::ring_buffer::RingBuffer; use embassy_hal_common::{low_power_wait_until, unborrow}; use futures::future::poll_fn; diff --git a/embassy-nrf/src/chips/nrf52805.rs b/embassy-nrf/src/chips/nrf52805.rs index c917dcdd..31659859 100644 --- a/embassy-nrf/src/chips/nrf52805.rs +++ b/embassy-nrf/src/chips/nrf52805.rs @@ -198,7 +198,7 @@ impl_saadc_input!(P0_05, ANALOGINPUT3); pub mod irqs { use crate::pac::Interrupt as InterruptEnum; - use embassy_macros::interrupt_declare as declare; + use embassy_macros::cortex_m_interrupt_declare as declare; declare!(POWER_CLOCK); declare!(RADIO); diff --git a/embassy-nrf/src/chips/nrf52810.rs b/embassy-nrf/src/chips/nrf52810.rs index 922b683f..195be51c 100644 --- a/embassy-nrf/src/chips/nrf52810.rs +++ b/embassy-nrf/src/chips/nrf52810.rs @@ -219,7 +219,7 @@ impl_saadc_input!(P0_31, ANALOGINPUT7); pub mod irqs { use crate::pac::Interrupt as InterruptEnum; - use embassy_macros::interrupt_declare as declare; + use embassy_macros::cortex_m_interrupt_declare as declare; declare!(POWER_CLOCK); declare!(RADIO); diff --git a/embassy-nrf/src/chips/nrf52811.rs b/embassy-nrf/src/chips/nrf52811.rs index d23ab5b3..18f05405 100644 --- a/embassy-nrf/src/chips/nrf52811.rs +++ b/embassy-nrf/src/chips/nrf52811.rs @@ -220,7 +220,7 @@ impl_saadc_input!(P0_31, ANALOGINPUT7); pub mod irqs { use crate::pac::Interrupt as InterruptEnum; - use embassy_macros::interrupt_declare as declare; + use embassy_macros::cortex_m_interrupt_declare as declare; declare!(POWER_CLOCK); declare!(RADIO); diff --git a/embassy-nrf/src/chips/nrf52820.rs b/embassy-nrf/src/chips/nrf52820.rs index e94ddbb1..b4ad4c72 100644 --- a/embassy-nrf/src/chips/nrf52820.rs +++ b/embassy-nrf/src/chips/nrf52820.rs @@ -212,7 +212,7 @@ impl_ppi_channel!(PPI_CH31, 31 => static); pub mod irqs { use crate::pac::Interrupt as InterruptEnum; - use embassy_macros::interrupt_declare as declare; + use embassy_macros::cortex_m_interrupt_declare as declare; declare!(POWER_CLOCK); declare!(RADIO); diff --git a/embassy-nrf/src/chips/nrf52832.rs b/embassy-nrf/src/chips/nrf52832.rs index fec7e10d..d578519f 100644 --- a/embassy-nrf/src/chips/nrf52832.rs +++ b/embassy-nrf/src/chips/nrf52832.rs @@ -236,7 +236,7 @@ impl_saadc_input!(P0_31, ANALOGINPUT7); pub mod irqs { use crate::pac::Interrupt as InterruptEnum; - use embassy_macros::interrupt_declare as declare; + use embassy_macros::cortex_m_interrupt_declare as declare; declare!(POWER_CLOCK); declare!(RADIO); diff --git a/embassy-nrf/src/chips/nrf52833.rs b/embassy-nrf/src/chips/nrf52833.rs index e09c7718..92f415a5 100644 --- a/embassy-nrf/src/chips/nrf52833.rs +++ b/embassy-nrf/src/chips/nrf52833.rs @@ -279,7 +279,7 @@ impl_saadc_input!(P0_31, ANALOGINPUT7); pub mod irqs { use crate::pac::Interrupt as InterruptEnum; - use embassy_macros::interrupt_declare as declare; + use embassy_macros::cortex_m_interrupt_declare as declare; declare!(POWER_CLOCK); declare!(RADIO); diff --git a/embassy-nrf/src/chips/nrf52840.rs b/embassy-nrf/src/chips/nrf52840.rs index 2e71e04b..e7a94b18 100644 --- a/embassy-nrf/src/chips/nrf52840.rs +++ b/embassy-nrf/src/chips/nrf52840.rs @@ -284,7 +284,7 @@ impl_saadc_input!(P0_31, ANALOGINPUT7); pub mod irqs { use crate::pac::Interrupt as InterruptEnum; - use embassy_macros::interrupt_declare as declare; + use embassy_macros::cortex_m_interrupt_declare as declare; declare!(POWER_CLOCK); declare!(RADIO); diff --git a/embassy-nrf/src/chips/nrf5340_app.rs b/embassy-nrf/src/chips/nrf5340_app.rs index 89579b69..13ed23cd 100644 --- a/embassy-nrf/src/chips/nrf5340_app.rs +++ b/embassy-nrf/src/chips/nrf5340_app.rs @@ -469,7 +469,7 @@ impl_saadc_input!(P0_20, ANALOGINPUT7); pub mod irqs { use crate::pac::Interrupt as InterruptEnum; - use embassy_macros::interrupt_declare as declare; + use embassy_macros::cortex_m_interrupt_declare as declare; declare!(FPU); declare!(CACHE); diff --git a/embassy-nrf/src/chips/nrf5340_net.rs b/embassy-nrf/src/chips/nrf5340_net.rs index e2ae97a9..a7e70cdc 100644 --- a/embassy-nrf/src/chips/nrf5340_net.rs +++ b/embassy-nrf/src/chips/nrf5340_net.rs @@ -329,7 +329,7 @@ impl_ppi_channel!(PPI_CH31, 31 => configurable); pub mod irqs { use crate::pac::Interrupt as InterruptEnum; - use embassy_macros::interrupt_declare as declare; + use embassy_macros::cortex_m_interrupt_declare as declare; declare!(CLOCK_POWER); declare!(RADIO); diff --git a/embassy-nrf/src/chips/nrf9160.rs b/embassy-nrf/src/chips/nrf9160.rs index b8caa126..57ff39b7 100644 --- a/embassy-nrf/src/chips/nrf9160.rs +++ b/embassy-nrf/src/chips/nrf9160.rs @@ -347,7 +347,7 @@ impl_saadc_input!(P0_20, ANALOGINPUT7); pub mod irqs { use crate::pac::Interrupt as InterruptEnum; - use embassy_macros::interrupt_declare as declare; + use embassy_macros::cortex_m_interrupt_declare as declare; declare!(SPU); declare!(CLOCK_POWER); diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs index f5212c6a..a6c84621 100644 --- a/embassy-nrf/src/gpio.rs +++ b/embassy-nrf/src/gpio.rs @@ -4,8 +4,8 @@ use core::convert::Infallible; use core::hint::unreachable_unchecked; use core::marker::PhantomData; +use crate::Unborrow; use cfg_if::cfg_if; -use embassy::util::Unborrow; use embassy_hal_common::{unborrow, unsafe_impl_unborrow}; use crate::pac; diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index c0bfd9d6..05154623 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs @@ -1,8 +1,8 @@ +use crate::interrupt::{Interrupt, InterruptExt}; use core::convert::Infallible; use core::future::Future; use core::marker::PhantomData; use core::task::{Context, Poll}; -use embassy::interrupt::{Interrupt, InterruptExt}; use embassy::waitqueue::AtomicWaker; use embassy_hal_common::unsafe_impl_unborrow; use futures::future::poll_fn; diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index 9c298a8b..6eaadfc6 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs @@ -114,23 +114,23 @@ mod chip; pub use chip::EASY_DMA_SIZE; +pub mod interrupt { + pub use crate::chip::irqs::*; + pub use cortex_m::interrupt::{CriticalSection, Mutex}; + pub use embassy_cortex_m::interrupt::*; +} + +// Reexports + #[cfg(feature = "unstable-pac")] pub use chip::pac; #[cfg(not(feature = "unstable-pac"))] pub(crate) use chip::pac; -pub use embassy::util::Unborrow; -pub use embassy_hal_common::unborrow; - pub use chip::{peripherals, Peripherals}; - -pub mod interrupt { - pub use crate::chip::irqs::*; - pub use cortex_m::interrupt::{CriticalSection, Mutex}; - pub use embassy::interrupt::{declare, take, Interrupt}; - pub use embassy_hal_common::interrupt::Priority3 as Priority; -} -pub use embassy_macros::interrupt; +pub use embassy_cortex_m::executor; +pub use embassy_hal_common::{unborrow, Unborrow}; +pub use embassy_macros::cortex_m_interrupt as interrupt; pub mod config { pub enum HfclkSource { diff --git a/embassy-nrf/src/nvmc.rs b/embassy-nrf/src/nvmc.rs index 7d7b5684..108a71d5 100644 --- a/embassy-nrf/src/nvmc.rs +++ b/embassy-nrf/src/nvmc.rs @@ -3,10 +3,10 @@ use crate::pac; use crate::peripherals::NVMC; +use crate::Unborrow; use core::marker::PhantomData; use core::ptr; use core::slice; -use embassy::util::Unborrow; use embassy_hal_common::unborrow; use embedded_storage::nor_flash::{ ErrorType, MultiwriteNorFlash, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash, diff --git a/embassy-nrf/src/ppi/dppi.rs b/embassy-nrf/src/ppi/dppi.rs index 1842590b..8609ef8d 100644 --- a/embassy-nrf/src/ppi/dppi.rs +++ b/embassy-nrf/src/ppi/dppi.rs @@ -1,6 +1,6 @@ use core::marker::PhantomData; -use embassy::util::Unborrow; +use crate::Unborrow; use embassy_hal_common::unborrow; use crate::pac; diff --git a/embassy-nrf/src/ppi/mod.rs b/embassy-nrf/src/ppi/mod.rs index aeccb154..faabbf7c 100644 --- a/embassy-nrf/src/ppi/mod.rs +++ b/embassy-nrf/src/ppi/mod.rs @@ -16,9 +16,9 @@ //! use crate::peripherals; +use crate::Unborrow; use core::marker::PhantomData; use core::ptr::NonNull; -use embassy::util::Unborrow; use embassy_hal_common::unsafe_impl_unborrow; #[cfg(feature = "_dppi")] diff --git a/embassy-nrf/src/ppi/ppi.rs b/embassy-nrf/src/ppi/ppi.rs index cdbe046f..d832d69e 100644 --- a/embassy-nrf/src/ppi/ppi.rs +++ b/embassy-nrf/src/ppi/ppi.rs @@ -1,6 +1,6 @@ use core::marker::PhantomData; -use embassy::util::Unborrow; +use crate::Unborrow; use embassy_hal_common::unborrow; use super::{Channel, ConfigurableChannel, Event, Ppi, StaticChannel, Task}; diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs index 5ac52f17..3ed60ca0 100644 --- a/embassy-nrf/src/pwm.rs +++ b/embassy-nrf/src/pwm.rs @@ -1,8 +1,8 @@ #![macro_use] +use crate::Unborrow; use core::marker::PhantomData; use core::sync::atomic::{compiler_fence, Ordering}; -use embassy::util::Unborrow; use embassy_hal_common::unborrow; use crate::gpio::sealed::Pin as _; diff --git a/embassy-nrf/src/qdec.rs b/embassy-nrf/src/qdec.rs index c2681538..b230043b 100644 --- a/embassy-nrf/src/qdec.rs +++ b/embassy-nrf/src/qdec.rs @@ -6,10 +6,10 @@ use crate::interrupt; use crate::pac; use crate::peripherals::QDEC; +use crate::interrupt::InterruptExt; +use crate::Unborrow; use core::marker::PhantomData; use core::task::Poll; -use embassy::interrupt::InterruptExt; -use embassy::util::Unborrow; use embassy::waitqueue::AtomicWaker; use embassy_hal_common::unborrow; use futures::future::poll_fn; diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs index 8902879f..adb0d838 100644 --- a/embassy-nrf/src/qspi.rs +++ b/embassy-nrf/src/qspi.rs @@ -1,10 +1,10 @@ #![macro_use] +use crate::interrupt::{Interrupt, InterruptExt}; +use crate::Unborrow; use core::marker::PhantomData; use core::ptr; use core::task::Poll; -use embassy::interrupt::{Interrupt, InterruptExt}; -use embassy::util::Unborrow; use embassy_hal_common::drop::DropBomb; use embassy_hal_common::unborrow; use futures::future::poll_fn; diff --git a/embassy-nrf/src/rng.rs b/embassy-nrf/src/rng.rs index 98833c52..43cf805f 100644 --- a/embassy-nrf/src/rng.rs +++ b/embassy-nrf/src/rng.rs @@ -4,8 +4,8 @@ use core::sync::atomic::AtomicPtr; use core::sync::atomic::Ordering; use core::task::Poll; -use embassy::interrupt::InterruptExt; -use embassy::util::Unborrow; +use crate::interrupt::InterruptExt; +use crate::Unborrow; use embassy::waitqueue::AtomicWaker; use embassy_hal_common::drop::OnDrop; use embassy_hal_common::unborrow; diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs index 61bc1fbd..915115a1 100644 --- a/embassy-nrf/src/saadc.rs +++ b/embassy-nrf/src/saadc.rs @@ -1,10 +1,10 @@ #![macro_use] +use crate::interrupt::InterruptExt; +use crate::Unborrow; use core::marker::PhantomData; use core::sync::atomic::{compiler_fence, Ordering}; use core::task::Poll; -use embassy::interrupt::InterruptExt; -use embassy::util::Unborrow; use embassy::waitqueue::AtomicWaker; use embassy_hal_common::unborrow; use futures::future::poll_fn; diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index f97a1c0f..7b28373d 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs @@ -1,10 +1,10 @@ #![macro_use] +use crate::interrupt::InterruptExt; +use crate::Unborrow; use core::marker::PhantomData; use core::sync::atomic::{compiler_fence, Ordering}; use core::task::Poll; -use embassy::interrupt::InterruptExt; -use embassy::util::Unborrow; use embassy_hal_common::unborrow; use futures::future::poll_fn; diff --git a/embassy-nrf/src/temp.rs b/embassy-nrf/src/temp.rs index f7c6e660..e5e5f29a 100644 --- a/embassy-nrf/src/temp.rs +++ b/embassy-nrf/src/temp.rs @@ -4,10 +4,10 @@ use crate::interrupt; use crate::pac; use crate::peripherals::TEMP; +use crate::interrupt::InterruptExt; +use crate::Unborrow; use core::marker::PhantomData; use core::task::Poll; -use embassy::interrupt::InterruptExt; -use embassy::util::Unborrow; use embassy::waitqueue::AtomicWaker; use embassy_hal_common::{drop::OnDrop, unborrow}; use fixed::types::I30F2; diff --git a/embassy-nrf/src/time_driver.rs b/embassy-nrf/src/time_driver.rs index a32a7bc7..8f175814 100644 --- a/embassy-nrf/src/time_driver.rs +++ b/embassy-nrf/src/time_driver.rs @@ -1,10 +1,10 @@ +use crate::interrupt::{Interrupt, InterruptExt}; use core::cell::Cell; use core::sync::atomic::{compiler_fence, AtomicU32, AtomicU8, Ordering}; use core::{mem, ptr}; use critical_section::CriticalSection; use embassy::blocking_mutex::raw::CriticalSectionRawMutex; use embassy::blocking_mutex::CriticalSectionMutex as Mutex; -use embassy::interrupt::{Interrupt, InterruptExt}; use embassy::time::driver::{AlarmHandle, Driver}; use crate::interrupt; diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs index 9173338b..588654f9 100644 --- a/embassy-nrf/src/timer.rs +++ b/embassy-nrf/src/timer.rs @@ -3,9 +3,9 @@ use core::marker::PhantomData; use core::task::Poll; -use embassy::interrupt::Interrupt; -use embassy::interrupt::InterruptExt; -use embassy::util::Unborrow; +use crate::interrupt::Interrupt; +use crate::interrupt::InterruptExt; +use crate::Unborrow; use embassy::waitqueue::AtomicWaker; use embassy_hal_common::drop::OnDrop; use embassy_hal_common::unborrow; diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs index 510266c9..2337ae21 100644 --- a/embassy-nrf/src/twim.rs +++ b/embassy-nrf/src/twim.rs @@ -6,14 +6,14 @@ //! //! - nRF52832: Section 33 //! - nRF52840: Section 6.31 +use crate::interrupt::{Interrupt, InterruptExt}; +use crate::Unborrow; use core::future::Future; use core::marker::PhantomData; use core::sync::atomic::{compiler_fence, Ordering::SeqCst}; use core::task::Poll; -use embassy::interrupt::{Interrupt, InterruptExt}; #[cfg(feature = "time")] use embassy::time::{Duration, Instant}; -use embassy::util::Unborrow; use embassy::waitqueue::AtomicWaker; use embassy_hal_common::unborrow; use futures::future::poll_fn; diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index 8970b8a1..70dbfb08 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs @@ -13,11 +13,11 @@ //! memory may be used given that buffers are passed in directly to its read and write //! methods. +use crate::interrupt::InterruptExt; +use crate::Unborrow; use core::marker::PhantomData; use core::sync::atomic::{compiler_fence, Ordering}; use core::task::Poll; -use embassy::interrupt::InterruptExt; -use embassy::util::Unborrow; use embassy_hal_common::drop::OnDrop; use embassy_hal_common::unborrow; use futures::future::poll_fn; diff --git a/embassy-nrf/src/usb.rs b/embassy-nrf/src/usb.rs index 842abf16..d0223c4c 100644 --- a/embassy-nrf/src/usb.rs +++ b/embassy-nrf/src/usb.rs @@ -1,12 +1,12 @@ #![macro_use] +use crate::interrupt::InterruptExt; +use crate::Unborrow; use core::marker::PhantomData; use core::mem::MaybeUninit; use core::sync::atomic::{compiler_fence, AtomicU32, Ordering}; use core::task::Poll; use cortex_m::peripheral::NVIC; -use embassy::interrupt::InterruptExt; -use embassy::util::Unborrow; use embassy::waitqueue::AtomicWaker; use embassy_hal_common::unborrow; use embassy_usb::driver::{self, EndpointError, Event, Unsupported}; |