Skip to content

Commit

Permalink
Merge pull request #122 from card-io-ecg/pcc
Browse files Browse the repository at this point in the history
Delete manual PCC handling
  • Loading branch information
bugadani authored Oct 5, 2023
2 parents f438c7c + 9bc20bf commit 140692c
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
8 changes: 2 additions & 6 deletions src/board/hardware/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -95,7 +95,6 @@ impl super::startup::StartupResources {
io.pins.gpio10,
io.pins.gpio12,
io.pins.gpio11,
&mut system.peripheral_clock_control,
&clocks,
);

Expand All @@ -112,7 +111,6 @@ impl super::startup::StartupResources {
DummyOutputPin,
io.pins.gpio1,
io.pins.gpio18,
&mut system.peripheral_clock_control,
&clocks,
);

Expand All @@ -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 {
Expand Down
9 changes: 2 additions & 7 deletions src/board/hardware/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -116,7 +116,6 @@ impl super::startup::StartupResources {
io.pins.gpio11,
io.pins.gpio14,
io.pins.gpio21,
&mut system.peripheral_clock_control,
&clocks,
);

Expand All @@ -133,7 +132,6 @@ impl super::startup::StartupResources {
io.pins.gpio38,
io.pins.gpio1,
io.pins.gpio18,
&mut system.peripheral_clock_control,
&clocks,
);

Expand All @@ -152,7 +150,6 @@ impl super::startup::StartupResources {
io.pins.gpio35,
io.pins.gpio36,
100u32.kHz(),
&mut system.peripheral_clock_control,
&clocks,
);

Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 2 additions & 7 deletions src/board/hardware/v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -97,7 +97,6 @@ impl super::startup::StartupResources {
io.pins.gpio11,
io.pins.gpio14,
io.pins.gpio21,
&mut system.peripheral_clock_control,
&clocks,
);

Expand All @@ -114,7 +113,6 @@ impl super::startup::StartupResources {
io.pins.gpio38,
io.pins.gpio1,
io.pins.gpio18,
&mut system.peripheral_clock_control,
&clocks,
);

Expand All @@ -124,7 +122,6 @@ impl super::startup::StartupResources {
io.pins.gpio36,
io.pins.gpio35,
100u32.kHz(),
&mut system.peripheral_clock_control,
&clocks,
);

Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions src/board/initialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<VbusDetect, ChargerStatus>,
pub wifi: &'static mut WifiDriver,
Expand Down
6 changes: 0 additions & 6 deletions src/board/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use crate::{
interrupt, peripherals,
prelude::*,
spi::{dma::WithDmaSpi3, SpiMode},
system::PeripheralClockControl,
Rtc, Spi,
},
utils::DummyOutputPin,
Expand All @@ -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,

Expand Down Expand Up @@ -69,7 +67,6 @@ impl StartupResources {
display_cs: impl Into<DisplayChipSelect>,
display_sclk: impl Into<DisplaySclk>,
display_mosi: impl Into<DisplayMosi>,
pcc: &mut PeripheralClockControl,
clocks: &Clocks,
) -> Display {
unwrap!(interrupt::enable(
Expand All @@ -93,7 +90,6 @@ impl StartupResources {
display_mosi.into(),
40u32.MHz(),
SpiMode::Mode0,
pcc,
clocks,
)
.with_dma(display_dma_channel.configure(
Expand Down Expand Up @@ -128,7 +124,6 @@ impl StartupResources {
touch_detect: impl Into<TouchDetect>,
adc_cs: impl Into<AdcChipSelect>,

pcc: &mut PeripheralClockControl,
clocks: &Clocks,
) -> EcgFrontend {
unwrap!(interrupt::enable(
Expand All @@ -155,7 +150,6 @@ impl StartupResources {
adc_miso.into(),
1u32.MHz(),
SpiMode::Mode1,
pcc,
clocks,
)
.with_dma(adc_dma_channel.configure(
Expand Down
5 changes: 2 additions & 3 deletions src/board/wifi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
clock::Clocks,
peripherals::{RNG, TIMG1},
radio::Wifi,
system::{PeripheralClockControl, RadioClockControl},
system::RadioClockControl,
timer::{Timer0, TimerGroup},
Rng, Timer,
},
Expand Down Expand Up @@ -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,
}),
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions src/stack_protection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -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 {
Expand Down

0 comments on commit 140692c

Please sign in to comment.