aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/settings.json8
-rw-r--r--embassy-embedded-hal/Cargo.toml (renamed from embassy-traits/Cargo.toml)7
-rw-r--r--embassy-embedded-hal/src/adapter.rs (renamed from embassy-traits/src/adapter.rs)0
-rw-r--r--embassy-embedded-hal/src/lib.rs (renamed from embassy-traits/src/lib.rs)1
-rw-r--r--embassy-embedded-hal/src/shared_bus/i2c.rs120
-rw-r--r--embassy-embedded-hal/src/shared_bus/mod.rs4
-rw-r--r--embassy-embedded-hal/src/shared_bus/spi.rs110
-rw-r--r--examples/boot/nrf/Cargo.toml2
-rw-r--r--examples/boot/nrf/src/bin/a.rs2
-rw-r--r--examples/boot/stm32f3/Cargo.toml2
-rw-r--r--examples/boot/stm32f3/src/bin/a.rs2
-rw-r--r--examples/boot/stm32f7/Cargo.toml2
-rw-r--r--examples/boot/stm32f7/src/bin/a.rs2
-rw-r--r--examples/boot/stm32h7/Cargo.toml2
-rw-r--r--examples/boot/stm32h7/src/bin/a.rs2
-rw-r--r--examples/boot/stm32l0/Cargo.toml2
-rw-r--r--examples/boot/stm32l0/src/bin/a.rs2
-rw-r--r--examples/boot/stm32l1/Cargo.toml2
-rw-r--r--examples/boot/stm32l1/src/bin/a.rs2
-rw-r--r--examples/boot/stm32l4/Cargo.toml2
-rw-r--r--examples/boot/stm32l4/src/bin/a.rs2
-rw-r--r--examples/boot/stm32wl/Cargo.toml2
-rw-r--r--examples/boot/stm32wl/src/bin/a.rs2
-rw-r--r--examples/stm32l4/Cargo.toml2
-rw-r--r--examples/stm32l4/src/bin/i2c_blocking_async.rs2
-rw-r--r--examples/stm32l4/src/bin/spi_blocking_async.rs2
26 files changed, 262 insertions, 26 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 79433a7c9..5ce8e4e7d 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,15 +1,11 @@
1{ 1{
2 "editor.formatOnSave": true, 2 "editor.formatOnSave": true,
3 "rust-analyzer.assist.importEnforceGranularity": true,
4 "rust-analyzer.assist.importGranularity": "module",
5 "rust-analyzer.checkOnSave.allFeatures": false, 3 "rust-analyzer.checkOnSave.allFeatures": false,
6 "rust-analyzer.checkOnSave.allTargets": false, 4 "rust-analyzer.checkOnSave.allTargets": false,
7 "rust-analyzer.checkOnSave.noDefaultFeatures": true, 5 "rust-analyzer.checkOnSave.noDefaultFeatures": true,
8 "rust-analyzer.cargo.allFeatures": false, 6 "rust-analyzer.cargo.allFeatures": false,
9 "rust-analyzer.cargo.noDefaultFeatures": true, 7 "rust-analyzer.cargo.noDefaultFeatures": true,
10 "rust-analyzer.experimental.procAttrMacros": false,
11 "rust-analyzer.procMacro.enable": true, 8 "rust-analyzer.procMacro.enable": true,
12 "rust-analyzer.cargo.runBuildScripts": true,
13 "rust-analyzer.cargo.target": "thumbv7em-none-eabi", 9 "rust-analyzer.cargo.target": "thumbv7em-none-eabi",
14 "rust-analyzer.cargo.features": [ 10 "rust-analyzer.cargo.features": [
15 // These are needed to prevent embassy-net from failing to build 11 // These are needed to prevent embassy-net from failing to build
@@ -38,4 +34,8 @@
38 // "examples/stm32wl55/Cargo.toml", 34 // "examples/stm32wl55/Cargo.toml",
39 // "examples/wasm/Cargo.toml", 35 // "examples/wasm/Cargo.toml",
40 ], 36 ],
37 "rust-analyzer.imports.granularity.enforce": true,
38 "rust-analyzer.imports.granularity.group": "module",
39 "rust-analyzer.cargo.buildScripts.enable": true,
40 "rust-analyzer.procMacro.attributes.enable": false,
41} \ No newline at end of file 41} \ No newline at end of file
diff --git a/embassy-traits/Cargo.toml b/embassy-embedded-hal/Cargo.toml
index 4e0e7d22d..14b73dce5 100644
--- a/embassy-traits/Cargo.toml
+++ b/embassy-embedded-hal/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2name = "embassy-traits" 2name = "embassy-embedded-hal"
3version = "0.1.0" 3version = "0.1.0"
4authors = ["Dario Nieuwenhuis <[email protected]>"] 4authors = ["Dario Nieuwenhuis <[email protected]>"]
5edition = "2018" 5edition = "2018"
@@ -8,9 +8,10 @@ edition = "2018"
8std = [] 8std = []
9 9
10[dependencies] 10[dependencies]
11embassy = { version = "0.1.0", path = "../embassy" }
11embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } 12embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] }
12embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } 13embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" }
13embedded-hal-async = { version = "0.1.0-alpha.0" } 14embedded-hal-async = { version = "0.1.0-alpha.1" }
14embedded-storage = "0.3.0" 15embedded-storage = "0.3.0"
15embedded-storage-async = "0.3.0" 16embedded-storage-async = "0.3.0"
16nb = "1.0.0" 17nb = "1.0.0" \ No newline at end of file
diff --git a/embassy-traits/src/adapter.rs b/embassy-embedded-hal/src/adapter.rs
index 033efb7ef..033efb7ef 100644
--- a/embassy-traits/src/adapter.rs
+++ b/embassy-embedded-hal/src/adapter.rs
diff --git a/embassy-traits/src/lib.rs b/embassy-embedded-hal/src/lib.rs
index 9c5c367a8..27ffa7421 100644
--- a/embassy-traits/src/lib.rs
+++ b/embassy-embedded-hal/src/lib.rs
@@ -3,3 +3,4 @@
3#![feature(type_alias_impl_trait)] 3#![feature(type_alias_impl_trait)]
4 4
5pub mod adapter; 5pub mod adapter;
6pub mod shared_bus;
diff --git a/embassy-embedded-hal/src/shared_bus/i2c.rs b/embassy-embedded-hal/src/shared_bus/i2c.rs
new file mode 100644
index 000000000..5a180e897
--- /dev/null
+++ b/embassy-embedded-hal/src/shared_bus/i2c.rs
@@ -0,0 +1,120 @@
1//! Asynchronous shared I2C bus
2//!
3//! # Example (nrf52)
4//!
5//! ```rust
6//! use embassy_embedded_hal::shared_bus::i2c::I2cBusDevice;
7//! use embassy::mutex::Mutex;
8//! use embassy::blocking_mutex::raw::ThreadModeRawMutex;
9//!
10//! static I2C_BUS: Forever<Mutex::<ThreadModeRawMutex, Twim<TWISPI0>>> = Forever::new();
11//! let config = twim::Config::default();
12//! let irq = interrupt::take!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0);
13//! let i2c = Twim::new(p.TWISPI0, irq, p.P0_03, p.P0_04, config);
14//! let i2c_bus = Mutex::<ThreadModeRawMutex, _>::new(i2c);
15//! let i2c_bus = I2C_BUS.put(i2c_bus);
16//!
17//! // Device 1, using embedded-hal-async compatible driver for QMC5883L compass
18//! let i2c_dev1 = I2cBusDevice::new(i2c_bus);
19//! let compass = QMC5883L::new(i2c_dev1).await.unwrap();
20//!
21//! // Device 2, using embedded-hal-async compatible driver for Mpu6050 accelerometer
22//! let i2c_dev2 = I2cBusDevice::new(i2c_bus);
23//! let mpu = Mpu6050::new(i2c_dev2);
24//! ```
25use core::{fmt::Debug, future::Future};
26use embassy::blocking_mutex::raw::RawMutex;
27use embassy::mutex::Mutex;
28use embedded_hal_async::i2c;
29
30#[derive(Copy, Clone, Eq, PartialEq, Debug)]
31pub enum I2cBusDeviceError<BUS> {
32 I2c(BUS),
33}
34
35impl<BUS> i2c::Error for I2cBusDeviceError<BUS>
36where
37 BUS: i2c::Error + Debug,
38{
39 fn kind(&self) -> i2c::ErrorKind {
40 match self {
41 Self::I2c(e) => e.kind(),
42 }
43 }
44}
45
46pub struct I2cBusDevice<'a, M: RawMutex, BUS> {
47 bus: &'a Mutex<M, BUS>,
48}
49
50impl<'a, M: RawMutex, BUS> I2cBusDevice<'a, M, BUS> {
51 pub fn new(bus: &'a Mutex<M, BUS>) -> Self {
52 Self { bus }
53 }
54}
55
56impl<'a, M: RawMutex, BUS> i2c::ErrorType for I2cBusDevice<'a, M, BUS>
57where
58 BUS: i2c::ErrorType,
59{
60 type Error = I2cBusDeviceError<BUS::Error>;
61}
62
63impl<M, BUS> i2c::I2c for I2cBusDevice<'_, M, BUS>
64where
65 M: RawMutex + 'static,
66 BUS: i2c::I2c + 'static,
67{
68 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
69
70 fn read<'a>(&'a mut self, address: u8, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> {
71 async move {
72 let mut bus = self.bus.lock().await;
73 bus.read(address, buffer)
74 .await
75 .map_err(I2cBusDeviceError::I2c)?;
76 Ok(())
77 }
78 }
79
80 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
81
82 fn write<'a>(&'a mut self, address: u8, bytes: &'a [u8]) -> Self::WriteFuture<'a> {
83 async move {
84 let mut bus = self.bus.lock().await;
85 bus.write(address, bytes)
86 .await
87 .map_err(I2cBusDeviceError::I2c)?;
88 Ok(())
89 }
90 }
91
92 type WriteReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
93
94 fn write_read<'a>(
95 &'a mut self,
96 address: u8,
97 wr_buffer: &'a [u8],
98 rd_buffer: &'a mut [u8],
99 ) -> Self::WriteReadFuture<'a> {
100 async move {
101 let mut bus = self.bus.lock().await;
102 bus.write_read(address, wr_buffer, rd_buffer)
103 .await
104 .map_err(I2cBusDeviceError::I2c)?;
105 Ok(())
106 }
107 }
108
109 type TransactionFuture<'a, 'b> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a, 'b: 'a;
110
111 fn transaction<'a, 'b>(
112 &'a mut self,
113 address: u8,
114 operations: &'a mut [embedded_hal_async::i2c::Operation<'b>],
115 ) -> Self::TransactionFuture<'a, 'b> {
116 let _ = address;
117 let _ = operations;
118 async move { todo!() }
119 }
120}
diff --git a/embassy-embedded-hal/src/shared_bus/mod.rs b/embassy-embedded-hal/src/shared_bus/mod.rs
new file mode 100644
index 000000000..bd4fd2c31
--- /dev/null
+++ b/embassy-embedded-hal/src/shared_bus/mod.rs
@@ -0,0 +1,4 @@
1//! Shared bus implementations for embedded-hal-async
2
3pub mod i2c;
4pub mod spi;
diff --git a/embassy-embedded-hal/src/shared_bus/spi.rs b/embassy-embedded-hal/src/shared_bus/spi.rs
new file mode 100644
index 000000000..3ec064ba7
--- /dev/null
+++ b/embassy-embedded-hal/src/shared_bus/spi.rs
@@ -0,0 +1,110 @@
1//! Asynchronous shared SPI bus
2//!
3//! # Example (nrf52)
4//!
5//! ```rust
6//! use embassy_embedded_hal::shared_bus::spi::SpiBusDevice;
7//! use embassy::mutex::Mutex;
8//! use embassy::blocking_mutex::raw::ThreadModeRawMutex;
9//!
10//! static SPI_BUS: Forever<Mutex<ThreadModeRawMutex, spim::Spim<SPI3>>> = Forever::new();
11//! let mut config = spim::Config::default();
12//! config.frequency = spim::Frequency::M32;
13//! let irq = interrupt::take!(SPIM3);
14//! let spi = spim::Spim::new_txonly(p.SPI3, irq, p.P0_15, p.P0_18, config);
15//! let spi_bus = Mutex::<ThreadModeRawMutex, _>::new(spi);
16//! let spi_bus = SPI_BUS.put(spi_bus);
17//!
18//! // Device 1, using embedded-hal-async compatible driver for ST7735 LCD display
19//! let cs_pin1 = Output::new(p.P0_24, Level::Low, OutputDrive::Standard);
20//! let spi_dev1 = SpiBusDevice::new(spi_bus, cs_pin1);
21//! let display1 = ST7735::new(spi_dev1, dc1, rst1, Default::default(), 160, 128);
22//!
23//! // Device 2
24//! let cs_pin2 = Output::new(p.P0_24, Level::Low, OutputDrive::Standard);
25//! let spi_dev2 = SpiBusDevice::new(spi_bus, cs_pin2);
26//! let display2 = ST7735::new(spi_dev2, dc2, rst2, Default::default(), 160, 128);
27//! ```
28use core::{fmt::Debug, future::Future};
29use embassy::blocking_mutex::raw::RawMutex;
30use embassy::mutex::Mutex;
31
32use embedded_hal_1::digital::blocking::OutputPin;
33use embedded_hal_1::spi::ErrorType;
34use embedded_hal_async::spi;
35
36#[derive(Copy, Clone, Eq, PartialEq, Debug)]
37pub enum SpiBusDeviceError<BUS, CS> {
38 Spi(BUS),
39 Cs(CS),
40}
41
42impl<BUS, CS> spi::Error for SpiBusDeviceError<BUS, CS>
43where
44 BUS: spi::Error + Debug,
45 CS: Debug,
46{
47 fn kind(&self) -> spi::ErrorKind {
48 match self {
49 Self::Spi(e) => e.kind(),
50 Self::Cs(_) => spi::ErrorKind::Other,
51 }
52 }
53}
54
55pub struct SpiBusDevice<'a, M: RawMutex, BUS, CS> {
56 bus: &'a Mutex<M, BUS>,
57 cs: CS,
58}
59
60impl<'a, M: RawMutex, BUS, CS> SpiBusDevice<'a, M, BUS, CS> {
61 pub fn new(bus: &'a Mutex<M, BUS>, cs: CS) -> Self {
62 Self { bus, cs }
63 }
64}
65
66impl<'a, M: RawMutex, BUS, CS> spi::ErrorType for SpiBusDevice<'a, M, BUS, CS>
67where
68 BUS: spi::ErrorType,
69 CS: OutputPin,
70{
71 type Error = SpiBusDeviceError<BUS::Error, CS::Error>;
72}
73
74impl<M, BUS, CS> spi::SpiDevice for SpiBusDevice<'_, M, BUS, CS>
75where
76 M: RawMutex + 'static,
77 BUS: spi::SpiBusFlush + 'static,
78 CS: OutputPin,
79{
80 type Bus = BUS;
81
82 type TransactionFuture<'a, R, F, Fut> = impl Future<Output = Result<R, Self::Error>> + 'a
83 where
84 Self: 'a, R: 'a, F: FnOnce(*mut Self::Bus) -> Fut + 'a,
85 Fut: Future<Output = Result<R, <Self::Bus as ErrorType>::Error>> + 'a;
86
87 fn transaction<'a, R, F, Fut>(&'a mut self, f: F) -> Self::TransactionFuture<'a, R, F, Fut>
88 where
89 R: 'a,
90 F: FnOnce(*mut Self::Bus) -> Fut + 'a,
91 Fut: Future<Output = Result<R, <Self::Bus as ErrorType>::Error>> + 'a,
92 {
93 async move {
94 let mut bus = self.bus.lock().await;
95 self.cs.set_low().map_err(SpiBusDeviceError::Cs)?;
96
97 let f_res = f(&mut *bus).await;
98
99 // On failure, it's important to still flush and deassert CS.
100 let flush_res = bus.flush().await;
101 let cs_res = self.cs.set_high();
102
103 let f_res = f_res.map_err(SpiBusDeviceError::Spi)?;
104 flush_res.map_err(SpiBusDeviceError::Spi)?;
105 cs_res.map_err(SpiBusDeviceError::Cs)?;
106
107 Ok(f_res)
108 }
109 }
110}
diff --git a/examples/boot/nrf/Cargo.toml b/examples/boot/nrf/Cargo.toml
index da8333b7c..42bc35430 100644
--- a/examples/boot/nrf/Cargo.toml
+++ b/examples/boot/nrf/Cargo.toml
@@ -8,7 +8,7 @@ version = "0.1.0"
8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] } 8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] }
9embassy-nrf = { version = "0.1.0", path = "../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly", "nrf52840"] } 9embassy-nrf = { version = "0.1.0", path = "../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly", "nrf52840"] }
10embassy-boot-nrf = { version = "0.1.0", path = "../../../embassy-boot/nrf" } 10embassy-boot-nrf = { version = "0.1.0", path = "../../../embassy-boot/nrf" }
11embassy-traits = { version = "0.1.0", path = "../../../embassy-traits" } 11embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" }
12 12
13defmt = { version = "0.3", optional = true } 13defmt = { version = "0.3", optional = true }
14defmt-rtt = { version = "0.3", optional = true } 14defmt-rtt = { version = "0.3", optional = true }
diff --git a/examples/boot/nrf/src/bin/a.rs b/examples/boot/nrf/src/bin/a.rs
index 7368e36ce..d45d0ff34 100644
--- a/examples/boot/nrf/src/bin/a.rs
+++ b/examples/boot/nrf/src/bin/a.rs
@@ -5,13 +5,13 @@
5#![feature(type_alias_impl_trait)] 5#![feature(type_alias_impl_trait)]
6 6
7use embassy_boot_nrf::FirmwareUpdater; 7use embassy_boot_nrf::FirmwareUpdater;
8use embassy_embedded_hal::adapter::BlockingAsync;
8use embassy_nrf::{ 9use embassy_nrf::{
9 gpio::{Input, Pull}, 10 gpio::{Input, Pull},
10 gpio::{Level, Output, OutputDrive}, 11 gpio::{Level, Output, OutputDrive},
11 nvmc::Nvmc, 12 nvmc::Nvmc,
12 Peripherals, 13 Peripherals,
13}; 14};
14use embassy_traits::adapter::BlockingAsync;
15use panic_reset as _; 15use panic_reset as _;
16 16
17static APP_B: &[u8] = include_bytes!("../../b.bin"); 17static APP_B: &[u8] = include_bytes!("../../b.bin");
diff --git a/examples/boot/stm32f3/Cargo.toml b/examples/boot/stm32f3/Cargo.toml
index d4ca600f8..fab6fd723 100644
--- a/examples/boot/stm32f3/Cargo.toml
+++ b/examples/boot/stm32f3/Cargo.toml
@@ -8,7 +8,7 @@ version = "0.1.0"
8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] } 8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] }
9embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] } 9embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] }
10embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" } 10embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" }
11embassy-traits = { version = "0.1.0", path = "../../../embassy-traits" } 11embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" }
12 12
13defmt = { version = "0.3", optional = true } 13defmt = { version = "0.3", optional = true }
14defmt-rtt = { version = "0.3", optional = true } 14defmt-rtt = { version = "0.3", optional = true }
diff --git a/examples/boot/stm32f3/src/bin/a.rs b/examples/boot/stm32f3/src/bin/a.rs
index db9262f43..9ad798389 100644
--- a/examples/boot/stm32f3/src/bin/a.rs
+++ b/examples/boot/stm32f3/src/bin/a.rs
@@ -3,11 +3,11 @@
3#![feature(type_alias_impl_trait)] 3#![feature(type_alias_impl_trait)]
4 4
5use embassy_boot_stm32::FirmwareUpdater; 5use embassy_boot_stm32::FirmwareUpdater;
6use embassy_embedded_hal::adapter::BlockingAsync;
6use embassy_stm32::exti::ExtiInput; 7use embassy_stm32::exti::ExtiInput;
7use embassy_stm32::flash::Flash; 8use embassy_stm32::flash::Flash;
8use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 9use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
9use embassy_stm32::Peripherals; 10use embassy_stm32::Peripherals;
10use embassy_traits::adapter::BlockingAsync;
11use panic_reset as _; 11use panic_reset as _;
12 12
13#[cfg(feature = "defmt-rtt")] 13#[cfg(feature = "defmt-rtt")]
diff --git a/examples/boot/stm32f7/Cargo.toml b/examples/boot/stm32f7/Cargo.toml
index 857b287d5..14500b198 100644
--- a/examples/boot/stm32f7/Cargo.toml
+++ b/examples/boot/stm32f7/Cargo.toml
@@ -8,7 +8,7 @@ version = "0.1.0"
8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] } 8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] }
9embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] } 9embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] }
10embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" } 10embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" }
11embassy-traits = { version = "0.1.0", path = "../../../embassy-traits" } 11embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" }
12 12
13defmt = { version = "0.3", optional = true } 13defmt = { version = "0.3", optional = true }
14defmt-rtt = { version = "0.3", optional = true } 14defmt-rtt = { version = "0.3", optional = true }
diff --git a/examples/boot/stm32f7/src/bin/a.rs b/examples/boot/stm32f7/src/bin/a.rs
index ca154f0af..b4f49d579 100644
--- a/examples/boot/stm32f7/src/bin/a.rs
+++ b/examples/boot/stm32f7/src/bin/a.rs
@@ -3,11 +3,11 @@
3#![feature(type_alias_impl_trait)] 3#![feature(type_alias_impl_trait)]
4 4
5use embassy_boot_stm32::FirmwareUpdater; 5use embassy_boot_stm32::FirmwareUpdater;
6use embassy_embedded_hal::adapter::BlockingAsync;
6use embassy_stm32::exti::ExtiInput; 7use embassy_stm32::exti::ExtiInput;
7use embassy_stm32::flash::Flash; 8use embassy_stm32::flash::Flash;
8use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 9use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
9use embassy_stm32::Peripherals; 10use embassy_stm32::Peripherals;
10use embassy_traits::adapter::BlockingAsync;
11use panic_reset as _; 11use panic_reset as _;
12 12
13#[cfg(feature = "defmt-rtt")] 13#[cfg(feature = "defmt-rtt")]
diff --git a/examples/boot/stm32h7/Cargo.toml b/examples/boot/stm32h7/Cargo.toml
index 1fd03906f..3069277ed 100644
--- a/examples/boot/stm32h7/Cargo.toml
+++ b/examples/boot/stm32h7/Cargo.toml
@@ -8,7 +8,7 @@ version = "0.1.0"
8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] } 8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] }
9embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] } 9embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] }
10embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" } 10embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" }
11embassy-traits = { version = "0.1.0", path = "../../../embassy-traits" } 11embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" }
12 12
13defmt = { version = "0.3", optional = true } 13defmt = { version = "0.3", optional = true }
14defmt-rtt = { version = "0.3", optional = true } 14defmt-rtt = { version = "0.3", optional = true }
diff --git a/examples/boot/stm32h7/src/bin/a.rs b/examples/boot/stm32h7/src/bin/a.rs
index 1f23a8bc2..1d196e8a5 100644
--- a/examples/boot/stm32h7/src/bin/a.rs
+++ b/examples/boot/stm32h7/src/bin/a.rs
@@ -3,11 +3,11 @@
3#![feature(type_alias_impl_trait)] 3#![feature(type_alias_impl_trait)]
4 4
5use embassy_boot_stm32::FirmwareUpdater; 5use embassy_boot_stm32::FirmwareUpdater;
6use embassy_embedded_hal::adapter::BlockingAsync;
6use embassy_stm32::exti::ExtiInput; 7use embassy_stm32::exti::ExtiInput;
7use embassy_stm32::flash::Flash; 8use embassy_stm32::flash::Flash;
8use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 9use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
9use embassy_stm32::Peripherals; 10use embassy_stm32::Peripherals;
10use embassy_traits::adapter::BlockingAsync;
11use panic_reset as _; 11use panic_reset as _;
12 12
13#[cfg(feature = "defmt-rtt")] 13#[cfg(feature = "defmt-rtt")]
diff --git a/examples/boot/stm32l0/Cargo.toml b/examples/boot/stm32l0/Cargo.toml
index 5cb1add5b..13ca84367 100644
--- a/examples/boot/stm32l0/Cargo.toml
+++ b/examples/boot/stm32l0/Cargo.toml
@@ -8,7 +8,7 @@ version = "0.1.0"
8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] } 8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] }
9embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } 9embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] }
10embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32", features = ["thumbv6"] } 10embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32", features = ["thumbv6"] }
11embassy-traits = { version = "0.1.0", path = "../../../embassy-traits" } 11embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" }
12 12
13defmt = { version = "0.3", optional = true } 13defmt = { version = "0.3", optional = true }
14defmt-rtt = { version = "0.3", optional = true } 14defmt-rtt = { version = "0.3", optional = true }
diff --git a/examples/boot/stm32l0/src/bin/a.rs b/examples/boot/stm32l0/src/bin/a.rs
index 9e603a226..d4b252bf0 100644
--- a/examples/boot/stm32l0/src/bin/a.rs
+++ b/examples/boot/stm32l0/src/bin/a.rs
@@ -4,11 +4,11 @@
4 4
5use embassy::time::{Duration, Timer}; 5use embassy::time::{Duration, Timer};
6use embassy_boot_stm32::FirmwareUpdater; 6use embassy_boot_stm32::FirmwareUpdater;
7use embassy_embedded_hal::adapter::BlockingAsync;
7use embassy_stm32::exti::ExtiInput; 8use embassy_stm32::exti::ExtiInput;
8use embassy_stm32::flash::Flash; 9use embassy_stm32::flash::Flash;
9use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 10use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
10use embassy_stm32::Peripherals; 11use embassy_stm32::Peripherals;
11use embassy_traits::adapter::BlockingAsync;
12use panic_reset as _; 12use panic_reset as _;
13 13
14#[cfg(feature = "defmt-rtt")] 14#[cfg(feature = "defmt-rtt")]
diff --git a/examples/boot/stm32l1/Cargo.toml b/examples/boot/stm32l1/Cargo.toml
index 9f97462f6..b0b6e3d25 100644
--- a/examples/boot/stm32l1/Cargo.toml
+++ b/examples/boot/stm32l1/Cargo.toml
@@ -8,7 +8,7 @@ version = "0.1.0"
8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] } 8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] }
9embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] } 9embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] }
10embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" } 10embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" }
11embassy-traits = { version = "0.1.0", path = "../../../embassy-traits" } 11embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" }
12 12
13defmt = { version = "0.3", optional = true } 13defmt = { version = "0.3", optional = true }
14defmt-rtt = { version = "0.3", optional = true } 14defmt-rtt = { version = "0.3", optional = true }
diff --git a/examples/boot/stm32l1/src/bin/a.rs b/examples/boot/stm32l1/src/bin/a.rs
index 9e603a226..d4b252bf0 100644
--- a/examples/boot/stm32l1/src/bin/a.rs
+++ b/examples/boot/stm32l1/src/bin/a.rs
@@ -4,11 +4,11 @@
4 4
5use embassy::time::{Duration, Timer}; 5use embassy::time::{Duration, Timer};
6use embassy_boot_stm32::FirmwareUpdater; 6use embassy_boot_stm32::FirmwareUpdater;
7use embassy_embedded_hal::adapter::BlockingAsync;
7use embassy_stm32::exti::ExtiInput; 8use embassy_stm32::exti::ExtiInput;
8use embassy_stm32::flash::Flash; 9use embassy_stm32::flash::Flash;
9use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 10use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
10use embassy_stm32::Peripherals; 11use embassy_stm32::Peripherals;
11use embassy_traits::adapter::BlockingAsync;
12use panic_reset as _; 12use panic_reset as _;
13 13
14#[cfg(feature = "defmt-rtt")] 14#[cfg(feature = "defmt-rtt")]
diff --git a/examples/boot/stm32l4/Cargo.toml b/examples/boot/stm32l4/Cargo.toml
index 53424a666..705dbd0d6 100644
--- a/examples/boot/stm32l4/Cargo.toml
+++ b/examples/boot/stm32l4/Cargo.toml
@@ -8,7 +8,7 @@ version = "0.1.0"
8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] } 8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] }
9embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] } 9embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] }
10embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" } 10embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" }
11embassy-traits = { version = "0.1.0", path = "../../../embassy-traits" } 11embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" }
12 12
13defmt = { version = "0.3", optional = true } 13defmt = { version = "0.3", optional = true }
14defmt-rtt = { version = "0.3", optional = true } 14defmt-rtt = { version = "0.3", optional = true }
diff --git a/examples/boot/stm32l4/src/bin/a.rs b/examples/boot/stm32l4/src/bin/a.rs
index 41684b2f0..23b1d98bb 100644
--- a/examples/boot/stm32l4/src/bin/a.rs
+++ b/examples/boot/stm32l4/src/bin/a.rs
@@ -3,11 +3,11 @@
3#![feature(type_alias_impl_trait)] 3#![feature(type_alias_impl_trait)]
4 4
5use embassy_boot_stm32::FirmwareUpdater; 5use embassy_boot_stm32::FirmwareUpdater;
6use embassy_embedded_hal::adapter::BlockingAsync;
6use embassy_stm32::exti::ExtiInput; 7use embassy_stm32::exti::ExtiInput;
7use embassy_stm32::flash::Flash; 8use embassy_stm32::flash::Flash;
8use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 9use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
9use embassy_stm32::Peripherals; 10use embassy_stm32::Peripherals;
10use embassy_traits::adapter::BlockingAsync;
11use panic_reset as _; 11use panic_reset as _;
12 12
13#[cfg(feature = "defmt-rtt")] 13#[cfg(feature = "defmt-rtt")]
diff --git a/examples/boot/stm32wl/Cargo.toml b/examples/boot/stm32wl/Cargo.toml
index fb64886e6..41e6a112e 100644
--- a/examples/boot/stm32wl/Cargo.toml
+++ b/examples/boot/stm32wl/Cargo.toml
@@ -8,7 +8,7 @@ version = "0.1.0"
8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] } 8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] }
9embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] } 9embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] }
10embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" } 10embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" }
11embassy-traits = { version = "0.1.0", path = "../../../embassy-traits" } 11embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" }
12 12
13defmt = { version = "0.3", optional = true } 13defmt = { version = "0.3", optional = true }
14defmt-rtt = { version = "0.3", optional = true } 14defmt-rtt = { version = "0.3", optional = true }
diff --git a/examples/boot/stm32wl/src/bin/a.rs b/examples/boot/stm32wl/src/bin/a.rs
index b3e9efa75..1089eff1e 100644
--- a/examples/boot/stm32wl/src/bin/a.rs
+++ b/examples/boot/stm32wl/src/bin/a.rs
@@ -3,11 +3,11 @@
3#![feature(type_alias_impl_trait)] 3#![feature(type_alias_impl_trait)]
4 4
5use embassy_boot_stm32::FirmwareUpdater; 5use embassy_boot_stm32::FirmwareUpdater;
6use embassy_embedded_hal::adapter::BlockingAsync;
6use embassy_stm32::exti::ExtiInput; 7use embassy_stm32::exti::ExtiInput;
7use embassy_stm32::flash::Flash; 8use embassy_stm32::flash::Flash;
8use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 9use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
9use embassy_stm32::Peripherals; 10use embassy_stm32::Peripherals;
10use embassy_traits::adapter::BlockingAsync;
11use panic_reset as _; 11use panic_reset as _;
12 12
13#[cfg(feature = "defmt-rtt")] 13#[cfg(feature = "defmt-rtt")]
diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml
index b3478f74e..afea5a5aa 100644
--- a/examples/stm32l4/Cargo.toml
+++ b/examples/stm32l4/Cargo.toml
@@ -9,7 +9,7 @@ resolver = "2"
9 9
10[dependencies] 10[dependencies]
11embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } 11embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] }
12embassy-traits = { version = "0.1.0", path = "../../embassy-traits" } 12embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" }
13embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l4s5vi", "time-driver-any", "exti", "unstable-traits"] } 13embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l4s5vi", "time-driver-any", "exti", "unstable-traits"] }
14 14
15defmt = "0.3" 15defmt = "0.3"
diff --git a/examples/stm32l4/src/bin/i2c_blocking_async.rs b/examples/stm32l4/src/bin/i2c_blocking_async.rs
index 136aea849..eb74223b0 100644
--- a/examples/stm32l4/src/bin/i2c_blocking_async.rs
+++ b/examples/stm32l4/src/bin/i2c_blocking_async.rs
@@ -7,12 +7,12 @@ use panic_probe as _;
7 7
8use defmt::*; 8use defmt::*;
9use embassy::executor::Spawner; 9use embassy::executor::Spawner;
10use embassy_embedded_hal::adapter::BlockingAsync;
10use embassy_stm32::dma::NoDma; 11use embassy_stm32::dma::NoDma;
11use embassy_stm32::i2c::I2c; 12use embassy_stm32::i2c::I2c;
12use embassy_stm32::interrupt; 13use embassy_stm32::interrupt;
13use embassy_stm32::time::Hertz; 14use embassy_stm32::time::Hertz;
14use embassy_stm32::Peripherals; 15use embassy_stm32::Peripherals;
15use embassy_traits::adapter::BlockingAsync;
16use embedded_hal_async::i2c::I2c as I2cTrait; 16use embedded_hal_async::i2c::I2c as I2cTrait;
17 17
18const ADDRESS: u8 = 0x5F; 18const ADDRESS: u8 = 0x5F;
diff --git a/examples/stm32l4/src/bin/spi_blocking_async.rs b/examples/stm32l4/src/bin/spi_blocking_async.rs
index 0398965d3..e1a400107 100644
--- a/examples/stm32l4/src/bin/spi_blocking_async.rs
+++ b/examples/stm32l4/src/bin/spi_blocking_async.rs
@@ -7,12 +7,12 @@ use panic_probe as _;
7 7
8use defmt::*; 8use defmt::*;
9use embassy::executor::Spawner; 9use embassy::executor::Spawner;
10use embassy_embedded_hal::adapter::BlockingAsync;
10use embassy_stm32::dma::NoDma; 11use embassy_stm32::dma::NoDma;
11use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 12use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
12use embassy_stm32::spi::{Config, Spi}; 13use embassy_stm32::spi::{Config, Spi};
13use embassy_stm32::time::Hertz; 14use embassy_stm32::time::Hertz;
14use embassy_stm32::Peripherals; 15use embassy_stm32::Peripherals;
15use embassy_traits::adapter::BlockingAsync;
16use embedded_hal_async::spi::SpiBus; 16use embedded_hal_async::spi::SpiBus;
17 17
18#[embassy::main] 18#[embassy::main]