aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchemicstry <[email protected]>2022-10-24 11:38:15 +0300
committerchemicstry <[email protected]>2022-10-24 11:38:15 +0300
commitd99841fea90caccfd95c2dad8f233ab3198f7371 (patch)
treebd41c902982917aa13eeff1fc1cac084cda801bd
parent4ce4131f8bad84ab38f595ac02dc5292611aaac0 (diff)
Implement time feature
-rw-r--r--embassy-stm32/Cargo.toml5
-rw-r--r--embassy-stm32/src/i2c/mod.rs2
-rw-r--r--embassy-stm32/src/lib.rs2
-rw-r--r--embassy-stm32/src/subghz/timeout.rs1
-rw-r--r--embassy-stm32/src/subghz/tx_params.rs1
5 files changed, 9 insertions, 2 deletions
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml
index 9194ae788..c598604bd 100644
--- a/embassy-stm32/Cargo.toml
+++ b/embassy-stm32/Cargo.toml
@@ -82,9 +82,12 @@ memory-x = ["stm32-metapac/memory-x"]
82subghz = [] 82subghz = []
83exti = [] 83exti = []
84 84
85# Enables additional driver features that depend on embassy-time
86time = ["dep:embassy-time"]
87
85# Features starting with `_` are for internal use only. They're not intended 88# Features starting with `_` are for internal use only. They're not intended
86# to be enabled by other crates, and are not covered by semver guarantees. 89# to be enabled by other crates, and are not covered by semver guarantees.
87_time-driver = ["dep:embassy-time"] 90_time-driver = ["time"]
88time-driver-any = ["_time-driver"] 91time-driver-any = ["_time-driver"]
89time-driver-tim2 = ["_time-driver"] 92time-driver-tim2 = ["_time-driver"]
90time-driver-tim3 = ["_time-driver"] 93time-driver-tim3 = ["_time-driver"]
diff --git a/embassy-stm32/src/i2c/mod.rs b/embassy-stm32/src/i2c/mod.rs
index f4f64992c..f898fcc8b 100644
--- a/embassy-stm32/src/i2c/mod.rs
+++ b/embassy-stm32/src/i2c/mod.rs
@@ -7,7 +7,9 @@ use crate::interrupt::Interrupt;
7mod _version; 7mod _version;
8pub use _version::*; 8pub use _version::*;
9 9
10#[cfg(feature = "time")]
10mod timeout; 11mod timeout;
12#[cfg(feature = "time")]
11pub use timeout::*; 13pub use timeout::*;
12 14
13use crate::peripherals; 15use crate::peripherals;
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs
index 0392e8086..bcf2feee8 100644
--- a/embassy-stm32/src/lib.rs
+++ b/embassy-stm32/src/lib.rs
@@ -52,7 +52,7 @@ pub mod sdmmc;
52pub mod spi; 52pub mod spi;
53#[cfg(usart)] 53#[cfg(usart)]
54pub mod usart; 54pub mod usart;
55#[cfg(usb)] 55#[cfg(all(usb, feature = "time"))]
56pub mod usb; 56pub mod usb;
57#[cfg(any(otgfs, otghs))] 57#[cfg(any(otgfs, otghs))]
58pub mod usb_otg; 58pub mod usb_otg;
diff --git a/embassy-stm32/src/subghz/timeout.rs b/embassy-stm32/src/subghz/timeout.rs
index 28b3b0c21..0ae49dd90 100644
--- a/embassy-stm32/src/subghz/timeout.rs
+++ b/embassy-stm32/src/subghz/timeout.rs
@@ -439,6 +439,7 @@ impl From<Timeout> for [u8; 3] {
439 } 439 }
440} 440}
441 441
442#[cfg(feature = "time")]
442impl From<Timeout> for embassy_time::Duration { 443impl From<Timeout> for embassy_time::Duration {
443 fn from(to: Timeout) -> Self { 444 fn from(to: Timeout) -> Self {
444 embassy_time::Duration::from_micros(to.as_micros().into()) 445 embassy_time::Duration::from_micros(to.as_micros().into())
diff --git a/embassy-stm32/src/subghz/tx_params.rs b/embassy-stm32/src/subghz/tx_params.rs
index cede6f2c1..03bdb1ea8 100644
--- a/embassy-stm32/src/subghz/tx_params.rs
+++ b/embassy-stm32/src/subghz/tx_params.rs
@@ -44,6 +44,7 @@ impl From<RampTime> for core::time::Duration {
44 } 44 }
45} 45}
46 46
47#[cfg(feature = "time")]
47impl From<RampTime> for embassy_time::Duration { 48impl From<RampTime> for embassy_time::Duration {
48 fn from(rt: RampTime) -> Self { 49 fn from(rt: RampTime) -> Self {
49 match rt { 50 match rt {