aboutsummaryrefslogtreecommitdiff
path: root/embassy-embedded-hal
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-embedded-hal')
-rw-r--r--embassy-embedded-hal/Cargo.toml10
-rw-r--r--embassy-embedded-hal/build.rs18
-rw-r--r--embassy-embedded-hal/src/flash/concat_flash.rs3
-rw-r--r--embassy-embedded-hal/src/flash/mem_flash.rs3
-rw-r--r--embassy-embedded-hal/src/flash/partition/mod.rs2
-rw-r--r--embassy-embedded-hal/src/lib.rs8
-rw-r--r--embassy-embedded-hal/src/shared_bus/asynch/i2c.rs13
-rw-r--r--embassy-embedded-hal/src/shared_bus/asynch/spi.rs11
-rw-r--r--embassy-embedded-hal/src/shared_bus/mod.rs2
9 files changed, 36 insertions, 34 deletions
diff --git a/embassy-embedded-hal/Cargo.toml b/embassy-embedded-hal/Cargo.toml
index 52ecd5c71..db4dc9587 100644
--- a/embassy-embedded-hal/Cargo.toml
+++ b/embassy-embedded-hal/Cargo.toml
@@ -8,27 +8,25 @@ license = "MIT OR Apache-2.0"
8[package.metadata.embassy_docs] 8[package.metadata.embassy_docs]
9src_base = "https://github.com/embassy-rs/embassy/blob/embassy-embedded-hal-v$VERSION/embassy-embedded-hal/src/" 9src_base = "https://github.com/embassy-rs/embassy/blob/embassy-embedded-hal-v$VERSION/embassy-embedded-hal/src/"
10src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-embedded-hal/src/" 10src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-embedded-hal/src/"
11features = ["nightly", "std"] 11features = ["std"]
12target = "x86_64-unknown-linux-gnu" 12target = "x86_64-unknown-linux-gnu"
13 13
14[features] 14[features]
15std = [] 15std = []
16# Enable nightly-only features
17nightly = ["embassy-futures", "embedded-hal-async", "embedded-storage-async"]
18time = ["dep:embassy-time"] 16time = ["dep:embassy-time"]
19default = ["time"] 17default = ["time"]
20 18
21[dependencies] 19[dependencies]
22embassy-futures = { version = "0.1.0", path = "../embassy-futures", optional = true } 20embassy-futures = { version = "0.1.0", path = "../embassy-futures" }
23embassy-sync = { version = "0.4.0", path = "../embassy-sync" } 21embassy-sync = { version = "0.4.0", path = "../embassy-sync" }
24embassy-time = { version = "0.1.5", path = "../embassy-time", optional = true } 22embassy-time = { version = "0.1.5", path = "../embassy-time", optional = true }
25embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = [ 23embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = [
26 "unproven", 24 "unproven",
27] } 25] }
28embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } 26embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" }
29embedded-hal-async = { version = "=1.0.0-rc.2", optional = true } 27embedded-hal-async = { version = "=1.0.0-rc.2" }
30embedded-storage = "0.3.0" 28embedded-storage = "0.3.0"
31embedded-storage-async = { version = "0.4.0", optional = true } 29embedded-storage-async = { version = "0.4.0" }
32nb = "1.0.0" 30nb = "1.0.0"
33 31
34defmt = { version = "0.3", optional = true } 32defmt = { version = "0.3", optional = true }
diff --git a/embassy-embedded-hal/build.rs b/embassy-embedded-hal/build.rs
new file mode 100644
index 000000000..78bd27ec7
--- /dev/null
+++ b/embassy-embedded-hal/build.rs
@@ -0,0 +1,18 @@
1use std::env;
2use std::ffi::OsString;
3use std::process::Command;
4
5fn main() {
6 println!("cargo:rerun-if-changed=build.rs");
7
8 let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc"));
9
10 let output = Command::new(rustc)
11 .arg("--version")
12 .output()
13 .expect("failed to run `rustc --version`");
14
15 if String::from_utf8_lossy(&output.stdout).contains("nightly") {
16 println!("cargo:rustc-cfg=nightly");
17 }
18}
diff --git a/embassy-embedded-hal/src/flash/concat_flash.rs b/embassy-embedded-hal/src/flash/concat_flash.rs
index 1ea84269c..499941d19 100644
--- a/embassy-embedded-hal/src/flash/concat_flash.rs
+++ b/embassy-embedded-hal/src/flash/concat_flash.rs
@@ -1,5 +1,4 @@
1use embedded_storage::nor_flash::{ErrorType, NorFlash, NorFlashError, ReadNorFlash}; 1use embedded_storage::nor_flash::{ErrorType, NorFlash, NorFlashError, ReadNorFlash};
2#[cfg(feature = "nightly")]
3use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash}; 2use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash};
4 3
5/// Convenience helper for concatenating two consecutive flashes into one. 4/// Convenience helper for concatenating two consecutive flashes into one.
@@ -117,7 +116,6 @@ where
117 } 116 }
118} 117}
119 118
120#[cfg(feature = "nightly")]
121impl<First, Second, E> AsyncReadNorFlash for ConcatFlash<First, Second> 119impl<First, Second, E> AsyncReadNorFlash for ConcatFlash<First, Second>
122where 120where
123 First: AsyncReadNorFlash<Error = E>, 121 First: AsyncReadNorFlash<Error = E>,
@@ -146,7 +144,6 @@ where
146 } 144 }
147} 145}
148 146
149#[cfg(feature = "nightly")]
150impl<First, Second, E> AsyncNorFlash for ConcatFlash<First, Second> 147impl<First, Second, E> AsyncNorFlash for ConcatFlash<First, Second>
151where 148where
152 First: AsyncNorFlash<Error = E>, 149 First: AsyncNorFlash<Error = E>,
diff --git a/embassy-embedded-hal/src/flash/mem_flash.rs b/embassy-embedded-hal/src/flash/mem_flash.rs
index afb0d1a15..d24c61823 100644
--- a/embassy-embedded-hal/src/flash/mem_flash.rs
+++ b/embassy-embedded-hal/src/flash/mem_flash.rs
@@ -1,7 +1,6 @@
1use alloc::vec::Vec; 1use alloc::vec::Vec;
2 2
3use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; 3use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash};
4#[cfg(feature = "nightly")]
5use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash}; 4use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash};
6 5
7extern crate alloc; 6extern crate alloc;
@@ -93,7 +92,6 @@ impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> NorFla
93 } 92 }
94} 93}
95 94
96#[cfg(feature = "nightly")]
97impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> AsyncReadNorFlash 95impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> AsyncReadNorFlash
98 for MemFlash<SIZE, ERASE_SIZE, WRITE_SIZE> 96 for MemFlash<SIZE, ERASE_SIZE, WRITE_SIZE>
99{ 97{
@@ -109,7 +107,6 @@ impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> AsyncR
109 } 107 }
110} 108}
111 109
112#[cfg(feature = "nightly")]
113impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> AsyncNorFlash 110impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> AsyncNorFlash
114 for MemFlash<SIZE, ERASE_SIZE, WRITE_SIZE> 111 for MemFlash<SIZE, ERASE_SIZE, WRITE_SIZE>
115{ 112{
diff --git a/embassy-embedded-hal/src/flash/partition/mod.rs b/embassy-embedded-hal/src/flash/partition/mod.rs
index 42c8a308d..6177ed9ab 100644
--- a/embassy-embedded-hal/src/flash/partition/mod.rs
+++ b/embassy-embedded-hal/src/flash/partition/mod.rs
@@ -2,11 +2,9 @@
2 2
3use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind}; 3use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind};
4 4
5#[cfg(feature = "nightly")]
6mod asynch; 5mod asynch;
7mod blocking; 6mod blocking;
8 7
9#[cfg(feature = "nightly")]
10pub use asynch::Partition; 8pub use asynch::Partition;
11pub use blocking::BlockingPartition; 9pub use blocking::BlockingPartition;
12 10
diff --git a/embassy-embedded-hal/src/lib.rs b/embassy-embedded-hal/src/lib.rs
index ce5fac3f0..b40f892f4 100644
--- a/embassy-embedded-hal/src/lib.rs
+++ b/embassy-embedded-hal/src/lib.rs
@@ -1,15 +1,13 @@
1#![cfg_attr(not(feature = "std"), no_std)] 1#![cfg_attr(not(feature = "std"), no_std)]
2#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections))] 2#![cfg_attr(nightly, feature(async_fn_in_trait, impl_trait_projections))]
3#![cfg_attr(feature = "nightly", allow(stable_features, unknown_lints, async_fn_in_trait))] 3#![cfg_attr(nightly, allow(stable_features, unknown_lints))]
4#![allow(async_fn_in_trait)]
4#![warn(missing_docs)] 5#![warn(missing_docs)]
5 6
6//! Utilities to use `embedded-hal` traits with Embassy. 7//! Utilities to use `embedded-hal` traits with Embassy.
7 8
8#[cfg(feature = "nightly")]
9pub mod adapter; 9pub mod adapter;
10
11pub mod flash; 10pub mod flash;
12
13pub mod shared_bus; 11pub mod shared_bus;
14 12
15/// Set the configuration of a peripheral driver. 13/// Set the configuration of a peripheral driver.
diff --git a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs
index 1053d3849..779c04263 100644
--- a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs
+++ b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs
@@ -2,16 +2,15 @@
2//! 2//!
3//! # Example (nrf52) 3//! # Example (nrf52)
4//! 4//!
5//! ```rust 5//! ```rust,ignore
6//! use embassy_embedded_hal::shared_bus::i2c::I2cDevice; 6//! use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice;
7//! use embassy_sync::mutex::Mutex; 7//! use embassy_sync::mutex::Mutex;
8//! use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; 8//! use embassy_sync::blocking_mutex::raw::NoopRawMutex;
9//! 9//!
10//! static I2C_BUS: StaticCell<Mutex::<ThreadModeRawMutex, Twim<TWISPI0>>> = StaticCell::new(); 10//! static I2C_BUS: StaticCell<Mutex<NoopRawMutex, Twim<TWISPI0>>> = StaticCell::new();
11//! let config = twim::Config::default(); 11//! let config = twim::Config::default();
12//! let irq = interrupt::take!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0); 12//! let i2c = Twim::new(p.TWISPI0, Irqs, p.P0_03, p.P0_04, config);
13//! let i2c = Twim::new(p.TWISPI0, irq, p.P0_03, p.P0_04, config); 13//! let i2c_bus = Mutex::new(i2c);
14//! let i2c_bus = Mutex::<ThreadModeRawMutex, _>::new(i2c);
15//! let i2c_bus = I2C_BUS.init(i2c_bus); 14//! let i2c_bus = I2C_BUS.init(i2c_bus);
16//! 15//!
17//! // Device 1, using embedded-hal-async compatible driver for QMC5883L compass 16//! // Device 1, using embedded-hal-async compatible driver for QMC5883L compass
diff --git a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs
index b4f53c623..62b2c92a0 100644
--- a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs
+++ b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs
@@ -2,17 +2,16 @@
2//! 2//!
3//! # Example (nrf52) 3//! # Example (nrf52)
4//! 4//!
5//! ```rust 5//! ```rust,ignore
6//! use embassy_embedded_hal::shared_bus::spi::SpiDevice; 6//! use embassy_embedded_hal::shared_bus::spi::SpiDevice;
7//! use embassy_sync::mutex::Mutex; 7//! use embassy_sync::mutex::Mutex;
8//! use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; 8//! use embassy_sync::blocking_mutex::raw::NoopRawMutex;
9//! 9//!
10//! static SPI_BUS: StaticCell<Mutex<ThreadModeRawMutex, spim::Spim<SPI3>>> = StaticCell::new(); 10//! static SPI_BUS: StaticCell<Mutex<NoopRawMutex, spim::Spim<SPI3>>> = StaticCell::new();
11//! let mut config = spim::Config::default(); 11//! let mut config = spim::Config::default();
12//! config.frequency = spim::Frequency::M32; 12//! config.frequency = spim::Frequency::M32;
13//! let irq = interrupt::take!(SPIM3); 13//! let spi = spim::Spim::new_txonly(p.SPI3, Irqs, p.P0_15, p.P0_18, config);
14//! let spi = spim::Spim::new_txonly(p.SPI3, irq, p.P0_15, p.P0_18, config); 14//! let spi_bus = Mutex::new(spi);
15//! let spi_bus = Mutex::<ThreadModeRawMutex, _>::new(spi);
16//! let spi_bus = SPI_BUS.init(spi_bus); 15//! let spi_bus = SPI_BUS.init(spi_bus);
17//! 16//!
18//! // Device 1, using embedded-hal-async compatible driver for ST7735 LCD display 17//! // Device 1, using embedded-hal-async compatible driver for ST7735 LCD display
diff --git a/embassy-embedded-hal/src/shared_bus/mod.rs b/embassy-embedded-hal/src/shared_bus/mod.rs
index ab96df134..d835306bc 100644
--- a/embassy-embedded-hal/src/shared_bus/mod.rs
+++ b/embassy-embedded-hal/src/shared_bus/mod.rs
@@ -3,9 +3,7 @@ use core::fmt::Debug;
3 3
4use embedded_hal_1::{i2c, spi}; 4use embedded_hal_1::{i2c, spi};
5 5
6#[cfg(feature = "nightly")]
7pub mod asynch; 6pub mod asynch;
8
9pub mod blocking; 7pub mod blocking;
10 8
11/// Error returned by I2C device implementations in this crate. 9/// Error returned by I2C device implementations in this crate.