From 9bc20bf9974ea72b93251ccc443020bbe3fdb2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Tue, 26 Sep 2023 07:02:23 +0200 Subject: [PATCH] Delete manual PCC --- Cargo.toml | 2 +- src/board/hardware/v1.rs | 8 ++------ src/board/hardware/v2.rs | 9 ++------- src/board/hardware/v4.rs | 9 ++------- src/board/initialized.rs | 3 +-- src/board/startup.rs | 6 ------ src/board/wifi/mod.rs | 5 ++--- src/main.rs | 1 - src/stack_protection.rs | 6 ++---- 9 files changed, 12 insertions(+), 37 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4869fceb..50c598e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -143,7 +143,7 @@ smoltcp = { workspace = true } crc = "3.0.1" [patch.crates-io] -# esp32s3-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "24edf7bdc4788469a592e2fe6cf2580443101971" } +esp32s3-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "44e968f7a83f80be43d60cdc01c10eccab4b39cf" } # esp32s3-hal = { path = "../../esp-hal/esp32s3-hal" } # esp-hal-common = { path = "../../esp-hal/esp-hal-common" } # esp-wifi = { path = "../esp-wifi/esp-wifi" } diff --git a/src/board/hardware/v1.rs b/src/board/hardware/v1.rs index 062fdaee..ab116138 100644 --- a/src/board/hardware/v1.rs +++ b/src/board/hardware/v1.rs @@ -76,14 +76,14 @@ impl super::startup::StartupResources { let peripherals = Peripherals::take(); - let mut system = peripherals.SYSTEM.split(); + let system = peripherals.SYSTEM.split(); let clocks = ClockControl::configure(system.clock_control, CpuClock::Clock240MHz).freeze(); embassy::init(&clocks, SystemTimer::new(peripherals.SYSTIMER)); let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); - let dma = Gdma::new(peripherals.DMA, &mut system.peripheral_clock_control); + let dma = Gdma::new(peripherals.DMA); let display = Self::create_display_driver( dma.channel0, @@ -95,7 +95,6 @@ impl super::startup::StartupResources { io.pins.gpio10, io.pins.gpio12, io.pins.gpio11, - &mut system.peripheral_clock_control, &clocks, ); @@ -112,7 +111,6 @@ impl super::startup::StartupResources { DummyOutputPin, io.pins.gpio1, io.pins.gpio18, - &mut system.peripheral_clock_control, &clocks, ); @@ -136,11 +134,9 @@ impl super::startup::StartupResources { peripherals.RNG, system.radio_clock_control, &clocks, - &mut system.peripheral_clock_control, ) }), clocks, - peripheral_clock_control: system.peripheral_clock_control, rtc: Rtc::new(peripherals.RTC_CNTL), misc_pins: MiscPins { diff --git a/src/board/hardware/v2.rs b/src/board/hardware/v2.rs index 54873615..3fd5d0e8 100644 --- a/src/board/hardware/v2.rs +++ b/src/board/hardware/v2.rs @@ -97,14 +97,14 @@ impl super::startup::StartupResources { let peripherals = Peripherals::take(); - let mut system = peripherals.SYSTEM.split(); + let system = peripherals.SYSTEM.split(); let clocks = ClockControl::configure(system.clock_control, CpuClock::Clock240MHz).freeze(); embassy::init(&clocks, SystemTimer::new(peripherals.SYSTIMER)); let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); - let dma = Gdma::new(peripherals.DMA, &mut system.peripheral_clock_control); + let dma = Gdma::new(peripherals.DMA); let display = Self::create_display_driver( dma.channel0, @@ -116,7 +116,6 @@ impl super::startup::StartupResources { io.pins.gpio11, io.pins.gpio14, io.pins.gpio21, - &mut system.peripheral_clock_control, &clocks, ); @@ -133,7 +132,6 @@ impl super::startup::StartupResources { io.pins.gpio38, io.pins.gpio1, io.pins.gpio18, - &mut system.peripheral_clock_control, &clocks, ); @@ -152,7 +150,6 @@ impl super::startup::StartupResources { io.pins.gpio35, io.pins.gpio36, 100u32.kHz(), - &mut system.peripheral_clock_control, &clocks, ); @@ -200,11 +197,9 @@ impl super::startup::StartupResources { peripherals.RNG, system.radio_clock_control, &clocks, - &mut system.peripheral_clock_control, ) }), clocks, - peripheral_clock_control: system.peripheral_clock_control, rtc: Rtc::new(peripherals.RTC_CNTL), misc_pins: MiscPins { diff --git a/src/board/hardware/v4.rs b/src/board/hardware/v4.rs index 15ba080f..75c3c845 100644 --- a/src/board/hardware/v4.rs +++ b/src/board/hardware/v4.rs @@ -78,14 +78,14 @@ impl super::startup::StartupResources { let peripherals = Peripherals::take(); - let mut system = peripherals.SYSTEM.split(); + let system = peripherals.SYSTEM.split(); let clocks = ClockControl::configure(system.clock_control, CpuClock::Clock240MHz).freeze(); embassy::init(&clocks, SystemTimer::new(peripherals.SYSTIMER)); let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); - let dma = Gdma::new(peripherals.DMA, &mut system.peripheral_clock_control); + let dma = Gdma::new(peripherals.DMA); let display = Self::create_display_driver( dma.channel0, @@ -97,7 +97,6 @@ impl super::startup::StartupResources { io.pins.gpio11, io.pins.gpio14, io.pins.gpio21, - &mut system.peripheral_clock_control, &clocks, ); @@ -114,7 +113,6 @@ impl super::startup::StartupResources { io.pins.gpio38, io.pins.gpio1, io.pins.gpio18, - &mut system.peripheral_clock_control, &clocks, ); @@ -124,7 +122,6 @@ impl super::startup::StartupResources { io.pins.gpio36, io.pins.gpio35, 100u32.kHz(), - &mut system.peripheral_clock_control, &clocks, ); @@ -169,11 +166,9 @@ impl super::startup::StartupResources { peripherals.RNG, system.radio_clock_control, &clocks, - &mut system.peripheral_clock_control, ) }), clocks, - peripheral_clock_control: system.peripheral_clock_control, rtc: Rtc::new(peripherals.RTC_CNTL), misc_pins: MiscPins { diff --git a/src/board/initialized.rs b/src/board/initialized.rs index 0ffb7339..cc7ece00 100644 --- a/src/board/initialized.rs +++ b/src/board/initialized.rs @@ -2,7 +2,7 @@ use crate::{ board::{ config::Config, drivers::battery_monitor::BatteryMonitor, - hal::{clock::Clocks, system::PeripheralClockControl}, + hal::clock::Clocks, storage::FileSystem, wifi::{ap::Ap, sta::Sta, WifiDriver}, ChargerStatus, EcgFrontend, PoweredDisplay, VbusDetect, @@ -24,7 +24,6 @@ pub struct Board { pub display: PoweredDisplay, pub frontend: EcgFrontend, pub clocks: Clocks<'static>, - pub peripheral_clock_control: PeripheralClockControl, pub high_prio_spawner: SendSpawner, pub battery_monitor: BatteryMonitor, pub wifi: &'static mut WifiDriver, diff --git a/src/board/startup.rs b/src/board/startup.rs index 3f964972..34bba9eb 100644 --- a/src/board/startup.rs +++ b/src/board/startup.rs @@ -17,7 +17,6 @@ use crate::{ interrupt, peripherals, prelude::*, spi::{dma::WithDmaSpi3, SpiMode}, - system::PeripheralClockControl, Rtc, Spi, }, utils::DummyOutputPin, @@ -38,7 +37,6 @@ pub struct StartupResources { pub display: Display, pub frontend: EcgFrontend, pub clocks: Clocks<'static>, - pub peripheral_clock_control: PeripheralClockControl, #[cfg(feature = "battery_adc")] pub battery_adc: BatteryAdc, @@ -69,7 +67,6 @@ impl StartupResources { display_cs: impl Into, display_sclk: impl Into, display_mosi: impl Into, - pcc: &mut PeripheralClockControl, clocks: &Clocks, ) -> Display { unwrap!(interrupt::enable( @@ -93,7 +90,6 @@ impl StartupResources { display_mosi.into(), 40u32.MHz(), SpiMode::Mode0, - pcc, clocks, ) .with_dma(display_dma_channel.configure( @@ -128,7 +124,6 @@ impl StartupResources { touch_detect: impl Into, adc_cs: impl Into, - pcc: &mut PeripheralClockControl, clocks: &Clocks, ) -> EcgFrontend { unwrap!(interrupt::enable( @@ -155,7 +150,6 @@ impl StartupResources { adc_miso.into(), 1u32.MHz(), SpiMode::Mode1, - pcc, clocks, ) .with_dma(adc_dma_channel.configure( diff --git a/src/board/wifi/mod.rs b/src/board/wifi/mod.rs index 9f8c5aaf..f23f804b 100644 --- a/src/board/wifi/mod.rs +++ b/src/board/wifi/mod.rs @@ -9,7 +9,7 @@ use crate::{ clock::Clocks, peripherals::{RNG, TIMG1}, radio::Wifi, - system::{PeripheralClockControl, RadioClockControl}, + system::RadioClockControl, timer::{Timer0, TimerGroup}, Rng, Timer, }, @@ -176,14 +176,13 @@ impl WifiDriver { rng: RNG, rcc: RadioClockControl, clocks: &Clocks, - pcc: &mut PeripheralClockControl, ) -> Self { let rng = Rng::new(rng); Self { wifi, rng, state: WifiDriverState::Uninitialized(WifiInitResources { - timer: TimerGroup::new(timer, clocks, pcc).timer0, + timer: TimerGroup::new(timer, clocks).timer0, rng, rcc, }), diff --git a/src/main.rs b/src/main.rs index 5e386f51..496f7e4c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -312,7 +312,6 @@ async fn main_task(_spawner: Spawner, resources: StartupResources) { display, frontend: resources.frontend, clocks: resources.clocks, - peripheral_clock_control: resources.peripheral_clock_control, high_prio_spawner: INT_EXECUTOR.start(Priority::Priority3), battery_monitor, wifi: resources.wifi, diff --git a/src/stack_protection.rs b/src/stack_protection.rs index f8096090..2454c0af 100644 --- a/src/stack_protection.rs +++ b/src/stack_protection.rs @@ -3,7 +3,7 @@ use core::ops::Range; use crate::board::hal::{ assist_debug::DebugAssist, get_core, interrupt, - peripherals::{self, ASSIST_DEBUG, SYSTEM}, + peripherals::{self, ASSIST_DEBUG}, prelude::*, Cpu, }; @@ -13,10 +13,8 @@ pub struct StackMonitor { } fn conjure() -> DebugAssist<'static> { - let mut system = unsafe { SYSTEM::steal() }.split(); - let peripheral = unsafe { ASSIST_DEBUG::steal() }; - DebugAssist::new(peripheral, &mut system.peripheral_clock_control) + DebugAssist::new(peripheral) } impl StackMonitor {