summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-nrf/Cargo.toml8
-rw-r--r--embassy-nrf/src/lib.rs8
-rw-r--r--examples/nrf/Cargo.toml2
3 files changed, 16 insertions, 2 deletions
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml
index cc359752..ea7efec1 100644
--- a/embassy-nrf/Cargo.toml
+++ b/embassy-nrf/Cargo.toml
@@ -26,9 +26,15 @@ nrf52832 = ["nrf52832-pac"]
nrf52833 = ["nrf52833-pac"]
nrf52840 = ["nrf52840-pac"]
+# Features starting with `_` are for internal use only. They're not intended
+# to be enabled by other crates, and are not covered by semver guarantees.
+_time-driver = ["embassy/time-tick-32768hz"]
+
+gpiote = []
+time-driver-rtc1 = ["_time-driver"]
[dependencies]
-embassy = { version = "0.1.0", path = "../embassy", features = ["time-tick-32768hz"] }
+embassy = { version = "0.1.0", path = "../embassy" }
embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["nrf"]}
embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" }
diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs
index 0de4b439..0807822f 100644
--- a/embassy-nrf/src/lib.rs
+++ b/embassy-nrf/src/lib.rs
@@ -23,10 +23,12 @@ compile_error!("No chip feature activated. You must activate exactly one of the
pub(crate) mod fmt;
pub(crate) mod util;
+#[cfg(feature = "_time-driver")]
mod time_driver;
pub mod buffered_uarte;
pub mod gpio;
+#[cfg(feature = "gpiote")]
pub mod gpiote;
pub mod ppi;
#[cfg(not(any(feature = "nrf52805", feature = "nrf52820")))]
@@ -98,7 +100,9 @@ pub mod config {
pub struct Config {
pub hfclk_source: HfclkSource,
pub lfclk_source: LfclkSource,
+ #[cfg(feature = "gpiote")]
pub gpiote_interrupt_priority: crate::interrupt::Priority,
+ #[cfg(feature = "_time-driver")]
pub time_interrupt_priority: crate::interrupt::Priority,
}
@@ -110,7 +114,9 @@ pub mod config {
// xtals if they know they have them.
hfclk_source: HfclkSource::Internal,
lfclk_source: LfclkSource::InternalRC,
+ #[cfg(feature = "gpiote")]
gpiote_interrupt_priority: crate::interrupt::Priority::P0,
+ #[cfg(feature = "_time-driver")]
time_interrupt_priority: crate::interrupt::Priority::P0,
}
}
@@ -164,9 +170,11 @@ pub fn init(config: config::Config) -> Peripherals {
while r.events_lfclkstarted.read().bits() == 0 {}
// Init GPIOTE
+ #[cfg(feature = "gpiote")]
gpiote::init(config.gpiote_interrupt_priority);
// init RTC time driver
+ #[cfg(feature = "_time-driver")]
time_driver::init(config.time_interrupt_priority);
peripherals
diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml
index f410f89c..0f932e25 100644
--- a/examples/nrf/Cargo.toml
+++ b/examples/nrf/Cargo.toml
@@ -19,7 +19,7 @@ defmt-error = []
[dependencies]
embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-trace"] }
embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
-embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "defmt-trace", "nrf52840"] }
+embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "defmt-trace", "nrf52840", "time-driver-rtc1", "gpiote"] }
defmt = "0.2.0"
defmt-rtt = "0.2.0"