From c5f0060d341d190a85c15c7521a1bf5554956cc3 Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Tue, 27 Jun 2023 07:14:31 -0700 Subject: [PATCH] Miscellaneous fixes/improvements (#627) * Un-comment remaining device peripheral definitions for ESP32-H2 * Re-work `RadioExt` implementations, add support for ESP32-H2 * README updates for ESP32-C6/H2 * Update CHANGELOG --- CHANGELOG.md | 1 + esp-hal-common/devices/esp32h2.toml | 34 +++++++++--------- esp-hal-common/src/radio.rs | 34 +++++++++++------- esp-hal-common/src/soc/esp32h2/peripherals.rs | 36 +++++++++---------- esp32c6-hal/README.md | 2 +- esp32h2-hal/README.md | 12 +++---- 6 files changed, 65 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f758bb6c6..d8da21389 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Change LED pin to GPIO2 in ESP32 blinky example (#581) - Update ESP32-H2 and ESP32-C6 clocks and remove `i2c_clock` for all chips but ESP32 (#592) - Use both timers in `TIMG0` for embassy time driver when able (#609) +- Re-work `RadioExt` implementations, add support for ESP32-H2 (#627) ### Fixed diff --git a/esp-hal-common/devices/esp32h2.toml b/esp-hal-common/devices/esp32h2.toml index 79c4d1a31..fdd94a661 100644 --- a/esp-hal-common/devices/esp32h2.toml +++ b/esp-hal-common/devices/esp32h2.toml @@ -8,13 +8,13 @@ peripherals = [ "apb_saradc", "assist_debug", "dma", - # "ds", - # "ecc", + "ds", + "ecc", "efuse", "gpio", - # "hmac", - # "hp_apm", - # "hp_sys", + "hmac", + "hp_apm", + "hp_sys", "i2c0", "i2c1", "i2s0", @@ -22,20 +22,20 @@ peripherals = [ "intpri", "io_mux", "ledc", - # "lp_ana", - # "lp_aon", - # "lp_apm", + "lp_ana", + "lp_aon", + "lp_apm", "lp_clkrst", - # "lp_peri", - # "lp_timer", + "lp_peri", + "lp_timer", "lp_wdt", "mcpwm0", "mem_monitor", "modem_lpcon", "modem_syscon", - # "otp_debug", - # "parl_io", - # "pau", + "otp_debug", + "parl_io", + "pau", "pcnt", "pcr", "pmu", @@ -43,19 +43,19 @@ peripherals = [ "rng", "rsa", "sha", - # "soc_etm", + "soc_etm", "spi0", "spi1", "spi2", "systimer", - # "tee", + "tee", "timg0", "timg1", - # "trace", + "trace", # "twai0", "uart0", "uart1", - # "uhci0", + "uhci0", "usb_device", # Additional peripherals defined by us (the developers): diff --git a/esp-hal-common/src/radio.rs b/esp-hal-common/src/radio.rs index 98623801f..0dcd42724 100644 --- a/esp-hal-common/src/radio.rs +++ b/esp-hal-common/src/radio.rs @@ -70,17 +70,7 @@ impl crate::peripheral::Peripheral for LowRate { impl crate::peripheral::sealed::Sealed for LowRate {} cfg_if::cfg_if! { - if #[cfg(any(esp32, esp32c2, esp32c3, esp32s3))] { - impl RadioExt for crate::peripherals::RADIO { - type Components = (Wifi, Bluetooth); - - fn split(self) -> Self::Components { - unsafe { - (Wifi::steal(), Bluetooth::steal()) - } - } - } - } else if #[cfg(esp32c6)] { + if #[cfg(all(bt, ieee802154, wifi))] { impl RadioExt for crate::peripherals::RADIO { type Components = (Wifi, Bluetooth, LowRate); @@ -90,7 +80,27 @@ cfg_if::cfg_if! { } } } - } else if #[cfg(esp32s2)] { + } else if #[cfg(all(bt, ieee802154))] { + impl RadioExt for crate::peripherals::RADIO { + type Components = (Bluetooth, LowRate); + + fn split(self) -> Self::Components { + unsafe { + (Bluetooth::steal(), LowRate::steal()) + } + } + } + } else if #[cfg(all(bt, wifi))] { + impl RadioExt for crate::peripherals::RADIO { + type Components = (Wifi, Bluetooth); + + fn split(self) -> Self::Components { + unsafe { + (Wifi::steal(), Bluetooth::steal()) + } + } + } + } else if #[cfg(wifi)] { impl RadioExt for crate::peripherals::RADIO { type Components = Wifi; diff --git a/esp-hal-common/src/soc/esp32h2/peripherals.rs b/esp-hal-common/src/soc/esp32h2/peripherals.rs index e438290ab..4e96b1aa5 100644 --- a/esp-hal-common/src/soc/esp32h2/peripherals.rs +++ b/esp-hal-common/src/soc/esp32h2/peripherals.rs @@ -12,13 +12,13 @@ crate::peripherals! { APB_SARADC => true, ASSIST_DEBUG => true, DMA => true, - // DS => true, - // ECC => true, + DS => true, + ECC => true, EFUSE => true, GPIO => true, - // HMAC => true, - // HP_APM => true, - // HP_SYS => true, + HMAC => true, + HP_APM => true, + HP_SYS => true, I2C0 => true, I2C1 => true, I2S0 => true, @@ -26,20 +26,20 @@ crate::peripherals! { INTPRI => true, IO_MUX => true, LEDC => true, - // LP_ANA => true, - // LP_AON => true, - // LP_APM => true, + LP_ANA => true, + LP_AON => true, + LP_APM => true, LP_CLKRST => true, - // LP_PERI => true, - // LP_TIMER => true, + LP_PERI => true, + LP_TIMER => true, LP_WDT => true, MCPWM0 => true, MEM_MONITOR => true, MODEM_LPCON => true, MODEM_SYSCON => true, - // OTP_DEBUG => true, - // PARL_IO => true, - // PAU => true, + OTP_DEBUG => true, + PARL_IO => true, + PAU => true, PCNT => true, PCR => true, PMU => true, @@ -47,19 +47,19 @@ crate::peripherals! { RNG => true, RSA => true, SHA => true, - // SOC_ETM => true, + SOC_ETM => true, SPI0 => true, SPI1 => true, SPI2 => true, SYSTIMER => true, - // TEE => true, + TEE => true, TIMG0 => true, TIMG1 => true, - // TRACE => true, - // TWAI0 => true, + TRACE => true, + TWAI0 => true, UART0 => true, UART1 => true, - // UHCI0 => true, + UHCI0 => true, USB_DEVICE => true, RADIO => false, } diff --git a/esp32c6-hal/README.md b/esp32c6-hal/README.md index 9b1191969..6f4653f25 100644 --- a/esp32c6-hal/README.md +++ b/esp32c6-hal/README.md @@ -33,7 +33,7 @@ By default, [espflash](https://github.com/esp-rs/espflash) fetches the required #### Direct Boot -[Direct Boot](https://github.com/espressif/esp32c6-direct-boot-example#direct-boot-in-esp32-c6) allows an application stored in the External Flash to be executed directly, without being copied into Internal RAM. +[Direct Boot](https://github.com/espressif/esp32c3-direct-boot-example#direct-boot-in-esp32-c3) allows an application stored in the External Flash to be executed directly, without being copied into Internal RAM. ##### Booting the Hello World example using Direct Boot diff --git a/esp32h2-hal/README.md b/esp32h2-hal/README.md index c21b51c47..b5125b848 100644 --- a/esp32h2-hal/README.md +++ b/esp32h2-hal/README.md @@ -1,17 +1,17 @@ # esp32h2-hal - +![Crates.io](https://img.shields.io/crates/l/esp32h2-hal?labelColor=1C2C2E&style=flat-square) [![Matrix](https://img.shields.io/matrix/esp-rs:matrix.org?label=join%20matrix&labelColor=1C2C2E&color=BEC5C9&logo=matrix&style=flat-square)](https://matrix.to/#/#esp-rs:matrix.org) `no_std` HAL for the ESP32-H2 from Espressif. Implements a number of the traits defined by [embedded-hal](https://github.com/rust-embedded/embedded-hal). This device uses the RISC-V ISA, which is officially supported by the Rust compiler via the `riscv32imac-unknown-none-elf` target. Refer to the [Getting Started](#getting-started) section below for more information. - +[documentation]: https://docs.rs/esp32h2-hal/ ## Getting Started @@ -33,7 +33,7 @@ By default, [espflash](https://github.com/esp-rs/espflash) fetches the required #### Direct Boot -Direct Boot allows an application stored in the External Flash to be executed directly, without being copied into Internal RAM. +[Direct Boot](https://github.com/espressif/esp32c3-direct-boot-example#direct-boot-in-esp32-c3) allows an application stored in the External Flash to be executed directly, without being copied into Internal RAM. ##### Booting the Hello World example using Direct Boot @@ -73,4 +73,4 @@ at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without -any additional terms or conditions. +any additional terms or conditions.