Update MCU dependencies (#6682)

This commit is contained in:
Olivier Goffart 2024-10-29 21:35:51 +01:00 committed by GitHub
parent 7b1e8b4e12
commit d00655b059
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 56 additions and 58 deletions

View file

@ -61,7 +61,7 @@ raw-window-handle = { version = "0.6", optional = true }
image = { workspace = true, optional = true, features = ["default"] }
esp-backtrace = { version = "0.14.0", features = ["panic-handler", "println"], optional = true }
esp-println = { version = "0.11.0", default-features = false, features = ["uart"], optional = true }
esp-println = { version = "0.12.0", default-features = false, features = ["uart"], optional = true }
[build-dependencies]
anyhow = "1.0"

View file

@ -21,20 +21,20 @@ path = "lib.rs"
pico-st7789 = ["slint/unsafe-single-threaded", "rp-pico", "embedded-hal", "embedded-hal-nb", "cortex-m-rt", "embedded-alloc", "fugit", "cortex-m", "display-interface", "display-interface-spi", "mipidsi", "defmt", "defmt-rtt", "slint/libm", "embedded-dma", "embedded-graphics", "euclid/libm"]
stm32h735g = ["slint/unsafe-single-threaded", "cortex-m/critical-section-single-core", "cortex-m-rt","embedded-alloc", "embedded-time", "stm32h7xx-hal/stm32h735", "defmt", "defmt-rtt", "embedded-display-controller", "ft5336", "panic-probe", "slint/libm", "getrandom"]
esp32-s2-kaluga-1 = ["slint/unsafe-single-threaded", "esp-hal/esp32s2", "embedded-hal", "embedded-hal-bus", "esp-alloc", "esp-println/esp32s2", "display-interface", "display-interface-spi", "mipidsi", "embedded-graphics-core", "slint/libm"]
esp32-s3-box = ["slint/unsafe-single-threaded", "esp-hal/esp32s3", "esp-hal/embedded-hal-02", "embedded-hal", "embedded-hal-bus", "esp-alloc", "esp-println/esp32s3", "esp-backtrace/esp32s3", "display-interface", "display-interface-spi", "mipidsi", "embedded-graphics-core", "slint/libm", "tt21100"]
esp32-s3-box = ["slint/unsafe-single-threaded", "esp-hal/esp32s3", "embedded-hal", "embedded-hal-bus", "esp-alloc", "esp-println/esp32s3", "esp-backtrace/esp32s3", "display-interface", "display-interface-spi", "mipidsi", "embedded-graphics-core", "slint/libm", "tt21100"]
[dependencies]
slint = { version = "=1.9.0", path = "../../api/rs/slint", default-features = false, features = ["compat-1-2", "renderer-software"] }
i-slint-core-macros = { version = "=1.9.0", path = "../../internal/core-macros" }
derive_more = "0.99.5"
derive_more = { workspace = true }
embedded-graphics = { version = "0.8", optional = true }
once_cell = { version = "1.9", default-features = false, features = ["alloc"] }
pin-weak = { version = "1", default-features = false }
rgb = "0.8.27"
cfg-if = "1"
embedded-alloc = { version = "0.5", optional = true }
embedded-alloc = { version = "0.6", optional = true }
cortex-m-rt = { version = "0.7", optional = true }
cortex-m = { version = "0.7.2", optional = true }
display-interface = { version = "0.5.0", optional = true }
@ -52,10 +52,10 @@ embedded-time = { version = "0.12.0", optional = true }
embedded-display-controller = { version = "0.2.0", optional = true }
ft5336 = { version = "0.2", optional = true }
esp-hal = { version = "0.19", optional = true }
esp-hal = { version = "0.21", optional = true }
display-interface-spi = { version = "0.5", optional = true }
esp-alloc = { version = "0.4", optional = true }
esp-println = { version = "0.11.0", optional = true }
esp-alloc = { version = "0.5", optional = true }
esp-println = { version = "0.12.0", optional = true }
esp-backtrace = { version = "0.14.0", optional = true, features = ["panic-handler", "println"] }
tt21100 = { version = "0.1", optional = true }

View file

@ -3,18 +3,15 @@
use alloc::boxed::Box;
use alloc::rc::Rc;
use core::{cell::RefCell, convert::Infallible};
use core::{cell::RefCell, convert::Infallible, mem::MaybeUninit};
use display_interface_spi::SPIInterface;
use embedded_hal::digital::OutputPin;
use esp_alloc::EspHeap;
use esp_alloc as _;
pub use esp_hal::entry;
use esp_hal::gpio::{Io, Level, Output};
use esp_hal::spi::{master::Spi, SpiMode};
use esp_hal::system::SystemControl;
use esp_hal::timer::{systimer::SystemTimer, timg::TimerGroup};
use esp_hal::{
clock::ClockControl, delay::Delay, peripherals::Peripherals, prelude::*, rtc_cntl::Rtc,
};
use esp_hal::{delay::Delay, prelude::*, rtc_cntl::Rtc};
use esp_println::println;
type Display<DI, RST> = mipidsi::Display<DI, mipidsi::models::ST7789, RST>;
@ -28,13 +25,16 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
}
}
#[global_allocator]
static ALLOCATOR: EspHeap = EspHeap::empty();
pub fn init() {
const HEAP_SIZE: usize = 160 * 1024;
static mut HEAP: [u8; HEAP_SIZE] = [0; HEAP_SIZE];
unsafe { ALLOCATOR.init(core::ptr::addr_of_mut!(HEAP) as *mut u8, HEAP_SIZE) }
static mut HEAP: MaybeUninit<[u8; HEAP_SIZE]> = MaybeUninit::uninit();
unsafe {
esp_alloc::HEAP.add_region(esp_alloc::HeapRegion::new(
HEAP.as_mut_ptr() as *mut u8,
HEAP_SIZE,
esp_alloc::MemoryCapability::Internal.into(),
));
}
slint::platform::set_platform(Box::new(EspBackend::default()))
.expect("backend already initialized");
}
@ -57,24 +57,22 @@ impl slint::platform::Platform for EspBackend {
fn duration_since_start(&self) -> core::time::Duration {
core::time::Duration::from_millis(
SystemTimer::now() / (SystemTimer::TICKS_PER_SECOND / 1000),
SystemTimer::now() / (SystemTimer::ticks_per_second() / 1000),
)
}
fn run_event_loop(&self) -> Result<(), slint::PlatformError> {
let peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM);
let mut clocks = ClockControl::max(system.clock_control).freeze();
let peripherals = esp_hal::init(esp_hal::Config::default());
// Disable the RTC and TIMG watchdog timers
let mut rtc = Rtc::new(peripherals.LPWR, None);
let mut rtc = Rtc::new(peripherals.LPWR);
rtc.rwdt.disable();
let mut timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks, None);
let mut timer_group0 = TimerGroup::new(peripherals.TIMG0);
timer_group0.wdt.disable();
let mut timer_group1 = TimerGroup::new(peripherals.TIMG1, &clocks, None);
let mut timer_group1 = TimerGroup::new(peripherals.TIMG1);
timer_group1.wdt.disable();
let mut delay = Delay::new(&clocks);
let mut delay = Delay::new();
let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
let mut backlight = Output::new(io.pins.gpio6, Level::High);
@ -87,11 +85,11 @@ impl slint::platform::Platform for EspBackend {
let sck = io.pins.gpio15;
let miso = io.pins.gpio8;
let spi = Spi::new(peripherals.SPI3, 80u32.MHz(), SpiMode::Mode0, &mut clocks).with_pins(
Some(sck),
Some(mosi),
Some(miso),
esp_hal::gpio::NO_PIN,
let spi = Spi::new(peripherals.SPI3, 80u32.MHz(), SpiMode::Mode0).with_pins(
sck,
mosi,
miso,
esp_hal::gpio::NoPin,
);
let spi = embedded_hal_bus::spi::ExclusiveDevice::new_no_delay(spi, cs).unwrap();
let di = SPIInterface::new(spi, Output::new(dc, Level::Low));

View file

@ -4,30 +4,32 @@
use alloc::boxed::Box;
use alloc::rc::Rc;
use core::cell::RefCell;
use core::mem::MaybeUninit;
use display_interface_spi::SPIInterface;
use embedded_graphics_core::geometry::OriginDimensions;
use embedded_hal::digital::OutputPin;
use esp_alloc::EspHeap;
use esp_alloc as _;
use esp_backtrace as _;
use esp_hal::clock::ClockControl;
use esp_hal::delay::Delay;
pub use esp_hal::entry;
use esp_hal::gpio::{Input, Io, Level, Output, Pull};
use esp_hal::rtc_cntl::Rtc;
use esp_hal::spi::{master::Spi, SpiMode};
use esp_hal::system::SystemControl;
use esp_hal::timer::{systimer::SystemTimer, timg::TimerGroup};
use esp_hal::{i2c::I2C, peripherals::Peripherals, prelude::*};
use esp_hal::{i2c::I2c, prelude::*};
use mipidsi::{options::Orientation, Display};
use slint::platform::WindowEvent;
#[global_allocator]
static ALLOCATOR: EspHeap = EspHeap::empty();
pub fn init() {
const HEAP_SIZE: usize = 250 * 1024;
static mut HEAP: [u8; HEAP_SIZE] = [0; HEAP_SIZE];
unsafe { ALLOCATOR.init(core::ptr::addr_of_mut!(HEAP) as *mut u8, HEAP_SIZE) }
static mut HEAP: MaybeUninit<[u8; HEAP_SIZE]> = MaybeUninit::uninit();
unsafe {
esp_alloc::HEAP.add_region(esp_alloc::HeapRegion::new(
HEAP.as_mut_ptr() as *mut u8,
HEAP_SIZE,
esp_alloc::MemoryCapability::Internal.into(),
));
}
slint::platform::set_platform(Box::new(EspBackend::default()))
.expect("backend already initialized");
}
@ -50,27 +52,24 @@ impl slint::platform::Platform for EspBackend {
fn duration_since_start(&self) -> core::time::Duration {
core::time::Duration::from_millis(
SystemTimer::now() / (SystemTimer::TICKS_PER_SECOND / 1000),
SystemTimer::now() / (SystemTimer::ticks_per_second() / 1000),
)
}
fn run_event_loop(&self) -> Result<(), slint::PlatformError> {
let peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM);
let clocks = ClockControl::max(system.clock_control).freeze();
let peripherals = esp_hal::init(esp_hal::Config::default());
let mut rtc = Rtc::new(peripherals.LPWR, None);
let mut rtc = Rtc::new(peripherals.LPWR);
rtc.rwdt.disable();
let mut timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks, None);
let mut timer_group0 = TimerGroup::new(peripherals.TIMG0);
timer_group0.wdt.disable();
let mut timer_group1 = TimerGroup::new(peripherals.TIMG1, &clocks, None);
let mut timer_group1 = TimerGroup::new(peripherals.TIMG1);
timer_group1.wdt.disable();
let mut delay = Delay::new(&clocks);
let mut delay = Delay::new();
let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
let i2c =
I2C::new(peripherals.I2C0, io.pins.gpio8, io.pins.gpio18, 400u32.kHz(), &clocks, None);
let i2c = I2c::new(peripherals.I2C0, io.pins.gpio8, io.pins.gpio18, 400u32.kHz());
let mut touch = tt21100::TT21100::new(i2c, Input::new(io.pins.gpio3, Pull::Up))
.expect("Initialize the touch device");
@ -78,11 +77,11 @@ impl slint::platform::Platform for EspBackend {
let sclk = io.pins.gpio7;
let mosi = io.pins.gpio6;
let spi = Spi::new(peripherals.SPI2, 60u32.MHz(), SpiMode::Mode0, &clocks).with_pins(
Some(sclk),
Some(mosi),
esp_hal::gpio::NO_PIN,
esp_hal::gpio::NO_PIN,
let spi = Spi::new(peripherals.SPI2, 60u32.MHz(), SpiMode::Mode0).with_pins(
sclk,
mosi,
Level::Low,
esp_hal::gpio::NoPin,
);
let dc = Output::new(io.pins.gpio4, Level::Low);

View file

@ -12,7 +12,7 @@ use cortex_m::interrupt::Mutex;
use cortex_m::singleton;
pub use cortex_m_rt::entry;
use defmt_rtt as _;
use embedded_alloc::Heap;
use embedded_alloc::LlffHeap as Heap;
use embedded_hal::digital::{InputPin, OutputPin};
use embedded_hal::spi::{ErrorType, Operation, SpiBus, SpiDevice};
use fugit::{Hertz, RateExtU32};

View file

@ -19,7 +19,7 @@ use stm32h7xx_hal as hal; // global logger
#[cfg(feature = "panic-probe")]
use panic_probe as _;
use embedded_alloc::Heap;
use embedded_alloc::LlffHeap as Heap;
const HEAP_SIZE: usize = 200 * 1024;
static mut HEAP: [u8; HEAP_SIZE] = [0; HEAP_SIZE];
@ -205,7 +205,8 @@ impl Default for StmBackend {
led_green.set_low();
*/
let (fb1, fb2) = (core::ptr::addr_of!(FB1), core::ptr::addr_of!(FB2));
#[allow(unused_unsafe)] //(unsafe required for Rust <= 1.81)
let (fb1, fb2) = unsafe { (core::ptr::addr_of!(FB1), core::ptr::addr_of!(FB2)) };
assert!((hyperram_ptr as usize..hyperram_ptr as usize + hyperram_size)
.contains(&(fb1 as usize)));
assert!((hyperram_ptr as usize..hyperram_ptr as usize + hyperram_size)