nrf: make gpiote and time-driver optional via cargo features.
This commit is contained in:
		@@ -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" }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user