Skip to content

Commit 4e88e48

Browse files
authored
Remove unnecessary rt crate dependencies (#391)
* Remove unnecessary `rt` crate dependencies * Bump versions, update to latest released dependencies
1 parent df891b4 commit 4e88e48

File tree

173 files changed

+261
-640
lines changed

Some content is hidden

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

173 files changed

+261
-640
lines changed

esp-hal-common/Cargo.toml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "esp-hal-common"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
authors = [
55
"Jesse Braham <[email protected]>",
66
"Björn Quentin <[email protected]>",
@@ -24,7 +24,7 @@ fugit = "0.3.6"
2424
lock_api = { version = "0.4.9", optional = true }
2525
nb = "1.0.0"
2626
paste = "1.0.11"
27-
procmacros = { version = "0.2.0", package = "esp-hal-procmacros", path = "../esp-hal-procmacros" }
27+
procmacros = { version = "0.3.0", package = "esp-hal-procmacros", path = "../esp-hal-procmacros" }
2828
strum = { version = "0.24.1", default-features = false, features = ["derive"] }
2929
void = { version = "1.0.2", default-features = false }
3030
usb-device = { version = "0.2.9", optional = true }
@@ -40,8 +40,8 @@ esp-riscv-rt = { version = "0.1.0", optional = true }
4040
riscv-atomic-emulation-trap = { version = "0.4.0", optional = true }
4141

4242
# Xtensa
43-
xtensa-lx = { version = "0.7.0", optional = true }
44-
xtensa-lx-rt = { version = "0.14.0", optional = true }
43+
xtensa-lx = { version = "0.8.0", optional = true }
44+
xtensa-lx-rt = { version = "0.15.0", optional = true }
4545

4646
# Smart-LED (e.g., WS2812/SK68XX) support
4747
smart-leds-trait = { version = "0.2.1", optional = true }
@@ -53,18 +53,18 @@ ufmt-write = { version = "0.1.0", optional = true }
5353
# Each supported device MUST have its PAC included below along with a
5454
# corresponding feature. We rename the PAC packages because we cannot
5555
# have dependencies and features with the same names.
56-
esp32 = { version = "0.19.0", features = ["critical-section"], optional = true }
57-
esp32c2 = { version = "0.7.0", features = ["critical-section"], optional = true }
58-
esp32c3 = { version = "0.10.0", features = ["critical-section"], optional = true }
59-
esp32s2 = { version = "0.10.0", features = ["critical-section"], optional = true }
60-
esp32s3 = { version = "0.13.0", features = ["critical-section"], optional = true }
56+
esp32 = { version = "0.21.0", features = ["critical-section"], optional = true }
57+
esp32c2 = { version = "0.8.0", features = ["critical-section"], optional = true }
58+
esp32c3 = { version = "0.11.0", features = ["critical-section"], optional = true }
59+
esp32s2 = { version = "0.12.0", features = ["critical-section"], optional = true }
60+
esp32s3 = { version = "0.15.0", features = ["critical-section"], optional = true }
6161

6262
[features]
63-
esp32 = ["esp32/rt" , "xtensa", "xtensa-lx/esp32", "xtensa-lx-rt/esp32", "lock_api"]
64-
esp32c2 = ["esp32c2/rt", "riscv"]
65-
esp32c3 = ["esp32c3/rt", "riscv"]
66-
esp32s2 = ["esp32s2/rt", "xtensa", "xtensa-lx/esp32s2", "xtensa-lx-rt/esp32s2", "esp-synopsys-usb-otg", "usb-device"]
67-
esp32s3 = ["esp32s3/rt", "xtensa", "xtensa-lx/esp32s3", "xtensa-lx-rt/esp32s3", "lock_api", "esp-synopsys-usb-otg", "usb-device"]
63+
esp32 = ["esp32/rt" , "xtensa", "xtensa-lx/esp32", "xtensa-lx-rt/esp32", "lock_api", "procmacros/esp32"]
64+
esp32c2 = ["esp32c2/rt", "riscv", "procmacros/esp32c2"]
65+
esp32c3 = ["esp32c3/rt", "riscv", "procmacros/esp32c3"]
66+
esp32s2 = ["esp32s2/rt", "xtensa", "xtensa-lx/esp32s2", "xtensa-lx-rt/esp32s2", "esp-synopsys-usb-otg", "usb-device", "procmacros/esp32s2"]
67+
esp32s3 = ["esp32s3/rt", "xtensa", "xtensa-lx/esp32s3", "xtensa-lx-rt/esp32s3", "lock_api", "esp-synopsys-usb-otg", "usb-device", "procmacros/esp32s3"]
6868

6969
esp32c2_40mhz = []
7070
esp32c2_26mhz = []

esp-hal-common/src/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,27 @@
3131
#[cfg_attr(esp32s3, path = "peripherals/esp32s3.rs")]
3232
pub mod peripherals;
3333

34+
#[cfg(riscv)]
35+
pub use esp_riscv_rt;
36+
#[cfg(riscv)]
37+
pub use esp_riscv_rt::entry;
38+
#[cfg(riscv)]
39+
pub use esp_riscv_rt::riscv;
3440
pub use procmacros as macros;
41+
#[cfg(xtensa)]
42+
pub use xtensa_lx;
43+
#[cfg(xtensa)]
44+
pub use xtensa_lx_rt;
45+
#[cfg(xtensa)]
46+
pub use xtensa_lx_rt::entry;
47+
48+
/// State of the CPU saved when entering exception or interrupt
49+
pub mod trapframe {
50+
#[cfg(riscv)]
51+
pub use esp_riscv_rt::TrapFrame;
52+
#[cfg(xtensa)]
53+
pub use xtensa_lx_rt::exception::Context as TrapFrame;
54+
}
3555

3656
#[cfg(rmt)]
3757
pub use self::pulse_control::PulseControl;

esp-hal-common/src/prelude.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub use crate::{
3737
DmaTransfer as _esp_hal_dma_DmaTransfer,
3838
DmaTransferRxTx as _esp_hal_dma_DmaTransferRxTx,
3939
},
40+
entry,
4041
gpio::{
4142
InputPin as _esp_hal_gpio_InputPin,
4243
OutputPin as _esp_hal_gpio_OutputPin,

esp-hal-procmacros/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "esp-hal-procmacros"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
authors = [
55
"Jesse Braham <[email protected]>",
66
"Björn Quentin <[email protected]>",
@@ -20,9 +20,15 @@ proc-macro-error = "1.0.4"
2020
proc-macro2 = "1.0.50"
2121
quote = "1.0.23"
2222
syn = {version = "1.0.107", features = ["extra-traits", "full"]}
23+
proc-macro-crate = "1.3.0"
2324

2425
[features]
2526
interrupt = []
2627
riscv = []
2728
rtc_slow = []
2829
xtensa = []
30+
esp32 = []
31+
esp32c2 = []
32+
esp32c3 = []
33+
esp32s2 = []
34+
esp32s3 = []

esp-hal-procmacros/src/lib.rs

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ pub fn ram(args: TokenStream, input: TokenStream) -> TokenStream {
134134
#[cfg(feature = "interrupt")]
135135
#[proc_macro_attribute]
136136
pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
137+
use proc_macro_crate::{crate_name, FoundCrate};
138+
137139
let mut f: ItemFn = syn::parse(input).expect("`#[interrupt]` must be applied to a function");
138140

139141
let attr_args = parse_macro_input!(args as AttributeArgs);
@@ -200,10 +202,46 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
200202
&format!("__esp_hal_internal_{}", f.sig.ident),
201203
proc_macro2::Span::call_site(),
202204
);
205+
206+
#[cfg(feature = "esp32")]
207+
let hal_crate = crate_name("esp32-hal");
208+
#[cfg(feature = "esp32s2")]
209+
let hal_crate = crate_name("esp32s2-hal");
210+
#[cfg(feature = "esp32s3")]
211+
let hal_crate = crate_name("esp32s3-hal");
212+
#[cfg(feature = "esp32c2")]
213+
let hal_crate = crate_name("esp32c2-hal");
214+
#[cfg(feature = "esp32c3")]
215+
let hal_crate = crate_name("esp32c3-hal");
216+
217+
#[cfg(feature = "esp32")]
218+
let hal_crate_name = Ident::new("esp32_hal", Span::call_site().into());
219+
#[cfg(feature = "esp32s2")]
220+
let hal_crate_name = Ident::new("esp32s2_hal", Span::call_site().into());
221+
#[cfg(feature = "esp32s3")]
222+
let hal_crate_name = Ident::new("esp32s3_hal", Span::call_site().into());
223+
#[cfg(feature = "esp32c2")]
224+
let hal_crate_name = Ident::new("esp32c2_hal", Span::call_site().into());
225+
#[cfg(feature = "esp32c3")]
226+
let hal_crate_name = Ident::new("esp32c3_hal", Span::call_site().into());
227+
228+
let interrupt_in_hal_crate = match hal_crate {
229+
Ok(FoundCrate::Itself) => {
230+
quote!( #hal_crate_name::peripherals::Interrupt::#ident_s )
231+
}
232+
Ok(FoundCrate::Name(ref name)) => {
233+
let ident = Ident::new(&name, Span::call_site().into());
234+
quote!( #ident::peripherals::Interrupt::#ident_s )
235+
}
236+
Err(_) => {
237+
quote!( crate::peripherals::Interrupt::#ident_s )
238+
}
239+
};
240+
203241
f.block.stmts.extend(std::iter::once(
204242
syn::parse2(quote! {{
205243
// Check that this interrupt actually exists
206-
crate::peripherals::Interrupt::#ident_s;
244+
#interrupt_in_hal_crate;
207245
}})
208246
.unwrap(),
209247
));
@@ -218,25 +256,34 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
218256

219257
let export_name = ident_s.to_string();
220258

221-
#[cfg(feature = "xtensa")]
222-
let context = quote! {
223-
xtensa_lx_rt::exception::Context
224-
};
225-
226-
#[cfg(feature = "riscv")]
227-
let context = quote! {
228-
crate::interrupt::TrapFrame
259+
let trap_frame_in_hal_crate = match hal_crate {
260+
Ok(FoundCrate::Itself) => {
261+
quote!(#hal_crate_name::trapframe::TrapFrame)
262+
}
263+
Ok(FoundCrate::Name(ref name)) => {
264+
let ident = Ident::new(&name, Span::call_site().into());
265+
quote!( #ident::trapframe::TrapFrame )
266+
}
267+
Err(_) => {
268+
quote!(crate::trapframe::TrapFrame)
269+
}
229270
};
230271

231272
let context_call =
232273
(f.sig.inputs.len() == 1).then(|| Ident::new("context", proc_macro2::Span::call_site()));
233274

234275
quote!(
276+
macro_rules! foo {
277+
() => {
278+
};
279+
}
280+
foo!();
281+
235282
#(#cfgs)*
236283
#(#attrs)*
237284
#[doc(hidden)]
238285
#[export_name = #export_name]
239-
pub unsafe extern "C" fn #tramp_ident(context: &mut #context) {
286+
pub unsafe extern "C" fn #tramp_ident(context: &mut #trap_frame_in_hal_crate) {
240287
#ident(
241288
#context_call
242289
)

esp32-hal/Cargo.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "esp32-hal"
3-
version = "0.8.0"
3+
version = "0.9.0"
44
authors = [
55
"Jesse Braham <[email protected]>",
66
"Björn Quentin <[email protected]>",
@@ -30,15 +30,13 @@ embedded-hal = { version = "0.2.7", features = ["unproven"] }
3030
embedded-hal-1 = { version = "=1.0.0-alpha.9", optional = true, package = "embedded-hal" }
3131
embedded-hal-async = { version = "0.2.0-alpha.0", optional = true }
3232
embedded-hal-nb = { version = "=1.0.0-alpha.1", optional = true }
33-
esp-hal-common = { version = "0.5.0", features = ["esp32"], path = "../esp-hal-common" }
34-
xtensa-lx = { version = "0.7.0", features = ["esp32"] }
35-
xtensa-lx-rt = { version = "0.14.0", features = ["esp32"], optional = true }
33+
esp-hal-common = { version = "0.6.0", features = ["esp32"], path = "../esp-hal-common" }
3634

3735
[dev-dependencies]
3836
critical-section = "1.1.1"
3937
embassy-executor = { package = "embassy-executor", git = "https://github.com/embassy-rs/embassy/", rev = "cd9a65b", features = ["nightly", "integrated-timers"] }
4038
embedded-graphics = "0.7.1"
41-
esp-backtrace = { version = "0.4.0", features = ["esp32", "panic-handler", "exception-handler", "print-uart"] }
39+
esp-backtrace = { version = "0.5.0", features = ["esp32", "panic-handler", "exception-handler", "print-uart"] }
4240
esp-println = { version = "0.3.1", features = ["esp32"] }
4341
sha2 = { version = "0.10.6", default-features = false}
4442
smart-leds = "0.3.0"
@@ -50,7 +48,7 @@ aes = "0.8.2"
5048
default = ["rt", "vectored"]
5149
bluetooth = []
5250
eh1 = ["esp-hal-common/eh1", "dep:embedded-hal-1", "dep:embedded-hal-nb"]
53-
rt = ["xtensa-lx-rt/esp32"]
51+
rt = []
5452
smartled = ["esp-hal-common/smartled"]
5553
ufmt = ["esp-hal-common/ufmt"]
5654
vectored = ["esp-hal-common/vectored"]

esp32-hal/examples/adc.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use esp32_hal::{
1717
};
1818
use esp_backtrace as _;
1919
use esp_println::println;
20-
use xtensa_lx_rt::entry;
2120

2221
#[entry]
2322
fn main() -> ! {

esp32-hal/examples/advanced_serial.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use esp32_hal::{
2323
use esp_backtrace as _;
2424
use esp_println::println;
2525
use nb::block;
26-
use xtensa_lx_rt::entry;
2726

2827
#[entry]
2928
fn main() -> ! {

esp32-hal/examples/aes.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ use esp32_hal::{
1010
peripherals::Peripherals,
1111
prelude::*,
1212
timer::TimerGroup,
13+
xtensa_lx,
1314
Rtc,
1415
};
1516
use esp_backtrace as _;
1617
use esp_println::println;
1718

18-
#[xtensa_lx_rt::entry]
19+
#[entry]
1920
fn main() -> ! {
2021
let peripherals = Peripherals::take();
2122
let mut system = peripherals.DPORT.split();

esp32-hal/examples/blinky.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use esp32_hal::{
1515
Rtc,
1616
};
1717
use esp_backtrace as _;
18-
use xtensa_lx_rt::entry;
1918

2019
#[entry]
2120
fn main() -> ! {

esp32-hal/examples/blinky_erased_pins.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use esp32_hal::{
1515
Rtc,
1616
};
1717
use esp_backtrace as _;
18-
use xtensa_lx_rt::entry;
1918

2019
#[entry]
2120
fn main() -> ! {

esp32-hal/examples/clock_monitor.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use esp32_hal::{
1616
Rtc,
1717
};
1818
use esp_backtrace as _;
19-
use xtensa_lx_rt::entry;
2019

2120
static RTC: Mutex<RefCell<Option<Rtc>>> = Mutex::new(RefCell::new(None));
2221

esp32-hal/examples/dac.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use esp32_hal::{
1616
Rtc,
1717
};
1818
use esp_backtrace as _;
19-
use xtensa_lx_rt::entry;
2019

2120
#[entry]
2221
fn main() -> ! {

esp32-hal/examples/embassy_hello_world.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async fn run2() {
3838

3939
static EXECUTOR: StaticCell<Executor> = StaticCell::new();
4040

41-
#[xtensa_lx_rt::entry]
41+
#[entry]
4242
fn main() -> ! {
4343
esp_println::println!("Init!");
4444
let peripherals = Peripherals::take();

esp32-hal/examples/embassy_spi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async fn spi_task(spi: &'static mut SpiType<'static>) {
5757

5858
static EXECUTOR: StaticCell<Executor> = StaticCell::new();
5959

60-
#[xtensa_lx_rt::entry]
60+
#[entry]
6161
fn main() -> ! {
6262
esp_println::println!("Init!");
6363
let peripherals = Peripherals::take();

esp32-hal/examples/embassy_wait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async fn ping(mut pin: Gpio0<Input<PullDown>>) {
3434

3535
static EXECUTOR: StaticCell<Executor> = StaticCell::new();
3636

37-
#[xtensa_lx_rt::entry]
37+
#[entry]
3838
fn main() -> ! {
3939
esp_println::println!("Init!");
4040
let peripherals = Peripherals::take();

esp32-hal/examples/gpio_interrupt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ use esp32_hal::{
1717
peripherals::{self, Peripherals},
1818
prelude::*,
1919
timer::TimerGroup,
20+
xtensa_lx,
2021
Delay,
2122
Rtc,
2223
};
2324
use esp_backtrace as _;
24-
use xtensa_lx_rt::entry;
2525

2626
static BUTTON: Mutex<RefCell<Option<Gpio0<Input<PullDown>>>>> = Mutex::new(RefCell::new(None));
2727

esp32-hal/examples/hello_rgb.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ use smart_leds::{
3232
hsv::{hsv2rgb, Hsv},
3333
SmartLedsWrite,
3434
};
35-
use xtensa_lx_rt::entry;
3635

3736
#[entry]
3837
fn main() -> ! {

esp32-hal/examples/hello_world.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use esp32_hal::{
1616
};
1717
use esp_backtrace as _;
1818
use nb::block;
19-
use xtensa_lx_rt::entry;
2019

2120
#[entry]
2221
fn main() -> ! {

esp32-hal/examples/i2c_bmp180_calibration_data.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use esp32_hal::{
2020
};
2121
use esp_backtrace as _;
2222
use esp_println::println;
23-
use xtensa_lx_rt::entry;
2423

2524
#[entry]
2625
fn main() -> ! {

esp32-hal/examples/i2c_display.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use esp32_hal::{
3131
use esp_backtrace as _;
3232
use nb::block;
3333
use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306};
34-
use xtensa_lx_rt::entry;
3534

3635
#[entry]
3736
fn main() -> ! {

esp32-hal/examples/i2s_read.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use esp32_hal::{
2626
};
2727
use esp_backtrace as _;
2828
use esp_println::println;
29-
use xtensa_lx_rt::entry;
3029

3130
#[entry]
3231
fn main() -> ! {

0 commit comments

Comments
 (0)