Skip to content

Commit

Permalink
Unify: Remove the chip-specific HAL packages, adapt esp-hal for dir…
Browse files Browse the repository at this point in the history
…ect use [1/?] (#1196)

* Remove the chip-specific HAL packages

* Update some doc comments which were missed, fix build script for ESP32/S2

* Refactor/update `esp-hal-procmacros`

* Create the `examples` package, add back all of the previously existing examples

* Use `xtask` automation package for checking examples and documentation in CI

* Combine the `rt-riscv` and `rt-xtensa` features into a single `rt` feature

* Bump MSRV to 1.76.0 (shocking!)

* Re-document the features for the HAL

* No need to re-export the `riscv` package like this

* Make clippy happy, improve CI clippy checks

* Update `CHANGELOG.md`

* riscv: zero bss

Co-authored-by: Björn Quentin <bjoernQ@users.noreply.github.com>

* Address a number of review comments

* Correct pin number in `hello_rgb` example for ESP32-C3

* Address the remaining review comments

* More small tweaks/improvements

* Fix RMT examples (#11)

* Fix RMT examples

* Remove logger-init

* Make I2S examples work on ESP32 (#12)

* Make I2S examples work on ESP32

* Remove logger init

* Fix the direct-vectoring examples on all RISCV chips (#10)

* Update GPIOs for some examples...

* Embassy timer example fixes (#13)

* Switch to generic queue instead of integrated for all examples

* changelog

* Update GPIO in another example, make `rustfmt` happy

* Fix ESP32-S2 PSRAM

* Avoid UART0 and SPI flash pins (#15)

* Avoid UART0 and SPI flash pins

* Fix spi_eh1_device_loopback for non-ESP32

* Update examples/src/bin/gpio_interrupt.rs

Co-authored-by: Juraj Sadel <jurajsadel@gmail.com>

---------

Co-authored-by: Juraj Sadel <jurajsadel@gmail.com>

---------

Co-authored-by: Scott Mabin <scott@mabez.dev>
Co-authored-by: Björn Quentin <bjoernQ@users.noreply.github.com>
Co-authored-by: bjoernQ <bjoern.quentin@mobile-j.de>
Co-authored-by: Juraj Sadel <jurajsadel@gmail.com>
  • Loading branch information
5 people authored Feb 27, 2024
1 parent 9a95c0a commit 6a663f8
Show file tree
Hide file tree
Showing 473 changed files with 2,155 additions and 31,730 deletions.
747 changes: 125 additions & 622 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Lift the minimal buffer size requirement for I2S (#1189)

### Removed

- Remove `xtal-26mhz` and `xtal-40mhz` features (#1165)
- All chip-specific HAL packages have been removed (#1196)

### Breaking

- `ADC` and `DAC` drivers now take virtual peripherals in their constructors, instead of splitting `APB_SARADC`/`SENS` (#1100)
- The `DAC` driver's constructor is now `new` instead of `dac`, to be more consistent with other APIs (#1100)
- The DMA peripheral is now called `Dma` for devices with both PDMA and GDMA controllers (#1125)
- The `ADC` driver's constructor is now `new` instead of `adc`, to be more consistent with other APIs (#1133)
- `embassy-executor`'s `integrated-timers` is no longer enabled by default.

## [0.15.0] - 2024-01-19

Expand Down Expand Up @@ -147,7 +150,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- RISC-V: Fix stack allocation (#988)
- ESP32-C6: Fix used RAM (#997)
- ESP32-H2: Fix used RAM (#1003)
- Fix SPI slave DMA dma\_read and dma\_write (#1013)
- Fix SPI slave DMA dma_read and dma_write (#1013)
- ESP32-C6/H2: Fix disabling of interrupts (#1040)

### Removed
Expand All @@ -160,8 +163,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `Spi::new`/`Spi::new_half_duplex` takes no gpio pin now, instead you need to call `with_pins` to setup those (#901).
- ESP32-C2, ESP32-C3, ESP32-S2: atomic emulation trap has been removed. (#904) (#985)
- When upgrading you must either remove [these lines](https://github.com/esp-rs/riscv-atomic-emulation-trap#usage) from your `.cargo/config.toml`.
- Usage of `core::sync::atomic::*` in dependent crates should be replaced with [portable-atomic](https://github.com/taiki-e/portable-atomic).
- When upgrading you must either remove [these lines](https://github.com/esp-rs/riscv-atomic-emulation-trap#usage) from your `.cargo/config.toml`.
- Usage of `core::sync::atomic::*` in dependent crates should be replaced with [portable-atomic](https://github.com/taiki-e/portable-atomic).
- RSA driver now takes `u32` words instead of `u8` bytes. The expected slice length is now 4 times shorter. (#981)

## [0.13.1] - 2023-11-02
Expand Down
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
members = ["xtask"]
exclude = [
resolver = "2"
members = ["xtask"]
exclude = [
"esp-hal",
"esp-hal-procmacros",
"esp-hal-smartled",
Expand All @@ -14,4 +15,5 @@ exclude = [
"esp32p4-hal",
"esp32s2-hal",
"esp32s3-hal",
"examples",
]
54 changes: 21 additions & 33 deletions esp-hal-procmacros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
name = "esp-hal-procmacros"
version = "0.8.0"
edition = "2021"
rust-version = "1.67.0"
description = "Procedural macros for ESP-HAL"
rust-version = "1.76.0"
description = "Procedural macros for esp-hal"
repository = "https://github.com/esp-rs/esp-hal"
license = "MIT OR Apache-2.0"

[package.metadata.docs.rs]
features = ["esp32c3", "embassy", "interrupt", "ram"]
features = ["embassy", "has-ulp-core", "interrupt", "ram", "is-ulp-core"]

[lib]
proc-macro = true

[dependencies]
darling = "0.20.3"
document-features = "0.2.7"
darling = "0.20.5"
document-features = "0.2.8"
litrs = "0.4.1"
object = { version = "0.32.1", optional = true }
proc-macro-crate = "2.0.1"
object = { version = "0.32.2", optional = true }
proc-macro-crate = "3.1.0"
proc-macro-error = "1.0.4"
proc-macro2 = "1.0.70"
quote = "1.0.33"
syn = { version = "2.0.40", features = ["extra-traits", "full"] }
proc-macro2 = "1.0.78"
quote = "1.0.35"
syn = { version = "2.0.48", features = ["extra-traits", "full"] }

[features]
## Provide a `#[main]` procmacro to mark the entry point for Embassy applications.
Expand All @@ -36,26 +36,14 @@ ram = []
## Indicates the target devices has RTC slow memory available.
rtc_slow = []

#! ### Chip Support Feature Flags
## Target the ESP32.
esp32 = []
## Target the ESP32-C2.
esp32c2 = []
## Target the ESP32-C3.
esp32c3 = []
## Target the ESP32-C6.
esp32c6 = ["dep:object"]
## Target the ESP32-C6's low-power core.
esp32c6-lp = []
## Target the ESP32-H2.
esp32h2 = []
## Target the ESP32-P4.
esp32p4 = []
## Target the ESP32-S2.
esp32s2 = ["dep:object"]
## Target the ESP32-S2's ultra-low-power core.
esp32s2-ulp = []
## Target the ESP32-S3.
esp32s3 = ["dep:object"]
## Target the ESP32-S3's ultra-low-power core.
esp32s3-ulp = []
#! ### Low-power Core Feature Flags
## Indicate that the SoC contains an LP core.
has-lp-core = ["dep:object"]
## Indicate that the SoC contains a ULP core.
has-ulp-core = ["dep:object"]
## Provide an `#[entry]` macro for running applications on the ESP32-C6/P4's
## LP core.
is-lp-core = []
## Provide an `#[entry]` macro for running applications on the ESP32-S2/S3's
## ULP core.
is-ulp-core = []
24 changes: 11 additions & 13 deletions esp-hal-procmacros/src/embassy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub(crate) mod main {

use darling::{export::NestedMeta, FromMeta};
use proc_macro2::{Ident, Span, TokenStream};
use proc_macro_crate::FoundCrate;
use proc_macro_crate::{crate_name, FoundCrate};
use quote::{quote, ToTokens};
use syn::{ReturnType, Type};

Expand Down Expand Up @@ -162,19 +162,17 @@ pub(crate) mod main {
}

pub fn main() -> TokenStream {
let (hal_crate, hal_crate_name) = crate::get_hal_crate();
let hal_crate = if cfg!(any(feature = "is-lp-core", feature = "is-ulp-core")) {
crate_name("esp-lp-hal")
} else {
crate_name("esp-hal")
};

let executor = match hal_crate {
Ok(FoundCrate::Itself) => {
quote!( #hal_crate_name::embassy::executor::Executor )
}
Ok(FoundCrate::Name(ref name)) => {
let ident = Ident::new(&name, Span::call_site().into());
quote!( #ident::embassy::executor::Executor )
}
Err(_) => {
quote!(crate::embassy::executor::Executor)
}
let executor = if let Ok(FoundCrate::Name(ref name)) = hal_crate {
let ident = Ident::new(&name, Span::call_site().into());
quote!( #ident::embassy::executor::Executor )
} else {
quote!(crate::embassy::executor::Executor)
};

quote! {
Expand Down
26 changes: 25 additions & 1 deletion esp-hal-procmacros/src/enum_dispatch.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use proc_macro2::{Group, TokenTree};
use proc_macro2::{Group, TokenStream, TokenTree};
use quote::{format_ident, quote};
use syn::{
parse::{Parse, ParseStream, Result},
Ident,
Expand Down Expand Up @@ -54,3 +55,26 @@ impl Parse for MakeGpioEnumDispatchMacro {
})
}
}

pub(crate) fn build_match_arms(input: MakeGpioEnumDispatchMacro) -> Vec<TokenStream> {
let mut arms = Vec::new();
for (gpio_type, num) in input.elements {
let enum_name = format_ident!("ErasedPin");
let variant_name = format_ident!("Gpio{}", num);

if input.filter.contains(&gpio_type) {
arms.push({
quote! { #enum_name::#variant_name($target) => $body }
});
} else {
arms.push({
quote! {
#[allow(unused)]
#enum_name::#variant_name($target) => { panic!("Unsupported") }
}
});
}
}

arms
}
Loading

0 comments on commit 6a663f8

Please sign in to comment.