From 241754e9afbd114ed0b3a0a3e9d9222047f2fbe6 Mon Sep 17 00:00:00 2001 From: bjoernQ Date: Tue, 24 Jan 2023 13:57:41 +0100 Subject: [PATCH 1/2] Use latest published HALs and Xtensa toolchain --- .cargo/config.toml | 6 ++++++ Cargo.toml | 24 +++++++++++------------- README.md | 14 +++++++------- build.rs | 8 ++++---- examples/ble.rs | 4 ++-- examples/coex.rs | 4 ++-- examples/dhcp.rs | 4 ++-- examples/static_ip.rs | 4 ++-- smoketest.bat | 4 ++-- src/ble/os_adapter_esp32c3.rs | 3 +-- src/common_adapter/mod.rs | 2 +- src/lib.rs | 4 +++- src/timer_esp32.rs | 28 ++++++++++++++++++++++------ src/timer_esp32c2.rs | 8 ++++---- src/timer_esp32c3.rs | 8 ++++---- src/timer_esp32s2.rs | 20 ++++++++++++++++---- src/timer_esp32s3.rs | 32 ++++++++++++++++++++++++++------ src/wifi/os_adapter_esp32c2.rs | 3 +-- src/wifi/os_adapter_esp32c3.rs | 3 +-- 19 files changed, 117 insertions(+), 66 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index ffe683a9..385a08fa 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -12,6 +12,8 @@ rustflags = [ runner = "espflash flash --monitor" rustflags = [ + #"-C", "linker=rust-lld", + "-C", "link-arg=-Tlinkall.x", "-C", "link-arg=-Tesp32_rom_functions.x", ] @@ -20,6 +22,8 @@ rustflags = [ runner = "espflash flash --monitor" rustflags = [ + #"-C", "linker=rust-lld", + "-C", "link-arg=-Tlinkall.x", "-C", "link-arg=-Tesp32s3_rom_functions.x", ] @@ -28,6 +32,8 @@ rustflags = [ runner = "espflash flash --monitor" rustflags = [ + #"-C", "linker=rust-lld", + "-C", "link-arg=-Tlinkall.x", "-C", "link-arg=-Tesp32s2_rom_functions.x", diff --git a/Cargo.toml b/Cargo.toml index f84b5d84..aeecfc58 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,13 +11,15 @@ opt-level = 3 embedded-hal = "0.2.3" nb = "1.0.0" void = { version = "1.0.2", default-features = false } -esp32c3-hal = { version = "0.4.0", optional = true } -esp32c2-hal = { version = "0.2.0", optional = true } -esp32-hal = { version = "0.7.0", optional = true, features = [ "rt" ] } -esp32s3-hal = { version = "0.4.0", optional = true, features = [ "rt" ] } -esp32s2-hal = { version = "0.4.0", optional = true, features = [ "rt" ] } -riscv-rt = { version = "0.10.0", optional = true } -riscv = { version = "0.10.0", optional = true } +esp32c3-hal = { version = "0.5.0", optional = true } +esp32c2-hal = { version = "0.3.0", optional = true } +esp32-hal = { version = "0.8.0", optional = true, features = [ "rt" ] } +esp32s3-hal = { version = "0.5.0", optional = true, features = [ "rt" ] } +esp32s2-hal = { version = "0.5.0", optional = true, features = [ "rt" ] } +esp32c3 = { version = "0.9.1", features = ["critical-section"], optional = true } +esp32c2 = { version = "0.6.1", features = ["critical-section"], optional = true } +riscv-rt = { version = "0.11.0", optional = true } +riscv = { version = "0.10.1", optional = true } xtensa-lx-rt = { version = "0.14.0", optional = true } xtensa-lx = { version = "0.7.0", optional = true } smoltcp = { version = "0.8.2", default-features=false, features = ["proto-igmp", "proto-ipv4", "socket-tcp", "socket-icmp", "socket-udp", "medium-ethernet", "proto-dhcpv4", "socket-raw", "socket-dhcpv4"] } @@ -58,8 +60,8 @@ xtensa-atomic-emulation-trap = "0.3.0" [features] default = [ "utils" ] -esp32c3 = [ "riscv-target", "riscv", "riscv-rt", "esp32c3-hal" ] -esp32c2 = [ "riscv-target", "riscv", "riscv-rt", "esp32c2-hal" ] +esp32c3 = [ "riscv-target", "riscv", "riscv-rt", "esp32c3-hal", "dep:esp32c3" ] +esp32c2 = [ "riscv-target", "riscv", "riscv-rt", "esp32c2-hal", "dep:esp32c2" ] esp32 = [ "esp32-hal", "xtensa-lx-rt/esp32", "xtensa-lx/esp32" ] esp32s3 = [ "esp32s3-hal", "xtensa-lx-rt/esp32s3", "xtensa-lx/esp32s3" ] esp32s2 = [ "esp32s2-hal", "xtensa-lx-rt/esp32s2", "xtensa-lx/esp32s2" ] @@ -72,7 +74,3 @@ wifi = [] ble = [ "esp32-hal?/bluetooth" ] phy_enable_usb = [] ps_min_modem = [] - -# for now esp32c2 PAC is missing some interrupts -[patch.crates-io] -esp32c2 = { git = "https://github.com/esp-rs/esp-pacs", package = "esp32c2", rev = "1f7aee9" } diff --git a/README.md b/README.md index 865e29c7..4cdf10a2 100644 --- a/README.md +++ b/README.md @@ -53,12 +53,12 @@ https://github.com/esp-rs/esp-wireless-drivers-3rdparty/ (commit f4caebff200e8f6 | `cargo "+esp" run --example ble --release --target xtensa-esp32-none-elf --features "esp32,ble"` | ESP32 | | `cargo "+esp" run --example dhcp --release --target xtensa-esp32-none-elf --features "esp32,embedded-svc,wifi"` | ESP32 | | `cargo "+esp" run --example static_ip --release --target xtensa-esp32-none-elf --features "esp32,embedded-svc,wifi"` | ESP32 | -| `CARGO_PROFILE_RELEASE_OPT_LEVEL=1 cargo "+esp" run --example ble --release --target xtensa-esp32s3-none-elf --features "esp32s3,ble"` | ESP32-S3 | -| `CARGO_PROFILE_RELEASE_OPT_LEVEL=1 cargo "+esp" run --example dhcp --release --target xtensa-esp32s3-none-elf --features "esp32s3,embedded-svc,wifi"` | ESP32-S3| -| `CARGO_PROFILE_RELEASE_OPT_LEVEL=1 cargo "+esp" run --example static_ip --release --target xtensa-esp32s3-none-elf --features "esp32s3,embedded-svc,wifi"` | ESP32-S3| -| `CARGO_PROFILE_RELEASE_OPT_LEVEL=1 cargo "+esp" run --example coex --release --target xtensa-esp32s3-none-elf --features "esp32s3,embedded-svc,wifi,ble"` | ESP32-S3| -| `cargo "+esp" run --example dhcp --release --target xtensa-esp32s2-none-elf --features "esp32s2,embedded-svc,wifi"` | ESP32-S2| -| `cargo "+esp" run --example static_ip --release --target xtensa-esp32s2-none-elf --features "esp32s2,embedded-svc,wifi"` | ESP32-S2| +| `cargo "+esp" run --example ble --release --target xtensa-esp32s3-none-elf --features "esp32s3,ble"` | ESP32-S3 | +| `cargo "+esp" run --example dhcp --release --target xtensa-esp32s3-none-elf --features "esp32s3,embedded-svc,wifi"` | ESP32-S3| +| `cargo "+esp" run --example static_ip --release --target xtensa-esp32s3-none-elf --features "esp32s3,embedded-svc,wifi"` | ESP32-S3| +| `cargo "+esp" run --example coex --release --target xtensa-esp32s3-none-elf --features "esp32s3,embedded-svc,wifi,ble"` | ESP32-S3| +| `CARGO_PROFILE_RELEASE_OPT_LEVEL=2 cargo "+esp" run --example dhcp --release --target xtensa-esp32s2-none-elf --features "esp32s2,embedded-svc,wifi"` | ESP32-S2| +| `CARGO_PROFILE_RELEASE_OPT_LEVEL=2 cargo "+esp" run --example static_ip --release --target xtensa-esp32s2-none-elf --features "esp32s2,embedded-svc,wifi"` | ESP32-S2| | `cargo "+nightly" run --example ble --release --target riscv32imc-unknown-none-elf --features "esp32c2,ble"` | ESP32-C2| | `cargo "+nightly" run --example dhcp --release --target riscv32imc-unknown-none-elf --features "esp32c2,embedded-svc,wifi"` | ESP32-C2| | `cargo "+nightly" run --example static_ip --release --target riscv32imc-unknown-none-elf --features "esp32c2,embedded-svc,wifi"`| ESP32-C2| @@ -79,7 +79,7 @@ Additionally you can specify these features It is necessary to build with optimization level 2 or 3 since otherwise it might not even be able to connect or advertise. -On ESP32-S3 you need to use optimization level 1 for now. +On ESP32-S2 you need to use optimization level 2 for now. To make it work also for your debug builds add this to your `Cargo.toml` diff --git a/build.rs b/build.rs index f604ac51..f095f1f0 100644 --- a/build.rs +++ b/build.rs @@ -13,7 +13,7 @@ use std::path::PathBuf; fn main() -> Result<(), String> { match std::env::var("OPT_LEVEL") { Ok(level) => { - #[cfg(not(feature = "esp32s3"))] + #[cfg(not(feature = "esp32s2"))] if level != "2" && level != "3" { let message = format!( "esp-wifi should be built with optimization level 2 or 3 - yours is {}. @@ -24,9 +24,9 @@ fn main() -> Result<(), String> { println!("cargo:warning={}", message); } - // on ESP32-S3 we currently need opt-level 1 because of mis-optimizations - #[cfg(feature = "esp32s3")] - if level != "1" { + // on ESP32-S2 we currently need opt-level 2 because of mis-optimizations + #[cfg(feature = "esp32s2")] + if level != "2" { let message = format!( "esp-wifi should be built with optimization level 1 for ESP32-S3 for now - yours is {}. See https://github.com/esp-rs/esp-wifi", diff --git a/examples/ble.rs b/examples/ble.rs index 5b3b0795..1c5d833d 100644 --- a/examples/ble.rs +++ b/examples/ble.rs @@ -26,7 +26,7 @@ use esp_println::{logger::init_logger, println}; use esp_wifi::{ble::controller::BleConnector, initialize}; use hal::{ clock::{ClockControl, CpuClock}, - pac::Peripherals, + peripherals::*, prelude::*, Rng, Rtc, }; @@ -44,7 +44,7 @@ fn main() -> ! { init_logger(log::LevelFilter::Info); esp_wifi::init_heap(); - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); #[cfg(not(feature = "esp32"))] let system = peripherals.SYSTEM.split(); diff --git a/examples/coex.rs b/examples/coex.rs index a0978331..b4f99bf5 100644 --- a/examples/coex.rs +++ b/examples/coex.rs @@ -34,7 +34,7 @@ use hal::{ clock::{ClockControl, CpuClock}, Rng, }; -use hal::{pac::Peripherals, prelude::*, Rtc}; +use hal::{peripherals::Peripherals, prelude::*, Rtc}; use smoltcp::wire::Ipv4Address; #[cfg(feature = "esp32c3")] @@ -53,7 +53,7 @@ fn main() -> ! { init_logger(log::LevelFilter::Info); esp_wifi::init_heap(); - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); #[cfg(not(feature = "esp32"))] let system = peripherals.SYSTEM.split(); diff --git a/examples/dhcp.rs b/examples/dhcp.rs index 7416f2ee..3f8cd5c5 100644 --- a/examples/dhcp.rs +++ b/examples/dhcp.rs @@ -27,7 +27,7 @@ use esp_wifi::{create_network_stack_storage, network_stack_storage}; use esp_wifi::{current_millis, initialize}; use hal::clock::{ClockControl, CpuClock}; use hal::Rng; -use hal::{pac::Peripherals, prelude::*, Rtc}; +use hal::{peripherals::Peripherals, prelude::*, Rtc}; use smoltcp::wire::Ipv4Address; #[cfg(any(feature = "esp32c3", feature = "esp32c2"))] @@ -46,7 +46,7 @@ fn main() -> ! { init_logger(log::LevelFilter::Info); esp_wifi::init_heap(); - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); #[cfg(not(feature = "esp32"))] let system = peripherals.SYSTEM.split(); diff --git a/examples/static_ip.rs b/examples/static_ip.rs index 52e675fd..05bdef98 100644 --- a/examples/static_ip.rs +++ b/examples/static_ip.rs @@ -27,7 +27,7 @@ use esp_wifi::{create_network_stack_storage, network_stack_storage}; use esp_wifi::{current_millis, initialize}; use hal::clock::{ClockControl, CpuClock}; use hal::Rng; -use hal::{pac::Peripherals, prelude::*, Rtc}; +use hal::{peripherals::Peripherals, prelude::*, Rtc}; #[cfg(any(feature = "esp32c3", feature = "esp32c2"))] use hal::system::SystemExt; @@ -47,7 +47,7 @@ fn main() -> ! { init_logger(log::LevelFilter::Info); esp_wifi::init_heap(); - let peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take(); #[cfg(not(feature = "esp32"))] let system = peripherals.SYSTEM.split(); diff --git a/smoketest.bat b/smoketest.bat index 723a82d4..62238311 100644 --- a/smoketest.bat +++ b/smoketest.bat @@ -22,7 +22,7 @@ cargo "+esp" run --example ble --release --target xtensa-esp32-none-elf --featur cargo "+esp" run --example dhcp --release --target xtensa-esp32-none-elf --features "esp32,embedded-svc,wifi" cargo "+esp" run --example static_ip --release --target xtensa-esp32-none-elf --features "esp32,embedded-svc,wifi" -set CARGO_PROFILE_RELEASE_OPT_LEVEL=1 +set CARGO_PROFILE_RELEASE_OPT_LEVEL=3 echo. echo Connect ESP32-S3 pause @@ -31,7 +31,7 @@ cargo "+esp" run --example dhcp --release --target xtensa-esp32s3-none-elf --fea cargo "+esp" run --example static_ip --release --target xtensa-esp32s3-none-elf --features "esp32s3,embedded-svc,wifi" cargo "+esp" run --example coex --release --target xtensa-esp32s3-none-elf --features "esp32s3,embedded-svc,wifi,ble" -set CARGO_PROFILE_RELEASE_OPT_LEVEL=3 +set CARGO_PROFILE_RELEASE_OPT_LEVEL=2 echo. echo Connect ESP32-S2 pause diff --git a/src/ble/os_adapter_esp32c3.rs b/src/ble/os_adapter_esp32c3.rs index 054a0528..79ff3c67 100644 --- a/src/ble/os_adapter_esp32c3.rs +++ b/src/ble/os_adapter_esp32c3.rs @@ -1,6 +1,5 @@ use super::*; use crate::binary::include::esp_bt_controller_config_t; -use esp32c3_hal as hal; use log::trace; pub(crate) static mut BT_INTERRUPT_FUNCTION5: ( @@ -180,7 +179,7 @@ pub(crate) fn create_ble_config() -> esp_bt_controller_config_t { pub(crate) unsafe extern "C" fn interrupt_on(intr_num: i32) { trace!("interrupt_on {}", intr_num); - (*hal::pac::INTERRUPT_CORE0::PTR) + (*esp32c3::INTERRUPT_CORE0::PTR) .cpu_int_enable .modify(|r, w| w.bits(r.bits() | 1 << intr_num)); } diff --git a/src/common_adapter/mod.rs b/src/common_adapter/mod.rs index d302bf40..b33787bf 100644 --- a/src/common_adapter/mod.rs +++ b/src/common_adapter/mod.rs @@ -40,7 +40,7 @@ pub(crate) static mut RANDOM_GENERATOR: Option = None; pub fn init_rng(rng: hal::Rng) { unsafe { - crate::common_adapter::RANDOM_GENERATOR = Some(rng); + crate::common_adapter::RANDOM_GENERATOR = Some(core::mem::transmute(rng)); } } diff --git a/src/lib.rs b/src/lib.rs index aace3dc3..89b8b85c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,6 +22,8 @@ use esp32s2_hal as hal; #[cfg(feature = "esp32s3")] use esp32s3_hal as hal; +use hal::*; + use fugit::MegahertzU32; use hal::clock::Clocks; use linked_list_allocator::Heap; @@ -165,7 +167,7 @@ pub enum InitializationError { /// Initialize for using WiFi / BLE /// This will initialize internals and also initialize WiFi and BLE pub fn initialize( - timg1_timer0: hal::timer::Timer>, + timg1_timer0: hal::timer::Timer>, rng: hal::Rng, clocks: &Clocks, ) -> Result<(), InitializationError> { diff --git a/src/timer_esp32.rs b/src/timer_esp32.rs index 6c223bae..68e97083 100644 --- a/src/timer_esp32.rs +++ b/src/timer_esp32.rs @@ -4,7 +4,7 @@ use atomic_polyfill::{AtomicU64, Ordering}; use critical_section::Mutex; use esp32_hal::{ interrupt, - pac::{self, TIMG1}, + peripherals::{self, TIMG1}, prelude::*, timer::{Timer, Timer0}, }; @@ -39,18 +39,34 @@ fn read_timer_value() -> u64 { pub fn setup_timer_isr(timg1_timer0: Timer>) { let mut timer1 = timg1_timer0; - interrupt::enable(pac::Interrupt::TG1_T0_LEVEL, interrupt::Priority::Priority2).unwrap(); + interrupt::enable( + peripherals::Interrupt::TG1_T0_LEVEL, + interrupt::Priority::Priority2, + ) + .unwrap(); #[cfg(feature = "wifi")] - interrupt::enable(pac::Interrupt::WIFI_MAC, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::WIFI_MAC, + interrupt::Priority::Priority1, + ) + .unwrap(); #[cfg(feature = "wifi")] - interrupt::enable(pac::Interrupt::WIFI_BB, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::WIFI_BB, + interrupt::Priority::Priority1, + ) + .unwrap(); #[cfg(feature = "ble")] { - interrupt::enable(pac::Interrupt::RWBT, interrupt::Priority::Priority1).unwrap(); - interrupt::enable(pac::Interrupt::BT_BB, interrupt::Priority::Priority1).unwrap(); + interrupt::enable(peripherals::Interrupt::RWBT, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::BT_BB, + interrupt::Priority::Priority1, + ) + .unwrap(); } timer1.listen(); diff --git a/src/timer_esp32c2.rs b/src/timer_esp32c2.rs index 0349eccf..2c05ac00 100644 --- a/src/timer_esp32c2.rs +++ b/src/timer_esp32c2.rs @@ -1,11 +1,11 @@ use core::cell::RefCell; use critical_section::Mutex; +use esp32c2 as pac; use esp32c2_hal as hal; use esp32c2_hal::interrupt::TrapFrame; use esp32c2_hal::prelude::*; -use hal::pac; -use hal::pac::Interrupt; +use hal::peripherals::Interrupt; use hal::systimer::{Alarm, Periodic, Target}; use crate::{binary, preempt::preempt::task_switch}; @@ -158,7 +158,7 @@ fn SYSTIMER_TARGET0(trap_frame: &mut TrapFrame) { fn SW_INTR_3(trap_frame: &mut TrapFrame) { unsafe { // clear SW_INTR_3 - (&*esp32c2_hal::pac::SYSTEM::PTR) + (&*pac::SYSTEM::PTR) .cpu_intr_from_cpu_3 .modify(|_, w| w.cpu_intr_from_cpu_3().clear_bit()); } @@ -176,7 +176,7 @@ fn SW_INTR_3(trap_frame: &mut TrapFrame) { pub fn yield_task() { unsafe { - (&*esp32c2_hal::pac::SYSTEM::PTR) + (&*pac::SYSTEM::PTR) .cpu_intr_from_cpu_3 .modify(|_, w| w.cpu_intr_from_cpu_3().set_bit()); } diff --git a/src/timer_esp32c3.rs b/src/timer_esp32c3.rs index dcf5e0ab..50b66bd0 100644 --- a/src/timer_esp32c3.rs +++ b/src/timer_esp32c3.rs @@ -1,11 +1,11 @@ use core::cell::RefCell; use critical_section::Mutex; +use esp32c3 as pac; use esp32c3_hal as hal; use esp32c3_hal::interrupt::TrapFrame; use esp32c3_hal::prelude::*; -use hal::pac; -use hal::pac::Interrupt; +use hal::peripherals::Interrupt; use hal::systimer::{Alarm, Periodic, Target}; use crate::{binary, preempt::preempt::task_switch}; @@ -176,7 +176,7 @@ fn SYSTIMER_TARGET0(trap_frame: &mut TrapFrame) { fn SW_INTR_3(trap_frame: &mut TrapFrame) { unsafe { // clear SW_INTR_3 - (&*esp32c3_hal::pac::SYSTEM::PTR) + (&*pac::SYSTEM::PTR) .cpu_intr_from_cpu_3 .modify(|_, w| w.cpu_intr_from_cpu_3().clear_bit()); } @@ -194,7 +194,7 @@ fn SW_INTR_3(trap_frame: &mut TrapFrame) { pub fn yield_task() { unsafe { - (&*esp32c3_hal::pac::SYSTEM::PTR) + (&*pac::SYSTEM::PTR) .cpu_intr_from_cpu_3 .modify(|_, w| w.cpu_intr_from_cpu_3().set_bit()); } diff --git a/src/timer_esp32s2.rs b/src/timer_esp32s2.rs index e026f7d2..5ecf9be3 100644 --- a/src/timer_esp32s2.rs +++ b/src/timer_esp32s2.rs @@ -4,7 +4,7 @@ use atomic_polyfill::{AtomicU64, Ordering}; use critical_section::Mutex; use esp32s2_hal::{ interrupt, - pac::{self, TIMG1}, + peripherals::{self, TIMG1}, prelude::*, timer::{Timer, Timer0}, }; @@ -39,13 +39,25 @@ fn read_timer_value() -> u64 { pub fn setup_timer_isr(timg1_timer0: Timer>) { let mut timer1 = timg1_timer0; - interrupt::enable(pac::Interrupt::TG1_T0_LEVEL, interrupt::Priority::Priority2).unwrap(); + interrupt::enable( + peripherals::Interrupt::TG1_T0_LEVEL, + interrupt::Priority::Priority2, + ) + .unwrap(); #[cfg(feature = "wifi")] - interrupt::enable(pac::Interrupt::WIFI_MAC, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::WIFI_MAC, + interrupt::Priority::Priority1, + ) + .unwrap(); #[cfg(feature = "wifi")] - interrupt::enable(pac::Interrupt::WIFI_PWR, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::WIFI_PWR, + interrupt::Priority::Priority1, + ) + .unwrap(); timer1.listen(); timer1.start(TIMER_DELAY.convert()); diff --git a/src/timer_esp32s3.rs b/src/timer_esp32s3.rs index 63df4eab..a97c90f6 100644 --- a/src/timer_esp32s3.rs +++ b/src/timer_esp32s3.rs @@ -4,7 +4,7 @@ use atomic_polyfill::{AtomicU64, Ordering}; use critical_section::Mutex; use esp32s3_hal::{ interrupt, - pac::{self, TIMG1}, + peripherals::{self, TIMG1}, prelude::*, timer::{Timer, Timer0}, }; @@ -39,18 +39,38 @@ fn read_timer_value() -> u64 { pub fn setup_timer_isr(timg1_timer0: Timer>) { let mut timer1 = timg1_timer0; - interrupt::enable(pac::Interrupt::TG1_T0_LEVEL, interrupt::Priority::Priority2).unwrap(); + interrupt::enable( + peripherals::Interrupt::TG1_T0_LEVEL, + interrupt::Priority::Priority2, + ) + .unwrap(); #[cfg(feature = "wifi")] - interrupt::enable(pac::Interrupt::WIFI_MAC, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::WIFI_MAC, + interrupt::Priority::Priority1, + ) + .unwrap(); #[cfg(feature = "wifi")] - interrupt::enable(pac::Interrupt::WIFI_BB, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::WIFI_BB, + interrupt::Priority::Priority1, + ) + .unwrap(); #[cfg(feature = "ble")] { - interrupt::enable(pac::Interrupt::BT_BB_NMI, interrupt::Priority::Priority1).unwrap(); - interrupt::enable(pac::Interrupt::RWBT_NMI, interrupt::Priority::Priority1).unwrap(); + interrupt::enable( + peripherals::Interrupt::BT_BB_NMI, + interrupt::Priority::Priority1, + ) + .unwrap(); + interrupt::enable( + peripherals::Interrupt::RWBT_NMI, + interrupt::Priority::Priority1, + ) + .unwrap(); } timer1.listen(); diff --git a/src/wifi/os_adapter_esp32c2.rs b/src/wifi/os_adapter_esp32c2.rs index aa9156a5..6b3984ce 100644 --- a/src/wifi/os_adapter_esp32c2.rs +++ b/src/wifi/os_adapter_esp32c2.rs @@ -1,4 +1,3 @@ -use esp32c2_hal as hal; use log::trace; pub(crate) fn chip_ints_on(mask: u32) { @@ -10,7 +9,7 @@ pub(crate) fn chip_ints_on(mask: u32) { trace!("ints_on n={}", cpuint); unsafe { - (*hal::pac::INTERRUPT_CORE0::PTR) + (*esp32c2::INTERRUPT_CORE0::PTR) .cpu_int_enable .modify(|r, w| w.bits(r.bits() | 1 << cpuint)); } diff --git a/src/wifi/os_adapter_esp32c3.rs b/src/wifi/os_adapter_esp32c3.rs index 9b7a64a8..3c131fbe 100644 --- a/src/wifi/os_adapter_esp32c3.rs +++ b/src/wifi/os_adapter_esp32c3.rs @@ -1,4 +1,3 @@ -use esp32c3_hal as hal; use log::trace; pub(crate) fn chip_ints_on(mask: u32) { @@ -10,7 +9,7 @@ pub(crate) fn chip_ints_on(mask: u32) { trace!("ints_on n={}", cpuint); unsafe { - (*hal::pac::INTERRUPT_CORE0::PTR) + (*esp32c3::INTERRUPT_CORE0::PTR) .cpu_int_enable .modify(|r, w| w.bits(r.bits() | 1 << cpuint)); } From 75eadf4c8d97844040f48c2eecf8e2d092a170c5 Mon Sep 17 00:00:00 2001 From: bjoernQ Date: Fri, 27 Jan 2023 13:19:54 +0100 Subject: [PATCH 2/2] Fix warning message text --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index f095f1f0..f57dada9 100644 --- a/build.rs +++ b/build.rs @@ -28,7 +28,7 @@ fn main() -> Result<(), String> { #[cfg(feature = "esp32s2")] if level != "2" { let message = format!( - "esp-wifi should be built with optimization level 1 for ESP32-S3 for now - yours is {}. + "esp-wifi should be built with optimization level 1 for ESP32-S2 for now - yours is {}. See https://github.com/esp-rs/esp-wifi", level )