Skip to content

Commit

Permalink
Remove unnecessary rt crate dependencies (#391)
Browse files Browse the repository at this point in the history
* Remove unnecessary `rt` crate dependencies

* Bump versions, update to latest released dependencies
  • Loading branch information
bjoernQ authored Feb 10, 2023
1 parent df891b4 commit 4e88e48
Show file tree
Hide file tree
Showing 173 changed files with 261 additions and 640 deletions.
28 changes: 14 additions & 14 deletions esp-hal-common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "esp-hal-common"
version = "0.5.0"
version = "0.6.0"
authors = [
"Jesse Braham <[email protected]>",
"Björn Quentin <[email protected]>",
Expand All @@ -24,7 +24,7 @@ fugit = "0.3.6"
lock_api = { version = "0.4.9", optional = true }
nb = "1.0.0"
paste = "1.0.11"
procmacros = { version = "0.2.0", package = "esp-hal-procmacros", path = "../esp-hal-procmacros" }
procmacros = { version = "0.3.0", package = "esp-hal-procmacros", path = "../esp-hal-procmacros" }
strum = { version = "0.24.1", default-features = false, features = ["derive"] }
void = { version = "1.0.2", default-features = false }
usb-device = { version = "0.2.9", optional = true }
Expand All @@ -40,8 +40,8 @@ esp-riscv-rt = { version = "0.1.0", optional = true }
riscv-atomic-emulation-trap = { version = "0.4.0", optional = true }

# Xtensa
xtensa-lx = { version = "0.7.0", optional = true }
xtensa-lx-rt = { version = "0.14.0", optional = true }
xtensa-lx = { version = "0.8.0", optional = true }
xtensa-lx-rt = { version = "0.15.0", optional = true }

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

[features]
esp32 = ["esp32/rt" , "xtensa", "xtensa-lx/esp32", "xtensa-lx-rt/esp32", "lock_api"]
esp32c2 = ["esp32c2/rt", "riscv"]
esp32c3 = ["esp32c3/rt", "riscv"]
esp32s2 = ["esp32s2/rt", "xtensa", "xtensa-lx/esp32s2", "xtensa-lx-rt/esp32s2", "esp-synopsys-usb-otg", "usb-device"]
esp32s3 = ["esp32s3/rt", "xtensa", "xtensa-lx/esp32s3", "xtensa-lx-rt/esp32s3", "lock_api", "esp-synopsys-usb-otg", "usb-device"]
esp32 = ["esp32/rt" , "xtensa", "xtensa-lx/esp32", "xtensa-lx-rt/esp32", "lock_api", "procmacros/esp32"]
esp32c2 = ["esp32c2/rt", "riscv", "procmacros/esp32c2"]
esp32c3 = ["esp32c3/rt", "riscv", "procmacros/esp32c3"]
esp32s2 = ["esp32s2/rt", "xtensa", "xtensa-lx/esp32s2", "xtensa-lx-rt/esp32s2", "esp-synopsys-usb-otg", "usb-device", "procmacros/esp32s2"]
esp32s3 = ["esp32s3/rt", "xtensa", "xtensa-lx/esp32s3", "xtensa-lx-rt/esp32s3", "lock_api", "esp-synopsys-usb-otg", "usb-device", "procmacros/esp32s3"]

esp32c2_40mhz = []
esp32c2_26mhz = []
Expand Down
20 changes: 20 additions & 0 deletions esp-hal-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,27 @@
#[cfg_attr(esp32s3, path = "peripherals/esp32s3.rs")]
pub mod peripherals;

#[cfg(riscv)]
pub use esp_riscv_rt;
#[cfg(riscv)]
pub use esp_riscv_rt::entry;
#[cfg(riscv)]
pub use esp_riscv_rt::riscv;
pub use procmacros as macros;
#[cfg(xtensa)]
pub use xtensa_lx;
#[cfg(xtensa)]
pub use xtensa_lx_rt;
#[cfg(xtensa)]
pub use xtensa_lx_rt::entry;

/// State of the CPU saved when entering exception or interrupt
pub mod trapframe {
#[cfg(riscv)]
pub use esp_riscv_rt::TrapFrame;
#[cfg(xtensa)]
pub use xtensa_lx_rt::exception::Context as TrapFrame;
}

#[cfg(rmt)]
pub use self::pulse_control::PulseControl;
Expand Down
1 change: 1 addition & 0 deletions esp-hal-common/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub use crate::{
DmaTransfer as _esp_hal_dma_DmaTransfer,
DmaTransferRxTx as _esp_hal_dma_DmaTransferRxTx,
},
entry,
gpio::{
InputPin as _esp_hal_gpio_InputPin,
OutputPin as _esp_hal_gpio_OutputPin,
Expand Down
8 changes: 7 additions & 1 deletion esp-hal-procmacros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "esp-hal-procmacros"
version = "0.2.0"
version = "0.3.0"
authors = [
"Jesse Braham <[email protected]>",
"Björn Quentin <[email protected]>",
Expand All @@ -20,9 +20,15 @@ proc-macro-error = "1.0.4"
proc-macro2 = "1.0.50"
quote = "1.0.23"
syn = {version = "1.0.107", features = ["extra-traits", "full"]}
proc-macro-crate = "1.3.0"

[features]
interrupt = []
riscv = []
rtc_slow = []
xtensa = []
esp32 = []
esp32c2 = []
esp32c3 = []
esp32s2 = []
esp32s3 = []
67 changes: 57 additions & 10 deletions esp-hal-procmacros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ pub fn ram(args: TokenStream, input: TokenStream) -> TokenStream {
#[cfg(feature = "interrupt")]
#[proc_macro_attribute]
pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
use proc_macro_crate::{crate_name, FoundCrate};

let mut f: ItemFn = syn::parse(input).expect("`#[interrupt]` must be applied to a function");

let attr_args = parse_macro_input!(args as AttributeArgs);
Expand Down Expand Up @@ -200,10 +202,46 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
&format!("__esp_hal_internal_{}", f.sig.ident),
proc_macro2::Span::call_site(),
);

#[cfg(feature = "esp32")]
let hal_crate = crate_name("esp32-hal");
#[cfg(feature = "esp32s2")]
let hal_crate = crate_name("esp32s2-hal");
#[cfg(feature = "esp32s3")]
let hal_crate = crate_name("esp32s3-hal");
#[cfg(feature = "esp32c2")]
let hal_crate = crate_name("esp32c2-hal");
#[cfg(feature = "esp32c3")]
let hal_crate = crate_name("esp32c3-hal");

#[cfg(feature = "esp32")]
let hal_crate_name = Ident::new("esp32_hal", Span::call_site().into());
#[cfg(feature = "esp32s2")]
let hal_crate_name = Ident::new("esp32s2_hal", Span::call_site().into());
#[cfg(feature = "esp32s3")]
let hal_crate_name = Ident::new("esp32s3_hal", Span::call_site().into());
#[cfg(feature = "esp32c2")]
let hal_crate_name = Ident::new("esp32c2_hal", Span::call_site().into());
#[cfg(feature = "esp32c3")]
let hal_crate_name = Ident::new("esp32c3_hal", Span::call_site().into());

let interrupt_in_hal_crate = match hal_crate {
Ok(FoundCrate::Itself) => {
quote!( #hal_crate_name::peripherals::Interrupt::#ident_s )
}
Ok(FoundCrate::Name(ref name)) => {
let ident = Ident::new(&name, Span::call_site().into());
quote!( #ident::peripherals::Interrupt::#ident_s )
}
Err(_) => {
quote!( crate::peripherals::Interrupt::#ident_s )
}
};

f.block.stmts.extend(std::iter::once(
syn::parse2(quote! {{
// Check that this interrupt actually exists
crate::peripherals::Interrupt::#ident_s;
#interrupt_in_hal_crate;
}})
.unwrap(),
));
Expand All @@ -218,25 +256,34 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {

let export_name = ident_s.to_string();

#[cfg(feature = "xtensa")]
let context = quote! {
xtensa_lx_rt::exception::Context
};

#[cfg(feature = "riscv")]
let context = quote! {
crate::interrupt::TrapFrame
let trap_frame_in_hal_crate = match hal_crate {
Ok(FoundCrate::Itself) => {
quote!(#hal_crate_name::trapframe::TrapFrame)
}
Ok(FoundCrate::Name(ref name)) => {
let ident = Ident::new(&name, Span::call_site().into());
quote!( #ident::trapframe::TrapFrame )
}
Err(_) => {
quote!(crate::trapframe::TrapFrame)
}
};

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

quote!(
macro_rules! foo {
() => {
};
}
foo!();

#(#cfgs)*
#(#attrs)*
#[doc(hidden)]
#[export_name = #export_name]
pub unsafe extern "C" fn #tramp_ident(context: &mut #context) {
pub unsafe extern "C" fn #tramp_ident(context: &mut #trap_frame_in_hal_crate) {
#ident(
#context_call
)
Expand Down
10 changes: 4 additions & 6 deletions esp32-hal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "esp32-hal"
version = "0.8.0"
version = "0.9.0"
authors = [
"Jesse Braham <[email protected]>",
"Björn Quentin <[email protected]>",
Expand Down Expand Up @@ -30,15 +30,13 @@ embedded-hal = { version = "0.2.7", features = ["unproven"] }
embedded-hal-1 = { version = "=1.0.0-alpha.9", optional = true, package = "embedded-hal" }
embedded-hal-async = { version = "0.2.0-alpha.0", optional = true }
embedded-hal-nb = { version = "=1.0.0-alpha.1", optional = true }
esp-hal-common = { version = "0.5.0", features = ["esp32"], path = "../esp-hal-common" }
xtensa-lx = { version = "0.7.0", features = ["esp32"] }
xtensa-lx-rt = { version = "0.14.0", features = ["esp32"], optional = true }
esp-hal-common = { version = "0.6.0", features = ["esp32"], path = "../esp-hal-common" }

[dev-dependencies]
critical-section = "1.1.1"
embassy-executor = { package = "embassy-executor", git = "https://github.com/embassy-rs/embassy/", rev = "cd9a65b", features = ["nightly", "integrated-timers"] }
embedded-graphics = "0.7.1"
esp-backtrace = { version = "0.4.0", features = ["esp32", "panic-handler", "exception-handler", "print-uart"] }
esp-backtrace = { version = "0.5.0", features = ["esp32", "panic-handler", "exception-handler", "print-uart"] }
esp-println = { version = "0.3.1", features = ["esp32"] }
sha2 = { version = "0.10.6", default-features = false}
smart-leds = "0.3.0"
Expand All @@ -50,7 +48,7 @@ aes = "0.8.2"
default = ["rt", "vectored"]
bluetooth = []
eh1 = ["esp-hal-common/eh1", "dep:embedded-hal-1", "dep:embedded-hal-nb"]
rt = ["xtensa-lx-rt/esp32"]
rt = []
smartled = ["esp-hal-common/smartled"]
ufmt = ["esp-hal-common/ufmt"]
vectored = ["esp-hal-common/vectored"]
Expand Down
1 change: 0 additions & 1 deletion esp32-hal/examples/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use esp32_hal::{
};
use esp_backtrace as _;
use esp_println::println;
use xtensa_lx_rt::entry;

#[entry]
fn main() -> ! {
Expand Down
1 change: 0 additions & 1 deletion esp32-hal/examples/advanced_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use esp32_hal::{
use esp_backtrace as _;
use esp_println::println;
use nb::block;
use xtensa_lx_rt::entry;

#[entry]
fn main() -> ! {
Expand Down
3 changes: 2 additions & 1 deletion esp32-hal/examples/aes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ use esp32_hal::{
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
xtensa_lx,
Rtc,
};
use esp_backtrace as _;
use esp_println::println;

#[xtensa_lx_rt::entry]
#[entry]
fn main() -> ! {
let peripherals = Peripherals::take();
let mut system = peripherals.DPORT.split();
Expand Down
1 change: 0 additions & 1 deletion esp32-hal/examples/blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use esp32_hal::{
Rtc,
};
use esp_backtrace as _;
use xtensa_lx_rt::entry;

#[entry]
fn main() -> ! {
Expand Down
1 change: 0 additions & 1 deletion esp32-hal/examples/blinky_erased_pins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use esp32_hal::{
Rtc,
};
use esp_backtrace as _;
use xtensa_lx_rt::entry;

#[entry]
fn main() -> ! {
Expand Down
1 change: 0 additions & 1 deletion esp32-hal/examples/clock_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use esp32_hal::{
Rtc,
};
use esp_backtrace as _;
use xtensa_lx_rt::entry;

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

Expand Down
1 change: 0 additions & 1 deletion esp32-hal/examples/dac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use esp32_hal::{
Rtc,
};
use esp_backtrace as _;
use xtensa_lx_rt::entry;

#[entry]
fn main() -> ! {
Expand Down
2 changes: 1 addition & 1 deletion esp32-hal/examples/embassy_hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async fn run2() {

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

#[xtensa_lx_rt::entry]
#[entry]
fn main() -> ! {
esp_println::println!("Init!");
let peripherals = Peripherals::take();
Expand Down
2 changes: 1 addition & 1 deletion esp32-hal/examples/embassy_spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async fn spi_task(spi: &'static mut SpiType<'static>) {

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

#[xtensa_lx_rt::entry]
#[entry]
fn main() -> ! {
esp_println::println!("Init!");
let peripherals = Peripherals::take();
Expand Down
2 changes: 1 addition & 1 deletion esp32-hal/examples/embassy_wait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async fn ping(mut pin: Gpio0<Input<PullDown>>) {

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

#[xtensa_lx_rt::entry]
#[entry]
fn main() -> ! {
esp_println::println!("Init!");
let peripherals = Peripherals::take();
Expand Down
2 changes: 1 addition & 1 deletion esp32-hal/examples/gpio_interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ use esp32_hal::{
peripherals::{self, Peripherals},
prelude::*,
timer::TimerGroup,
xtensa_lx,
Delay,
Rtc,
};
use esp_backtrace as _;
use xtensa_lx_rt::entry;

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

Expand Down
1 change: 0 additions & 1 deletion esp32-hal/examples/hello_rgb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use smart_leds::{
hsv::{hsv2rgb, Hsv},
SmartLedsWrite,
};
use xtensa_lx_rt::entry;

#[entry]
fn main() -> ! {
Expand Down
1 change: 0 additions & 1 deletion esp32-hal/examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use esp32_hal::{
};
use esp_backtrace as _;
use nb::block;
use xtensa_lx_rt::entry;

#[entry]
fn main() -> ! {
Expand Down
1 change: 0 additions & 1 deletion esp32-hal/examples/i2c_bmp180_calibration_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use esp32_hal::{
};
use esp_backtrace as _;
use esp_println::println;
use xtensa_lx_rt::entry;

#[entry]
fn main() -> ! {
Expand Down
1 change: 0 additions & 1 deletion esp32-hal/examples/i2c_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use esp32_hal::{
use esp_backtrace as _;
use nb::block;
use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306};
use xtensa_lx_rt::entry;

#[entry]
fn main() -> ! {
Expand Down
1 change: 0 additions & 1 deletion esp32-hal/examples/i2s_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use esp32_hal::{
};
use esp_backtrace as _;
use esp_println::println;
use xtensa_lx_rt::entry;

#[entry]
fn main() -> ! {
Expand Down
Loading

0 comments on commit 4e88e48

Please sign in to comment.