Skip to content

Commit

Permalink
Update again
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Sep 16, 2024
1 parent 9b6552a commit 504ac9f
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 46 deletions.
13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ esp-println = { version = "0.11.0", default-features = false, features = [
] }
esp-alloc = "0.4.0"
esp-wifi = { version = "0.9.1", default-features = false, features = [
"esp-alloc",
"phy-enable-usb",
"ps-max-modem",
"wifi",
Expand Down Expand Up @@ -131,12 +132,12 @@ crc = "3.0.1"
enumset = "1.1.3"

[patch.crates-io]
esp-hal = { git = "https://github.com/bugadani/esp-hal.git", rev = "38abd6e1ab9ca621d310a198696a300db82c0ad8" }
esp-hal-embassy = { git = "https://github.com/bugadani/esp-hal.git", rev = "38abd6e1ab9ca621d310a198696a300db82c0ad8" }
esp-wifi = { git = "https://github.com/bugadani/esp-hal.git", rev = "38abd6e1ab9ca621d310a198696a300db82c0ad8" }
esp-backtrace = { git = "https://github.com/bugadani/esp-hal.git", rev = "38abd6e1ab9ca621d310a198696a300db82c0ad8" }
esp-println = { git = "https://github.com/bugadani/esp-hal.git", rev = "38abd6e1ab9ca621d310a198696a300db82c0ad8" }
esp-alloc = { git = "https://github.com/bugadani/esp-hal.git", rev = "38abd6e1ab9ca621d310a198696a300db82c0ad8" }
esp-hal = { git = "https://github.com/bugadani/esp-hal.git", rev = "2a74addee03970f1f79522b96dea285c947ac329" }
esp-hal-embassy = { git = "https://github.com/bugadani/esp-hal.git", rev = "2a74addee03970f1f79522b96dea285c947ac329" }
esp-wifi = { git = "https://github.com/bugadani/esp-hal.git", rev = "2a74addee03970f1f79522b96dea285c947ac329" }
esp-backtrace = { git = "https://github.com/bugadani/esp-hal.git", rev = "2a74addee03970f1f79522b96dea285c947ac329" }
esp-println = { git = "https://github.com/bugadani/esp-hal.git", rev = "2a74addee03970f1f79522b96dea285c947ac329" }
esp-alloc = { git = "https://github.com/bugadani/esp-hal.git", rev = "2a74addee03970f1f79522b96dea285c947ac329" }

[features]
default = ["defmt"]
Expand Down
4 changes: 2 additions & 2 deletions src/board/hardware/v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use esp_hal::{
timer::{
systimer::{SystemTimer, Target},
timg::TimerGroup,
ErasedTimer,
AnyTimer,
},
Async,
};
Expand Down Expand Up @@ -150,7 +150,7 @@ impl super::startup::StartupResources {
wifi: static_cell::make_static! {
WifiDriver::new(
peripherals.WIFI,
ErasedTimer::from(TimerGroup::new(peripherals.TIMG0)
AnyTimer::from(TimerGroup::new(peripherals.TIMG0)
.timer0),
peripherals.RNG,
peripherals.RADIO_CLK,
Expand Down
4 changes: 2 additions & 2 deletions src/board/hardware/v6c6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use esp_hal::{
timer::{
systimer::{SystemTimer, Target},
timg::TimerGroup,
ErasedTimer,
AnyTimer,
},
Async,
};
Expand Down Expand Up @@ -151,7 +151,7 @@ impl super::startup::StartupResources {
wifi: static_cell::make_static! {
WifiDriver::new(
peripherals.WIFI,
ErasedTimer::from(SystemTimer::new(peripherals.SYSTIMER).split::<Target>().alarm0),
AnyTimer::from(SystemTimer::new(peripherals.SYSTIMER).split::<Target>().alarm0),
peripherals.RNG,
peripherals.RADIO_CLK,
)
Expand Down
4 changes: 2 additions & 2 deletions src/board/hardware/v6s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use esp_hal::{
timer::{
systimer::{SystemTimer, Target},
timg::TimerGroup,
ErasedTimer,
AnyTimer,
},
Async,
};
Expand Down Expand Up @@ -148,7 +148,7 @@ impl super::startup::StartupResources {
wifi: static_cell::make_static! {
WifiDriver::new(
peripherals.WIFI,
ErasedTimer::from(TimerGroup::new(peripherals.TIMG0)
AnyTimer::from(TimerGroup::new(peripherals.TIMG0)
.timer0),
peripherals.RNG,
peripherals.RADIO_CLK,
Expand Down
22 changes: 9 additions & 13 deletions src/board/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ use embassy_time::Delay;
use embedded_hal_bus::spi::ExclusiveDevice;
use static_cell::make_static;

use crate::{
board::{
drivers::{battery_monitor::BatteryMonitor, frontend::Frontend},
utils::DummyOutputPin,
wifi::WifiDriver,
AdcClockEnable, AdcDrdy, AdcReset, AdcSpi, ChargerStatus, ChargerStatusPin, Display,
DisplayChipSelect, DisplayDataCommand, DisplayDmaChannel, DisplayMosi, DisplayReset,
DisplaySclk, DisplaySpiInstance, EcgFrontend, TouchDetect, VbusDetect, VbusDetectPin,
},
heap::init_heap,
use crate::board::{
drivers::{battery_monitor::BatteryMonitor, frontend::Frontend},
utils::DummyOutputPin,
wifi::WifiDriver,
AdcClockEnable, AdcDrdy, AdcReset, AdcSpi, ChargerStatus, ChargerStatusPin, Display,
DisplayChipSelect, DisplayDataCommand, DisplayDmaChannel, DisplayMosi, DisplayReset,
DisplaySclk, DisplaySpiInstance, EcgFrontend, TouchDetect, VbusDetect, VbusDetectPin,
};
use esp_hal::{
dma::*,
Expand Down Expand Up @@ -54,7 +51,6 @@ impl StartupResources {
pub(super) fn common_init() {
#[cfg(feature = "log")]
init_logger(log::LevelFilter::Trace); // we let the compile-time log level filter do the work
init_heap();

use core::ptr::addr_of;

Expand Down Expand Up @@ -99,15 +95,15 @@ impl StartupResources {
display_sclk: DisplaySclk,
display_mosi: DisplayMosi,
) -> Display {
let (tx_buffer, tx_descriptors, rx_buffer, rx_descriptors) = dma_buffers!(4092);
let (rx_buffer, rx_descriptors, tx_buffer, tx_descriptors) = dma_buffers!(4092);
let dma_tx_buf = DmaTxBuf::new(tx_descriptors, tx_buffer).unwrap();
let dma_rx_buf = DmaRxBuf::new(rx_descriptors, rx_buffer).unwrap();
let display_spi = Spi::new(display_spi, 40u32.MHz(), SpiMode::Mode0)
.with_sck(display_sclk)
.with_mosi(display_mosi)
.with_cs(display_cs)
.with_dma(display_dma_channel.configure_for_async(false, DmaPriority::Priority0))
.with_buffers(dma_tx_buf, dma_rx_buf);
.with_buffers(dma_rx_buf, dma_tx_buf);

Display::new(
SPIInterface::new(
Expand Down
6 changes: 3 additions & 3 deletions src/board/wifi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use embassy_net::{Config, Stack, StackResources};
use esp_hal::{
peripherals::{RADIO_CLK, RNG, WIFI},
rng::Rng,
timer::ErasedTimer,
timer::AnyTimer,
};
use esp_wifi::{
wifi::{WifiApDevice, WifiDevice, WifiDeviceMode, WifiStaDevice},
Expand Down Expand Up @@ -81,7 +81,7 @@ pub struct WifiDriver {
}

struct WifiInitResources {
timer: ErasedTimer,
timer: AnyTimer,
rng: Rng,
radio_clk: RADIO_CLK,
}
Expand Down Expand Up @@ -132,7 +132,7 @@ impl WifiDriverState {
}

impl WifiDriver {
pub fn new(wifi: WIFI, timer: ErasedTimer, rng: RNG, radio_clk: RADIO_CLK) -> Self {
pub fn new(wifi: WIFI, timer: AnyTimer, rng: RNG, radio_clk: RADIO_CLK) -> Self {
let rng = Rng::new(rng);
Self {
wifi,
Expand Down
15 changes: 0 additions & 15 deletions src/heap.rs

This file was deleted.

3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ use esp_hal::gpio::RtcPin as RtcWakeupPin;
use esp_hal::gpio::RtcPinWithResistors as RtcWakeupPin;

mod board;
mod heap;
pub mod human_readable;
mod stack_protection;
mod states;
Expand Down Expand Up @@ -200,6 +199,8 @@ where

#[main]
async fn main(_spawner: Spawner) {
esp_alloc::heap_allocator!((48 + 96) * 1024);

let resources = StartupResources::initialize().await;

let interrupt_executor = make_static!(InterruptExecutor::new(resources.software_interrupt1));
Expand Down
3 changes: 1 addition & 2 deletions src/states/menu/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::{
board::initialized::Context,
heap::ALLOCATOR,
states::menu::{AppMenu, MenuScreen},
AppState,
};
Expand Down Expand Up @@ -29,7 +28,7 @@ impl SelectValue for MainMenuEvents {
}

pub async fn main_menu(context: &mut Context) -> AppState {
info!("Free heap: {} bytes", ALLOCATOR.free());
info!("Free heap: {} bytes", esp_alloc::HEAP.free());

MainMenu
.display(context)
Expand Down

0 comments on commit 504ac9f

Please sign in to comment.