Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions embedded-hal-async/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
4 changes: 2 additions & 2 deletions embedded-hal-bus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ 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 = []

[dependencies]
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]
Expand Down
4 changes: 2 additions & 2 deletions embedded-hal-bus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#![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;
#[cfg(feature = "defmt")]
use defmt;

pub mod i2c;
pub mod spi;
Expand Down
6 changes: 3 additions & 3 deletions embedded-hal-bus/src/spi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ pub use rc::*;

pub use self::critical_section::*;

#[cfg(feature = "defmt-03")]
#[cfg(feature = "defmt")]
use crate::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<BUS, CS> {
/// An inner SPI bus operation failed.
Spi(BUS),
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions embedded-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
6 changes: 3 additions & 3 deletions embedded-hal/src/digital.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use core::ops::Not;

#[cfg(feature = "defmt-03")]
#[cfg(feature = "defmt")]
use crate::defmt;

/// Error.
Expand All @@ -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.
Expand Down Expand Up @@ -82,7 +82,7 @@ impl<T: ErrorType + ?Sized> 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,
Expand Down
8 changes: 4 additions & 4 deletions embedded-hal/src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@

use crate::private;

#[cfg(feature = "defmt-03")]
#[cfg(feature = "defmt")]
use crate::defmt;

/// I2C error.
Expand All @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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]),
Expand Down
4 changes: 2 additions & 2 deletions embedded-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ mod private {
}

// needed to prevent defmt macros from breaking, since they emit code that does `defmt::blahblah`.
#[cfg(feature = "defmt-03")]
use defmt_03 as defmt;
#[cfg(feature = "defmt")]
use defmt;
4 changes: 2 additions & 2 deletions embedded-hal/src/pwm.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Pulse Width Modulation (PWM) traits.

#[cfg(feature = "defmt-03")]
#[cfg(feature = "defmt")]
use crate::defmt;

/// Error
Expand All @@ -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.
Expand Down
12 changes: 6 additions & 6 deletions embedded-hal/src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@

use core::fmt::Debug;

#[cfg(feature = "defmt-03")]
#[cfg(feature = "defmt")]
use crate::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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -318,7 +318,7 @@ impl<T: ErrorType + ?Sized> 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.
///
Expand Down
Loading