Skip to main content

m5stack_core/board/
cores3.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2//! M5Stack CoreS3 board-level bring-up sequences and pin wiring.
3//!
4//! # Internal I²C bus (`I2C_SYS`)
5//!
6//! One shared bus on **GPIO12 (SDA) / GPIO11 (SCL)** carries seven devices; the
7//! BSP drives the first three, the rest are listed for completeness:
8//!
9//! | Device   | Addr | Role                        | BSP driver          |
10//! |----------|------|-----------------------------|---------------------|
11//! | AXP2101  | 0x34 | PMIC / power rails / battery | [`Axp2101Driver`]   |
12//! | AW9523B  | 0x58 | IO expander (LCD/touch reset)| [`Aw9523bDriver`]   |
13//! | FT6336U  | 0x38 | capacitive touch            | `driver::ft6336u`   |
14//! | BMI270   | 0x69 | 6-axis IMU                  | —                   |
15//! | BM8563   | 0x51 | RTC                         | —                   |
16//! | ES7210   | 0x40 | audio ADC (mic)             | —                   |
17//! | AW88298  | 0x36 | speaker amp                 | —                   |
18//!
19//! # AXP2101 power rails (from `Sch_M5_CoreS3_v1.0`)
20//!
21//! | AXP2101 out | Net           | Spec        | Powers                                  |
22//! |-------------|---------------|-------------|-----------------------------------------|
23//! | DCDC1       | `VDD_3V3`     | 3.3 V / 2 A | **Core VDD** — ESP32-S3, **AW9523B**, **FT6336U touch**, LCD logic |
24//! | DCDC3       | `VCC_3V3`     | 3.3 V / 2 A | Peripherals VDD                         |
25//! | DLDO1       | `VCC_BL`      | 3.3 V       | LCD **backlight** (see [`BACKLIGHT_MV`]) |
26//! | ALDO1       | `VDD_1V8`     | 1.8 V/300 mA| AW88298 PA DVDD                         |
27//! | ALDO2       | `VDDA_3V3`    | 3.3 V/300 mA| ES7210 codec VDDP                       |
28//! | ALDO3       | `VDDCAM_3V3`  | 3.3 V/300 mA| camera / codec VDDA                     |
29//! | ALDO4       | `VDD_3V3_SD`  | 3.3 V/300 mA| microSD card VDD                        |
30//! | BLDO1       | `AVDD`        | 2.8 V/300 mA| sensor VDDA                             |
31//! | BLDO2       | `DVDD`        | 1.2 V/300 mA| sensor VDD                              |
32//!
33//! **Reset gating (important):** the **AW9523B `RSTN` is wired to `AXP_PG`**
34//! (AXP2101 power-good) and has an internal ~100 kΩ pull-*low* — so the expander
35//! is held in reset until the AXP asserts power-good. It in turn drives
36//! `LCD_RST` / `TOUCH_RST`, so panel + touch bring-up all chain off it. See
37//! [`power_display_reset`] for the cold-boot readiness handling.
38
39use embedded_hal::digital::{ErrorType, OutputPin};
40use esp_hal::{
41    Blocking,
42    dma::AhbGdmaChannel,
43    gpio::AnyPin,
44    i2c::master::{BusTimeout, Config as I2cConfig, I2c, SoftwareTimeout},
45    peripherals::{BT, PCNT0_UNIT1, Peripherals, RMT, USB_DEVICE, WIFI},
46    spi::master::AnySpi,
47    time::Rate,
48    timer::{AnyTimer, timg::TimerGroup},
49};
50
51use embassy_time::{Duration, Timer};
52
53use crate::board::spi2::Spi2Resources;
54use crate::board::{SoftwareInterrupts, SystemResources};
55use crate::driver::aw9523b::{Aw9523bDriver, Aw9523bError, Aw9523bResources};
56use crate::driver::axp2101::{Axp2101Driver, Axp2101Error};
57use crate::io::shared_i2c::SharedI2cBus;
58
59/// AXP2101 PMIC I2C address on CoreS3.
60const AXP2101_ADDR: u8 = 0x34;
61/// Display backlight rail: AXP2101 DLDO1 @ 3.3 V.
62const BACKLIGHT_MV: u16 = 3300;
63
64/// AW9523B post-power-on I²C-ready time — the datasheet's "minimal wait time for
65/// I2C communication is 5 ms".
66const AW9523B_POR_MS: u64 = 5;
67/// Deterministic settle before the first AW9523B access: 200% of the POR time.
68/// On CoreS3 the expander's `RSTN` has an internal ~100 kΩ pull-*low* and is
69/// wired to `AXP_PG` (AXP2101 power-good), so it is held in reset until the AXP
70/// asserts power-good; at cold power-on `VDD_3V3` is already up (it powers the
71/// running ESP32) but `AXP_PG` may lag, leaving the expander briefly in reset.
72/// Waiting first — rather than poking the bus and retrying — avoids the premature
73/// `AcknowledgeCheckFailed(Address)`, each of which fires one chip-wide I2C clock
74/// reset.
75const AW9523B_SETTLE_MS: u64 = 2 * AW9523B_POR_MS;
76/// Fallback if the expander is still not ready after the settle. This should not
77/// happen in normal operation, so each attempt logs a warning; bounded, with a
78/// final failure logged as an error (best-effort — bring-up continues).
79const AW9523B_FALLBACK_TRIES: u32 = 5;
80const AW9523B_FALLBACK_DELAY_MS: u64 = 5;
81
82/// Fault-injection predicate for the `test-fault-inject` feature: reports the
83/// AW9523B "not ready" for the first `M5_TEST_AW_NACK` post-settle attempts (a
84/// build-time env var), so the cold-boot fallback retry can be regression-tested
85/// on the bench without a real power cycle. Absent from production builds.
86#[cfg(feature = "test-fault-inject")]
87fn aw_fault_inject_active(tries: u32) -> bool {
88    match option_env!("M5_TEST_AW_NACK") {
89        Some(s) => tries < s.parse::<u32>().unwrap_or(0),
90        None => false,
91    }
92}
93
94/// Power + display bring-up over the shared I2C bus: AW9523B IO-expander
95/// (`LCD_RST` + touch reset).
96///
97/// **The panel comes up dark.** Lighting it is [`set_backlight`], and it is the
98/// caller's call because only the caller knows when the panel holds something
99/// worth showing: the ILI9342C keeps its own framebuffer across a CPU reset, so
100/// a backlight switched on here — before the display is even initialised —
101/// re-lights the *previous* boot's last frame for as long as bring-up takes.
102/// Callers that do not care can switch it on immediately after this returns.
103///
104/// A [`AW9523B_SETTLE_MS`] wait precedes the first AW9523B access so the expander
105/// is out of reset (its `RSTN` follows `AXP_PG`) before we touch the bus — this
106/// removes the intermittent cold-boot `AcknowledgeCheckFailed(Address)` that
107/// otherwise fired one chip-wide I2C clock reset at every power-on. A bounded
108/// warn-on-failure retry backs it up in case the settle was not enough.
109///
110/// Best-effort — each sub-step logs and continues on error, so a flaky chip
111/// can't block the display/control loop from coming up. Caller-driven so the
112/// caller owns the *when* and the *which core*: this MUST run on the core that
113/// owns the I2C IRQ (APP core on the regulator — see its `irq-core-binding`
114/// doc), and the caller signals display-readiness after it returns
115/// (`LCD_RST` must precede display init).
116pub async fn power_display_reset(i2c: &'static SharedI2cBus) {
117    let mut aw = Aw9523bDriver::new(Aw9523bResources { i2c });
118    // Deterministic settle for the cold-boot reset-release window (RSTN = AXP_PG)
119    // before the first bus access — see AW9523B_SETTLE_MS.
120    Timer::after(Duration::from_millis(AW9523B_SETTLE_MS)).await;
121    let mut tries = 0u32;
122    loop {
123        // Test hook (feature `test-fault-inject`, absent in production builds):
124        // simulate the AW9523B still being not-ready for the first
125        // `M5_TEST_AW_NACK` post-settle attempts, so the fallback retry is
126        // exercisable on the bench without a power cycle (which the rig can't do).
127        #[cfg(feature = "test-fault-inject")]
128        if aw_fault_inject_active(tries) {
129            tries += 1;
130            if tries > AW9523B_FALLBACK_TRIES {
131                error!(
132                    "AW9523B not ready (fault-inject) after {} retries",
133                    AW9523B_FALLBACK_TRIES
134                );
135                break;
136            }
137            warn!(
138                "[test-fault-inject] AW9523B not-ready simulated; retry {}/{}",
139                tries, AW9523B_FALLBACK_TRIES
140            );
141            Timer::after(Duration::from_millis(AW9523B_FALLBACK_DELAY_MS)).await;
142            continue;
143        }
144        match aw.init().await {
145            Ok(()) => {
146                if tries > 0 {
147                    info!("AW9523B ready after settle + {} retries", tries);
148                }
149                break;
150            }
151            Err(e) => {
152                tries += 1;
153                if tries > AW9523B_FALLBACK_TRIES {
154                    error!(
155                        "AW9523B not ready after {} ms settle + {} retries: {:?}",
156                        AW9523B_SETTLE_MS, AW9523B_FALLBACK_TRIES, e
157                    );
158                    break;
159                }
160                warn!(
161                    "AW9523B not ready after settle; retry {}/{}: {:?}",
162                    tries, AW9523B_FALLBACK_TRIES, e
163                );
164                Timer::after(Duration::from_millis(AW9523B_FALLBACK_DELAY_MS)).await;
165            }
166        }
167    }
168    if let Err(e) = aw.lcd_rst_pulse().await {
169        error!("AW9523B LCD RST failed: {:?}", e);
170    }
171    if let Err(e) = aw.touch_rst_pulse().await {
172        error!("AW9523B TOUCH RST failed: {:?}", e);
173    }
174}
175
176/// Drop every rail via the AXP2101. The board stays down until the power key
177/// is pressed, which reaches the PMIC's PWRON directly.
178///
179/// The counterpart to [`power_display_reset`], and subject to the same rule:
180/// run it on the core that owns the I2C IRQ (APP core on the regulator).
181///
182/// Unlike the bring-up this is **not** best-effort — it returns the error
183/// instead of logging it, because a caller whose power-off failed is still
184/// running and has to say so. On success it does not return at all.
185///
186/// The rails come back on their own while VBUS is present; the PMIC treats
187/// that as a fresh power-on.
188pub async fn power_off(i2c: &'static SharedI2cBus) -> Result<(), Axp2101Error> {
189    Axp2101Driver::new(i2c, AXP2101_ADDR).power_off().await
190}
191
192/// Whether USB is powering the board: the AXP2101's VBUS-good flag.
193pub async fn usb_powered(i2c: &'static SharedI2cBus) -> Result<bool, Axp2101Error> {
194    Axp2101Driver::new(i2c, AXP2101_ADDR).vbus_present().await
195}
196
197/// Switch the panel backlight (AXP2101 DLDO1) on or off.
198///
199/// One function rather than a pair, because both directions are the same write
200/// and both have callers. **On** is how a board lights the panel once it holds
201/// a frame worth showing — [`power_display_reset`] deliberately leaves it dark,
202/// and this is the earliest honest moment. **Off** is what deep sleep needs:
203/// sleep does not touch the PMIC, so without it the board sleeps with a lit
204/// screen — the most visible half of its draw, and the half a user reads as "it
205/// did not turn off". It is also how a board goes dark on demand while it keeps
206/// running.
207///
208/// Not best-effort, unlike the bring-up: the error is returned, because a
209/// caller whose panel stayed dark is the one that has to explain the blank
210/// screen.
211pub async fn set_backlight(i2c: &'static SharedI2cBus, on: bool) -> Result<(), Axp2101Error> {
212    Axp2101Driver::new(i2c, AXP2101_ADDR)
213        .set_dldo1(on, BACKLIGHT_MV)
214        .await
215}
216
217/// Get the expander ready for a touch-woken deep sleep, and say whether the
218/// pad is clear.
219///
220/// `false` means the touch line is asserted right now, so a sleep would end the
221/// moment it began — the caller should not sleep yet.
222pub async fn arm_touch_wake(i2c: &'static SharedI2cBus) -> Result<bool, Aw9523bError> {
223    let mut aw = Aw9523bDriver::new(Aw9523bResources { i2c });
224    aw.arm_touch_interrupt().await?;
225    Ok(!aw.touch_asserted().await?)
226}
227
228// --- GPIO35 MISO/DC mux -----------------------------------------------------
229
230/// GPIO35 bit position in the GPIO1 (pins 32–) register bank.
231const GPIO35_BIT: u32 = 1 << (35 - 32);
232
233/// Zero-sized display-DC "pin" that drives GPIO35 via direct register writes.
234///
235/// On the CoreS3, GPIO35 is hardware-shared between SPI2 MISO (SD-card reads)
236/// and display DC (command/data select). This type does NOT own the pin — the
237/// SPI peripheral owns it for MISO input (`with_miso`), which also routes the
238/// pad through the GPIO matrix. Each `set_low`/`set_high` re-enables the
239/// output driver, so it composes with [`gpio35_disable_output`] (called after
240/// every SD access window).
241///
242/// Two valid configurations for GPIO35 as DC:
243/// 1. **No SD use** (simple display apps): configure GPIO35 as a plain
244///    [`Output`](esp_hal::gpio::Output) instead — a bare register hack without
245///    any pad routing leaves the pad unrouted and DC never toggles.
246/// 2. **Display + SD shared** ([`super::spi2`]): SPI owns the pad as MISO and
247///    DC writes go through this type.
248///
249/// Safety of the mux: the display and the SD card must share one SPI-bus
250/// mutex within a single task, with no `.await` between a DC write and the
251/// SPI transfer — otherwise an SD operation could preempt mid-command.
252pub struct Gpio35Dc;
253
254impl ErrorType for Gpio35Dc {
255    type Error = core::convert::Infallible;
256}
257
258/// Pending DC level, applied by [`apply_pending_dc`] when the display actually
259/// owns the bus.
260static DC_LOW: core::sync::atomic::AtomicBool = core::sync::atomic::AtomicBool::new(false);
261
262impl OutputPin for Gpio35Dc {
263    // RECORD, do not drive.
264    //
265    // GPIO35 is MISO as well as DC. `SpiInterface` sets DC and *then* awaits the
266    // SPI transfer, and that await now blocks on the shared-bus permit — so a
267    // DC write that took effect immediately would hold GPIO35 as an output
268    // while the SD card is mid-command, and every card response would read back
269    // as 0x00. (Observed exactly so: "unexpected token 0x00",
270    // "CrcMismatch(0, ..)", "UnknownDataResponse(0)".)
271    //
272    // The module docs used to require "no `.await` between a DC write and the
273    // SPI transfer". The fair arbiter introduced one, so the requirement is
274    // enforced here instead of being documented and hoped for: the level is
275    // recorded now and applied in [`apply_pending_dc`] once the permit is held.
276    fn set_low(&mut self) -> Result<(), Self::Error> {
277        DC_LOW.store(true, core::sync::atomic::Ordering::Release);
278        Ok(())
279    }
280
281    fn set_high(&mut self) -> Result<(), Self::Error> {
282        DC_LOW.store(false, core::sync::atomic::Ordering::Release);
283        Ok(())
284    }
285}
286
287/// Drive GPIO35 to the DC level recorded by [`Gpio35Dc`].
288///
289/// Call ONLY while holding the SPI2 permit: it takes the pad away from MISO.
290pub fn apply_pending_dc() {
291    unsafe {
292        let gpio = &*esp_hal::peripherals::GPIO::PTR;
293        if DC_LOW.load(core::sync::atomic::Ordering::Acquire) {
294            gpio.out1_w1tc().write(|w| w.bits(GPIO35_BIT));
295        } else {
296            gpio.out1_w1ts().write(|w| w.bits(GPIO35_BIT));
297        }
298        gpio.enable1_w1ts().write(|w| w.bits(GPIO35_BIT));
299    }
300}
301
302/// Disable the GPIO35 output driver so the pad returns to high-impedance
303/// input (SPI2 MISO). Must be called before any SD-card SPI operation — both
304/// at bring-up (after display init; [`super::spi2`] does it) and per-op at
305/// runtime (pass this as the block-device handler's pre-op hook).
306pub fn gpio35_disable_output() {
307    unsafe {
308        let gpio = &*esp_hal::peripherals::GPIO::PTR;
309        gpio.enable1_w1tc().write(|w| w.bits(GPIO35_BIT));
310    }
311}
312
313// --- Pin wiring ---------------------------------------------------------------
314
315/// External M5-Bus pins the BSP does not claim for on-board functions. What
316/// hangs off them (1-Wire sensors, RPM pickups, ...) is application wiring.
317/// Not exhaustive — extend as needed.
318pub struct M5Bus<'a> {
319    /// M5-Bus pin 20 (`BUS_PA_SCL`) → GPIO1.
320    pub gpio1: AnyPin<'a>,
321    /// M5-Bus pin 10 (`BUS_PB_OUT`) → GPIO9.
322    pub gpio9: AnyPin<'a>,
323    /// M5-Bus pin 2 (`BUS_ADC1`) → GPIO10.
324    pub gpio10: AnyPin<'a>,
325    /// M5-Bus pin 8 (`BUS_G5`) → GPIO5.
326    pub gpio5: AnyPin<'a>,
327    /// M5-Bus pin 21 (`BUS_G6`) → GPIO6.
328    pub gpio6: AnyPin<'a>,
329    /// M5-Bus pin 22 (`BUS_G7`) → GPIO7.
330    pub gpio7: AnyPin<'a>,
331    /// M5-Bus pin 13 (`BUS_U0RXD`) → GPIO44 — the ROM console's RX pin,
332    /// unused on CoreS3 (console is USB-Serial-JTAG). Assign as an input:
333    /// a ROM boot-log burst on the TX side (`gpio43`) can then never
334    /// contend with a driven line here.
335    pub gpio44: AnyPin<'a>,
336    /// M5-Bus pin 14 (`BUS_U0TXD`) → GPIO43 — the ROM console's TX pin,
337    /// unused on CoreS3. Assign as an output; see [`Self::gpio44`].
338    pub gpio43: AnyPin<'a>,
339}
340
341/// The CoreS3's peripherals, split into board-fact groups. See
342/// [`Board::split`].
343pub struct Board {
344    /// Display + SD-card shared SPI2 bus (see [`super::spi2`]).
345    pub spi2: Spi2Resources<'static>,
346    /// Internal I2C bus (SDA=GPIO12, SCL=GPIO11) shared by the AXP2101 PMIC
347    /// (0x34), AW9523B expander (0x58) and FT6336U touch (0x38).
348    ///
349    /// Returned BLOCKING: defer `into_async()` to the core that runs the I2C
350    /// tasks — `into_async()` binds the I2C peripheral IRQ to the calling
351    /// core, and on a BLE app it must stay off the core running RWBLE's
352    /// level-1 IRQ (cumulative IRQ blocking otherwise desyncs the BLE
353    /// controller blob and wedges that core's executor).
354    pub i2c0: I2c<'static, Blocking>,
355    pub bt: BT<'static>,
356    pub wifi: WIFI<'static>,
357    /// USB-Serial-JTAG — console + serial-cmd
358    /// ([`crate::io::serial_cmd::SerialCmdResources`]).
359    pub usb_device: USB_DEVICE<'static>,
360    /// RMT — e.g. the 1-Wire driver ([`crate::io::ow_temp::OnewireResources`]).
361    pub rmt: RMT<'static>,
362    /// PCNT — e.g. pulse counting ([`crate::io::rpm::RpmResources`]).
363    pub pcnt: PCNT0_UNIT1<'static>,
364    /// Spare SPI3 unit — the BSP does not drive it, listed for the app to
365    /// claim (same idea as [`Self::rmt`]/[`Self::pcnt`]). Wiring (which
366    /// [`Self::m5bus`] pin is SCK/MOSI/MISO/CS) and the interrupt priority /
367    /// core allocation are application knowledge. Attach the CS pin as the
368    /// peripheral's **hardware** chip-select (`with_cs`), not a
369    /// software-toggled [`esp_hal::gpio::Output`] — some designs depend on a
370    /// sub-microsecond CS gap that software toggling cannot hold. See #27.
371    pub spi3: AnySpi<'static>,
372    /// GDMA channel for [`Self::spi3`] — any free channel works, this is just
373    /// not the one `spi2` already owns (`DMA_CH0`).
374    pub spi3_dma: AhbGdmaChannel<'static>,
375    /// AW9523B `INTN` (GPIO21) — the expander's interrupt output, and with it
376    /// the touch line: `FT6336U TOUCH_INT -> AW9523B P1_2 -> INTN -> GPIO21`.
377    ///
378    /// Active-LOW open-drain, and an **RTC IO**, so it is the board's
379    /// deep-sleep wake source (M5Unified calls it `_wakeupPin`). Nothing in
380    /// this BSP drives the touch panel from it — `TouchButtons` polls over I2C
381    /// — so it is handed to the application whole. See
382    /// [`Aw9523bDriver::arm_touch_interrupt`].
383    pub touch_int: AnyPin<'static>,
384    /// SK6812 LED bars data pin (M-Bus pin 23 → GPIO13 on CoreS3), driven over
385    /// RMT ([`crate::driver::sk6812::Sk6812Driver`]). The M5GO bottom's 5 V LED
386    /// rail is gated by the AW9523B — see `Aw9523bDriver::enable_bus_5v`.
387    pub sk6812: AnyPin<'static>,
388    /// External SPI PSRAM (~8 MB) — feed to `mem::psram_map` / `mem::psram_split`
389    /// (sizing/usage is application policy). [feature `psram`]
390    pub psram: esp_hal::peripherals::PSRAM<'static>,
391    pub m5bus: M5Bus<'static>,
392    pub system: SystemResources<'static>,
393}
394
395impl Board {
396    /// Wire the CoreS3 pin map. Call once with the output of
397    /// [`crate::board::init`] (or `esp_hal::init`); heap setup stays with the
398    /// app (sizing is application policy).
399    pub fn split(peripherals: Peripherals) -> Self {
400        let spi2 = Spi2Resources {
401            spi2: AnySpi::from(peripherals.SPI2),
402            spi2_dma: peripherals.DMA_CH0.into(),
403            sck: AnyPin::from(peripherals.GPIO36),
404            mosi: AnyPin::from(peripherals.GPIO37),
405            miso_dc: AnyPin::from(peripherals.GPIO35),
406            display_cs: AnyPin::from(peripherals.GPIO3),
407            card_cs: AnyPin::from(peripherals.GPIO4),
408        };
409
410        let i2c0 = I2c::new(
411            peripherals.I2C0,
412            I2cConfig::default()
413                .with_frequency(Rate::from_khz(400))
414                // 1 ms: the PPS holds SCL 100-200 us for a read (see fire27).
415                .with_timeout(BusTimeout::BusCycles(400))
416                // Bound async transactions: without a software timeout the
417                // deadline is None, so a stuck/NACKing transaction loops
418                // forever in esp-hal's `check_all_commands_done` yield_now
419                // spin. On an InterruptExecutor that spin pins the core,
420                // masking the very completion IRQ that would end it — the
421                // whole executor wedges (HIL-proven on S3, 2026-06-02). A
422                // finite deadline makes a stuck op return Err instead.
423                .with_software_timeout(SoftwareTimeout::Transaction(
424                    esp_hal::time::Duration::from_millis(25),
425                )),
426        )
427        .expect("I2C0 init failed")
428        .with_sda(AnyPin::from(peripherals.GPIO12))
429        .with_scl(AnyPin::from(peripherals.GPIO11));
430
431        let tg0 = TimerGroup::new(peripherals.TIMG0);
432        let tg1 = TimerGroup::new(peripherals.TIMG1);
433        let system = SystemResources {
434            aes: peripherals.AES,
435            sw_int: SoftwareInterrupts {
436                intr2: peripherals.FROM_CPU_INTR2,
437                intr3: peripherals.FROM_CPU_INTR3,
438            },
439            timer0_0: AnyTimer::from(tg0.timer0),
440            timer0_1: AnyTimer::from(tg0.timer1),
441            timer1_0: AnyTimer::from(tg1.timer0),
442            timer1_1: AnyTimer::from(tg1.timer1),
443            cpu_ctrl: peripherals.CPU_CTRL,
444            lpwr: peripherals.LPWR,
445            flash: peripherals.FLASH,
446            rtc_timer: peripherals.RTC_TIMER,
447        };
448
449        Board {
450            spi2,
451            i2c0,
452            bt: peripherals.BT,
453            wifi: peripherals.WIFI,
454            usb_device: peripherals.USB_DEVICE,
455            rmt: peripherals.RMT,
456            pcnt: peripherals.PCNT0_UNIT1,
457            spi3: AnySpi::from(peripherals.SPI3),
458            spi3_dma: peripherals.DMA_CH1.into(),
459            touch_int: AnyPin::from(peripherals.GPIO21),
460            sk6812: AnyPin::from(peripherals.GPIO13),
461            psram: peripherals.PSRAM,
462            m5bus: M5Bus {
463                gpio1: AnyPin::from(peripherals.GPIO1),
464                gpio9: AnyPin::from(peripherals.GPIO9),
465                gpio10: AnyPin::from(peripherals.GPIO10),
466                gpio5: AnyPin::from(peripherals.GPIO5),
467                gpio6: AnyPin::from(peripherals.GPIO6),
468                gpio7: AnyPin::from(peripherals.GPIO7),
469                gpio44: AnyPin::from(peripherals.GPIO44),
470                gpio43: AnyPin::from(peripherals.GPIO43),
471            },
472            system,
473        }
474    }
475}