diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5b5ee297..8a9299e9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,7 +36,7 @@ jobs: cargo build --workspace --target thumbv7m-none-eabi - --features async,defmt-03,embedded-io/defmt,embedded-io-async/defmt + --features async,defmt,embedded-io/defmt,embedded-io-async/defmt msrv-1-81: runs-on: ubuntu-latest diff --git a/embedded-hal-async/Cargo.toml b/embedded-hal-async/Cargo.toml index 4d267933..60e02a7f 100644 --- a/embedded-hal-async/Cargo.toml +++ b/embedded-hal-async/Cargo.toml @@ -15,8 +15,8 @@ version = "1.0.0" rust-version = "1.75" [features] -defmt-03 = ["dep:defmt-03", "embedded-hal/defmt-03"] +defmt = ["dep:defmt", "embedded-hal/defmt"] [dependencies] embedded-hal = { version = "1.0.0", path = "../embedded-hal" } -defmt-03 = { package = "defmt", version = "0.3", optional = true } +defmt = { package = "defmt", version = "1", optional = true } diff --git a/embedded-hal-bus/Cargo.toml b/embedded-hal-bus/Cargo.toml index 7f404e3d..c4d78ec0 100644 --- a/embedded-hal-bus/Cargo.toml +++ b/embedded-hal-bus/Cargo.toml @@ -27,7 +27,7 @@ portable-atomic = ["dep:portable-atomic"] # Enable `embedded-hal-async` support. async = ["dep:embedded-hal-async"] # Derive `defmt::Format` from `defmt` 0.3 for enums and structs. See https://github.com/knurling-rs/defmt for more info -defmt-03 = ["dep:defmt-03", "embedded-hal/defmt-03", "embedded-hal-async?/defmt-03"] +defmt = ["dep:defmt", "embedded-hal/defmt", "embedded-hal-async?/defmt"] # Enables additional utilities requiring a global allocator. alloc = [] @@ -35,7 +35,7 @@ alloc = [] embedded-hal = { version = "1.0.0", path = "../embedded-hal" } embedded-hal-async = { version = "1.0.0", path = "../embedded-hal-async", optional = true } critical-section = { version = "1.0" } -defmt-03 = { package = "defmt", version = "0.3", optional = true } +defmt = { package = "defmt", version = "1", optional = true } portable-atomic = {version = "1.3", default-features = false, optional = true, features = ["require-cas"]} [package.metadata.docs.rs] diff --git a/embedded-hal-bus/src/lib.rs b/embedded-hal-bus/src/lib.rs index dfeca16e..7545480b 100644 --- a/embedded-hal-bus/src/lib.rs +++ b/embedded-hal-bus/src/lib.rs @@ -3,10 +3,6 @@ #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(docsrs, feature(doc_cfg))] -// needed to prevent defmt macros from breaking, since they emit code that does `defmt::blahblah`. -#[cfg(feature = "defmt-03")] -use defmt_03 as defmt; - pub mod i2c; pub mod spi; pub mod util; diff --git a/embedded-hal-bus/src/spi/mod.rs b/embedded-hal-bus/src/spi/mod.rs index 65972628..bf8b5a3b 100644 --- a/embedded-hal-bus/src/spi/mod.rs +++ b/embedded-hal-bus/src/spi/mod.rs @@ -25,12 +25,12 @@ pub use rc::*; pub use self::critical_section::*; -#[cfg(feature = "defmt-03")] -use crate::defmt; +#[cfg(feature = "defmt")] +use defmt; /// Error type for [`ExclusiveDevice`] operations. #[derive(Copy, Clone, Eq, PartialEq, Debug)] -#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum DeviceError { /// An inner SPI bus operation failed. Spi(BUS), @@ -65,7 +65,7 @@ where /// Dummy [`DelayNs`](embedded_hal::delay::DelayNs) implementation that panics on use. #[derive(Copy, Clone, Eq, PartialEq, Debug)] -#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub struct NoDelay; #[cold] diff --git a/embedded-hal/Cargo.toml b/embedded-hal/Cargo.toml index 011f3cc9..4dc4e011 100644 --- a/embedded-hal/Cargo.toml +++ b/embedded-hal/Cargo.toml @@ -17,7 +17,7 @@ repository = "https://github.com/rust-embedded/embedded-hal" version = "1.0.0" [features] -defmt-03 = ["dep:defmt-03"] +defmt = ["dep:defmt"] [dependencies] -defmt-03 = { package = "defmt", version = "0.3", optional = true } +defmt = { package = "defmt", version = "1", optional = true } diff --git a/embedded-hal/src/digital.rs b/embedded-hal/src/digital.rs index 581f2ca3..cff6e2cd 100644 --- a/embedded-hal/src/digital.rs +++ b/embedded-hal/src/digital.rs @@ -2,8 +2,8 @@ use core::ops::Not; -#[cfg(feature = "defmt-03")] -use crate::defmt; +#[cfg(feature = "defmt")] +use defmt; /// Error. pub trait Error: core::fmt::Debug { @@ -27,7 +27,7 @@ impl Error for core::convert::Infallible { /// free to define more specific or additional error types. However, by providing /// a mapping to these common errors, generic code can still react to them. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] -#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[non_exhaustive] pub enum ErrorKind { /// A different error occurred. The original error may contain more information. @@ -82,7 +82,7 @@ impl ErrorType for &mut T { /// assert_eq!(!state, PinState::High); /// ``` #[derive(Debug, PartialEq, Eq, Clone, Copy)] -#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum PinState { /// Low pin state. Low, diff --git a/embedded-hal/src/i2c.rs b/embedded-hal/src/i2c.rs index 8b99197e..c7b64d57 100644 --- a/embedded-hal/src/i2c.rs +++ b/embedded-hal/src/i2c.rs @@ -163,8 +163,8 @@ use crate::private; -#[cfg(feature = "defmt-03")] -use crate::defmt; +#[cfg(feature = "defmt")] +use defmt; /// I2C error. pub trait Error: core::fmt::Debug { @@ -189,7 +189,7 @@ impl Error for core::convert::Infallible { /// free to define more specific or additional error types. However, by providing /// a mapping to these common I2C errors, generic code can still react to them. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] -#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[non_exhaustive] pub enum ErrorKind { /// Bus error occurred. e.g. A START or a STOP condition is detected and is not @@ -213,7 +213,7 @@ pub enum ErrorKind { /// response was received to an address versus a no acknowledge to a data byte. /// Where it is not possible to differentiate, `Unknown` should be indicated. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] -#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum NoAcknowledgeSource { /// The device did not acknowledge its address. The device may be missing. Address, @@ -303,7 +303,7 @@ impl AddressMode for TenBitAddress {} /// /// Several operations can be combined as part of a transaction. #[derive(Debug, PartialEq, Eq)] -#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Operation<'a> { /// Read data into the provided buffer. Read(&'a mut [u8]), diff --git a/embedded-hal/src/lib.rs b/embedded-hal/src/lib.rs index f5eb76c3..c195bb2a 100644 --- a/embedded-hal/src/lib.rs +++ b/embedded-hal/src/lib.rs @@ -15,7 +15,3 @@ mod private { impl Sealed for SevenBitAddress {} impl Sealed for TenBitAddress {} } - -// needed to prevent defmt macros from breaking, since they emit code that does `defmt::blahblah`. -#[cfg(feature = "defmt-03")] -use defmt_03 as defmt; diff --git a/embedded-hal/src/pwm.rs b/embedded-hal/src/pwm.rs index 4d4ff150..8952b15b 100644 --- a/embedded-hal/src/pwm.rs +++ b/embedded-hal/src/pwm.rs @@ -1,7 +1,7 @@ //! Pulse Width Modulation (PWM) traits. -#[cfg(feature = "defmt-03")] -use crate::defmt; +#[cfg(feature = "defmt")] +use defmt; /// Error pub trait Error: core::fmt::Debug { @@ -26,7 +26,7 @@ impl Error for core::convert::Infallible { /// free to define more specific or additional error types. However, by providing /// a mapping to these common errors, generic code can still react to them. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] -#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[non_exhaustive] pub enum ErrorKind { /// A different error occurred. The original error may contain more information. diff --git a/embedded-hal/src/spi.rs b/embedded-hal/src/spi.rs index 55fc7e9f..9b19d995 100644 --- a/embedded-hal/src/spi.rs +++ b/embedded-hal/src/spi.rs @@ -173,12 +173,12 @@ use core::fmt::Debug; -#[cfg(feature = "defmt-03")] -use crate::defmt; +#[cfg(feature = "defmt")] +use defmt; /// Clock polarity. #[derive(Clone, Copy, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Polarity { /// Clock signal low when idle. IdleLow, @@ -188,7 +188,7 @@ pub enum Polarity { /// Clock phase. #[derive(Clone, Copy, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Phase { /// Data in "captured" on the first clock transition. CaptureOnFirstTransition, @@ -198,7 +198,7 @@ pub enum Phase { /// SPI mode. #[derive(Clone, Copy, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub struct Mode { /// Clock polarity. pub polarity: Polarity, @@ -253,7 +253,7 @@ impl Error for core::convert::Infallible { /// free to define more specific or additional error types. However, by providing /// a mapping to these common SPI errors, generic code can still react to them. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] -#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[non_exhaustive] pub enum ErrorKind { /// The peripheral receive buffer was overrun. @@ -318,7 +318,7 @@ impl ErrorType for &mut T { /// /// This allows composition of SPI operations into a single bus transaction. #[derive(Debug, PartialEq, Eq)] -#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Operation<'a, Word: 'static> { /// Read data into the provided buffer. ///