summaryrefslogtreecommitdiff
path: root/embassy-nrf
diff options
context:
space:
mode:
authorDario Nieuwenhuis <dirbaio@dirbaio.net>2021-08-20 15:42:42 +0200
committerDario Nieuwenhuis <dirbaio@dirbaio.net>2021-08-20 15:42:42 +0200
commit3457bb9f05ead9436349c7da877e17b803a55a0d (patch)
tree4599fa6b7684b6526093b2b65c70280c8f985e02 /embassy-nrf
parentde2039fd1dce2ab6a060b5744116373854b35a7d (diff)
downloadembassy-3457bb9f05ead9436349c7da877e17b803a55a0d.zip
nrf: make gpiote and time-driver optional via cargo features.
Diffstat (limited to 'embassy-nrf')
-rw-r--r--embassy-nrf/Cargo.toml8
-rw-r--r--embassy-nrf/src/lib.rs8
2 files changed, 15 insertions, 1 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