Skip to content

Commit b7b916f

Browse files
authored
Remove most trait implementation features from esp-hal (#2070)
* Eliminate esp-hal's `ufmt` feature * Eliminate esp-hal's `embedded-hal-02` feature * Eliminate esp-hal's `embedded-hal` feature * Eliminate esp-hal's `embedded-io` feature * Eliminate esp-hal's `async` feature * Update `CHANGELOG.md` * Remove `async` from required features for HIL tests * Update migration guide
1 parent 49e14b7 commit b7b916f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+78
-297
lines changed

esp-hal/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
### Removed
2222

2323
- Removed `NoPinType` in favour of `DummyPin`. (#2068)
24+
- Removed the `async`, `embedded-hal-02`, `embedded-hal`, `embedded-io`, `embedded-io-async`, and `ufmt` features (#2070)
2425

2526
## [0.20.1] - 2024-08-30
2627

esp-hal/Cargo.toml

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ links = "esp-hal"
1111

1212
[package.metadata.docs.rs]
1313
default-target = "riscv32imac-unknown-none-elf"
14-
features = ["embedded-hal", "esp32c6"]
14+
features = ["esp32c6"]
1515
rustdoc-args = ["--cfg", "docsrs"]
1616

1717
[dependencies]
@@ -24,17 +24,17 @@ defmt = { version = "0.3.8", optional = true }
2424
delegate = "0.12.0"
2525
digest = { version = "0.10.7", default-features = false, optional = true }
2626
document-features = "0.2.10"
27-
embassy-futures = { version = "0.1.1", optional = true }
28-
embassy-sync = { version = "0.6.0", optional = true }
27+
embassy-futures = "0.1.1"
28+
embassy-sync = "0.6.0"
2929
embassy-usb-driver = { version = "0.1.0", optional = true }
3030
embassy-usb-synopsys-otg = { version = "0.1.0", optional = true }
31-
embedded-can = { version = "0.4.1", optional = true }
32-
embedded-hal-02 = { version = "0.2.7", optional = true, features = ["unproven"], package = "embedded-hal" }
33-
embedded-hal = { version = "1.0.0", optional = true }
34-
embedded-hal-async = { version = "1.0.0", optional = true }
35-
embedded-hal-nb = { version = "1.0.0", optional = true }
36-
embedded-io = { version = "0.6.1", optional = true }
37-
embedded-io-async = { version = "0.6.1", optional = true }
31+
embedded-can = "0.4.1"
32+
embedded-hal-02 = { version = "0.2.7", features = ["unproven"], package = "embedded-hal" }
33+
embedded-hal = "1.0.0"
34+
embedded-hal-async = "1.0.0"
35+
embedded-hal-nb = "1.0.0"
36+
embedded-io = "0.6.1"
37+
embedded-io-async = "0.6.1"
3838
enumset = "1.1.5"
3939
esp-synopsys-usb-otg = { version = "0.4.2", optional = true, features = ["fs", "esp32sx"] }
4040
fugit = "0.3.7"
@@ -48,7 +48,7 @@ strum = { version = "0.26.3", default-features = false, featu
4848
void = { version = "1.0.2", default-features = false }
4949
usb-device = { version = "0.3.2", optional = true }
5050
rand_core = "0.6.4"
51-
ufmt-write = { version = "0.1.0", optional = true }
51+
ufmt-write = "0.1.0"
5252
xtensa-lx = { version = "0.9.0", optional = true }
5353

5454
# IMPORTANT:
@@ -76,14 +76,14 @@ esp-metadata = { version = "0.3.0", path = "../esp-metadata" }
7676
serde = { version = "1.0.209", features = ["derive"] }
7777

7878
[features]
79-
default = ["embedded-hal"]
79+
default = []
8080

8181
riscv = ["dep:riscv", "critical-section/restore-state-u8"]
8282
xtensa = ["dep:xtensa-lx", "critical-section/restore-state-u32"]
8383

8484
bluetooth = []
8585

86-
usb-otg = ["esp-synopsys-usb-otg", "usb-device"]
86+
usb-otg = ["dep:embassy-usb-driver", "dep:embassy-usb-synopsys-otg", "dep:esp-synopsys-usb-otg", "dep:usb-device"]
8787

8888
__esp_hal_embassy = []
8989

@@ -124,27 +124,14 @@ esp32s3 = ["dep:esp32s3", "xtensa", "procmacros/has-ulp-core", "xtensa-lx/spin",
124124
flip-link = ["esp-riscv-rt/fix-sp"]
125125

126126
#! ### Trait Implementation Feature Flags
127-
## Enable support for asynchronous operation, with interfaces provided by
128-
## `embedded-hal-async` and `embedded-io-async`.
129-
## Also enables `embassy-usb` support for ESP32-S2 and ESP32-S3.
130-
async = [
131-
"embedded-hal",
132-
"embedded-hal-async",
133-
"embedded-io",
134-
"embedded-io-async",
135-
"embassy-sync",
136-
"embassy-futures",
137-
"embassy-usb-driver",
138-
"embassy-usb-synopsys-otg"
139-
]
140127
## Implement `defmt::Format` on certain types.
141128
defmt = [
142129
"dep:defmt",
143-
"embassy-futures?/defmt",
144-
"embassy-sync?/defmt",
145-
"embedded-hal?/defmt-03",
130+
"embassy-futures/defmt",
131+
"embassy-sync/defmt",
132+
"embedded-hal/defmt-03",
146133
"embedded-io/defmt-03",
147-
"embedded-io-async?/defmt-03",
134+
"embedded-io-async/defmt-03",
148135
"esp32?/defmt",
149136
"esp32c2?/defmt",
150137
"esp32c3?/defmt",
@@ -153,15 +140,6 @@ defmt = [
153140
"esp32s2?/defmt",
154141
"esp32s3?/defmt",
155142
]
156-
## Implement the traits defined in the `1.0.0` releases of `embedded-hal` and
157-
## `embedded-hal-nb` for the relevant peripherals.
158-
embedded-hal = ["dep:embedded-hal", "dep:embedded-hal-nb", "dep:embedded-can"]
159-
## Implement the traits defined in the `0.2.x` release of `embedded-hal`.
160-
embedded-hal-02 = ["dep:embedded-hal-02"]
161-
## Implement the traits defined in `embedded-io` for certain peripherals.
162-
embedded-io = ["dep:embedded-io"]
163-
## Implement the `ufmt_write::uWrite` trait for certain peripherals.
164-
ufmt = ["dep:ufmt-write"]
165143

166144
#! ### PSRAM Feature Flags
167145
## Use externally connected PSRAM (2MB).
@@ -184,7 +162,7 @@ opsram-8m = []
184162
opsram-16m = []
185163

186164
# This feature is intended for testing; you probably don't want to enable it:
187-
ci = ["async", "embedded-hal-02", "embedded-io", "ufmt", "defmt", "bluetooth", "place-spi-driver-in-ram"]
165+
ci = ["defmt", "bluetooth", "place-spi-driver-in-ram"]
188166

189167
[lints.clippy]
190168
mixed_attributes_style = "allow"

esp-hal/MIGRATING-0.20.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
Migration Guide from 0.20.x to vNext
2-
====================================
1+
# Migration Guide from 0.20.x to vNext
32

4-
HAL initialsation
5-
-----------------
3+
## Cargo Features
4+
5+
A number of trait implementations which were previously feature-gated are now implemented by default. The following Cargo features have been removed:
6+
7+
- `async`
8+
- `embedded-hal-02`
9+
- `embedded-hal`
10+
- `embedded-io`
11+
- `embedded-io-async`
12+
- `ufmt`
13+
14+
If your project enables any of these features, simply remove them from your Cargo manifest and things should continue to work as expected.
15+
16+
## HAL Initialisation
617

718
Instead of manually grabbing peripherals and setting up clocks, you should now call `esp_hal::init`.
819

@@ -13,7 +24,7 @@ Instead of manually grabbing peripherals and setting up clocks, you should now c
1324
prelude::*,
1425
- system::SystemControl,
1526
};
16-
27+
1728
#[entry]
1829
fn main() -> ! {
1930
- let peripherals = Peripherals::take();

esp-hal/src/analog/adc/esp32.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ impl<'d, ADC1> Adc<'d, ADC1> {
343343
}
344344
}
345345

346-
#[cfg(feature = "embedded-hal-02")]
347346
impl<'d, ADCI, PIN> embedded_hal_02::adc::OneShot<ADCI, u16, super::AdcPin<PIN, ADCI>>
348347
for Adc<'d, ADCI>
349348
where

esp-hal/src/analog/adc/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ pub struct AdcPin<PIN, ADCI, CS = ()> {
110110
_phantom: PhantomData<ADCI>,
111111
}
112112

113-
#[cfg(feature = "embedded-hal-02")]
114113
impl<PIN, ADCI, CS> embedded_hal_02::adc::Channel<ADCI> for AdcPin<PIN, ADCI, CS>
115114
where
116115
PIN: embedded_hal_02::adc::Channel<ADCI, ID = u8>,
@@ -260,7 +259,6 @@ macro_rules! impl_adc_interface {
260259
const CHANNEL: u8 = $channel;
261260
}
262261

263-
#[cfg(feature = "embedded-hal-02")]
264262
impl embedded_hal_02::adc::Channel<crate::peripherals::$adc> for crate::gpio::$pin {
265263
type ID = u8;
266264

esp-hal/src/analog/adc/riscv.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ impl super::AdcCalEfuse for crate::peripherals::ADC2 {
530530
}
531531
}
532532

533-
#[cfg(feature = "embedded-hal-02")]
534533
impl<'d, ADCI, PIN, CS> embedded_hal_02::adc::OneShot<ADCI, u16, super::AdcPin<PIN, ADCI, CS>>
535534
for Adc<'d, ADCI>
536535
where

esp-hal/src/analog/adc/xtensa.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,6 @@ impl super::AdcCalEfuse for crate::peripherals::ADC2 {
590590
}
591591
}
592592

593-
#[cfg(feature = "embedded-hal-02")]
594593
impl<'d, ADCI, PIN, CS> embedded_hal_02::adc::OneShot<ADCI, u16, AdcPin<PIN, ADCI, CS>>
595594
for Adc<'d, ADCI>
596595
where

esp-hal/src/delay.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ use crate::clock::Clocks;
4545
#[non_exhaustive]
4646
pub struct Delay;
4747

48-
#[cfg(feature = "embedded-hal-02")]
4948
impl<T> embedded_hal_02::blocking::delay::DelayMs<T> for Delay
5049
where
5150
T: Into<u32>,
@@ -55,7 +54,6 @@ where
5554
}
5655
}
5756

58-
#[cfg(feature = "embedded-hal-02")]
5957
impl<T> embedded_hal_02::blocking::delay::DelayUs<T> for Delay
6058
where
6159
T: Into<u32>,
@@ -65,7 +63,6 @@ where
6563
}
6664
}
6765

68-
#[cfg(feature = "embedded-hal")]
6966
impl embedded_hal::delay::DelayNs for Delay {
7067
fn delay_ns(&mut self, ns: u32) {
7168
self.delay_nanos(ns);

esp-hal/src/dma/gdma.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -420,23 +420,18 @@ impl<const N: u8> RegisterAccess for Channel<N> {
420420
#[doc(hidden)]
421421
pub struct ChannelTxImpl<const N: u8> {}
422422

423-
#[cfg(feature = "async")]
424423
use embassy_sync::waitqueue::AtomicWaker;
425424

426-
#[cfg(feature = "async")]
427425
#[allow(clippy::declare_interior_mutable_const)]
428426
const INIT: AtomicWaker = AtomicWaker::new();
429427

430-
#[cfg(feature = "async")]
431428
static TX_WAKERS: [AtomicWaker; CHANNEL_COUNT] = [INIT; CHANNEL_COUNT];
432429

433-
#[cfg(feature = "async")]
434430
static RX_WAKERS: [AtomicWaker; CHANNEL_COUNT] = [INIT; CHANNEL_COUNT];
435431

436432
impl<const N: u8> crate::private::Sealed for ChannelTxImpl<N> {}
437433

438434
impl<const N: u8> TxChannel<Channel<N>> for ChannelTxImpl<N> {
439-
#[cfg(feature = "async")]
440435
fn waker() -> &'static AtomicWaker {
441436
&TX_WAKERS[N as usize]
442437
}
@@ -449,7 +444,6 @@ pub struct ChannelRxImpl<const N: u8> {}
449444
impl<const N: u8> crate::private::Sealed for ChannelRxImpl<N> {}
450445

451446
impl<const N: u8> RxChannel<Channel<N>> for ChannelRxImpl<N> {
452-
#[cfg(feature = "async")]
453447
fn waker() -> &'static AtomicWaker {
454448
&RX_WAKERS[N as usize]
455449
}
@@ -551,7 +545,6 @@ macro_rules! impl_channel {
551545
///
552546
/// Descriptors should be sized as `(CHUNK_SIZE + 4091) / 4092`. I.e., to
553547
/// transfer buffers of size `1..=4092`, you need 1 descriptor.
554-
#[cfg(feature = "async")]
555548
pub fn configure_for_async<'a>(
556549
self,
557550
burst_mode: bool,
@@ -578,23 +571,19 @@ macro_rules! impl_channel {
578571

579572
cfg_if::cfg_if! {
580573
if #[cfg(esp32c2)] {
581-
#[cfg(feature = "async")]
582574
const CHANNEL_COUNT: usize = 1;
583575
impl_channel!(0, super::asynch::interrupt::interrupt_handler_ch0, DMA_CH0);
584576
} else if #[cfg(esp32c3)] {
585-
#[cfg(feature = "async")]
586577
const CHANNEL_COUNT: usize = 3;
587578
impl_channel!(0, super::asynch::interrupt::interrupt_handler_ch0, DMA_CH0);
588579
impl_channel!(1, super::asynch::interrupt::interrupt_handler_ch1, DMA_CH1);
589580
impl_channel!(2, super::asynch::interrupt::interrupt_handler_ch2, DMA_CH2);
590581
} else if #[cfg(any(esp32c6, esp32h2))] {
591-
#[cfg(feature = "async")]
592582
const CHANNEL_COUNT: usize = 3;
593583
impl_channel!(0, super::asynch::interrupt::interrupt_handler_ch0, DMA_IN_CH0, DMA_OUT_CH0);
594584
impl_channel!(1, super::asynch::interrupt::interrupt_handler_ch1, DMA_IN_CH1, DMA_OUT_CH1);
595585
impl_channel!(2, super::asynch::interrupt::interrupt_handler_ch2, DMA_IN_CH2, DMA_OUT_CH2);
596586
} else if #[cfg(esp32s3)] {
597-
#[cfg(feature = "async")]
598587
const CHANNEL_COUNT: usize = 5;
599588
impl_channel!(0, super::asynch::interrupt::interrupt_handler_ch0, DMA_IN_CH0, DMA_OUT_CH0);
600589
impl_channel!(1, super::asynch::interrupt::interrupt_handler_ch1, DMA_IN_CH1, DMA_OUT_CH1);

esp-hal/src/dma/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,6 @@ pub trait RxPrivate: crate::private::Sealed {
12491249

12501250
fn clear_interrupts(&self);
12511251

1252-
#[cfg(feature = "async")]
12531252
fn waker() -> &'static embassy_sync::waitqueue::AtomicWaker;
12541253
}
12551254

@@ -1296,7 +1295,6 @@ where
12961295
R::is_in_done()
12971296
}
12981297

1299-
#[cfg(feature = "async")]
13001298
fn waker() -> &'static embassy_sync::waitqueue::AtomicWaker;
13011299
}
13021300

@@ -1494,7 +1492,6 @@ where
14941492
CH::Channel::clear_in_interrupts();
14951493
}
14961494

1497-
#[cfg(feature = "async")]
14981495
fn waker() -> &'static embassy_sync::waitqueue::AtomicWaker {
14991496
CH::Rx::waker()
15001497
}
@@ -1552,7 +1549,6 @@ pub trait TxPrivate: crate::private::Sealed {
15521549

15531550
fn clear_interrupts(&self);
15541551

1555-
#[cfg(feature = "async")]
15561552
fn waker() -> &'static embassy_sync::waitqueue::AtomicWaker;
15571553

15581554
fn descriptors_handled(&self) -> bool;
@@ -1633,7 +1629,6 @@ where
16331629
R::last_out_dscr_address()
16341630
}
16351631

1636-
#[cfg(feature = "async")]
16371632
fn waker() -> &'static embassy_sync::waitqueue::AtomicWaker;
16381633
}
16391634

@@ -1759,7 +1754,6 @@ where
17591754
CH::Channel::has_out_descriptor_error()
17601755
}
17611756

1762-
#[cfg(feature = "async")]
17631757
fn waker() -> &'static embassy_sync::waitqueue::AtomicWaker {
17641758
CH::Tx::waker()
17651759
}
@@ -2762,7 +2756,6 @@ where
27622756
}
27632757
}
27642758

2765-
#[cfg(feature = "async")]
27662759
pub(crate) mod asynch {
27672760
use core::task::Poll;
27682761

0 commit comments

Comments
 (0)