Skip to main content

m5stack_core/board/
mod.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2//! Board-level bring-up: pin wiring ([`cores3::Board`]/[`fire27::Board`]),
3//! display + SD shared-bus sequences ([`spi2`], [`display`]), and bring-up
4//! orchestration across drivers.
5
6#[cfg(feature = "cores3")]
7pub mod cores3;
8#[cfg(feature = "display")]
9pub mod display;
10#[cfg(feature = "fire27")]
11pub mod fire27;
12#[cfg(feature = "multicore")]
13mod multicore;
14#[cfg(feature = "multicore")]
15pub use multicore::run_app_core;
16#[cfg(any(feature = "cores3", feature = "fire27"))]
17pub mod spi2;
18
19use esp_hal::{
20    interrupt::software::SoftwareInterruptControl,
21    peripherals::{CPU_CTRL, LPWR, Peripherals},
22    timer::AnyTimer,
23};
24
25/// On-board display resolution — a *board fact*, independent of the `display`
26/// driver feature, defined exactly once per target here. Every subsystem that
27/// needs it (the [`display`] panel builder, [`crate::io::input_caps`]) reads
28/// these rather than re-stating the numbers.
29#[cfg(feature = "cores3")]
30pub const SCREEN_W: u16 = 320;
31#[cfg(feature = "cores3")]
32pub const SCREEN_H: u16 = 240;
33#[cfg(feature = "fire27")]
34pub const SCREEN_W: u16 = 320;
35#[cfg(feature = "fire27")]
36pub const SCREEN_H: u16 = 240;
37
38/// Initialise esp-hal at max CPU clock. Heap setup stays with the app
39/// (sizing is application policy).
40pub fn init() -> Peripherals {
41    esp_hal::init(esp_hal::Config::default().with_cpu_clock(esp_hal::clock::CpuClock::max()))
42}
43
44/// Chip-level (board-independent) system resources: executor timers, software
45/// interrupts, the second core, and the RTC domain (e.g. the production RWDT,
46/// [`crate::io::watchdog`]).
47pub struct SystemResources<'a> {
48    pub sw_int: SoftwareInterruptControl<'a>,
49    pub timer0_0: AnyTimer<'a>,
50    pub timer0_1: AnyTimer<'a>,
51    pub timer1_0: AnyTimer<'a>,
52    pub timer1_1: AnyTimer<'a>,
53    pub cpu_ctrl: CPU_CTRL<'a>,
54    /// RTC peripheral — hardware watchdog backstop, RTC time.
55    pub lpwr: LPWR<'a>,
56}