How nanahigh/esp32s3_demo works
Project Type and Purpose
• This is an embedded firmware demo written in Rust for the ESP32-S3 MCU.
• It exercises on-device peripherals: an LCD screen (raw bitmap asset), a sensor, and a PWM-driven output.
• The build system is Cargo (with a build.rs helper) and ESP-IDF or HAL configurations (sdkconfig.defaults).
File Structure
• .cargo/config.toml – custom target or linker overrides for embedded build.
• Cargo.toml + rust-toolchain.toml – Rust package metadata, target toolchain, and dependencies.
• build.rs – build-time steps such as bundling the ferris.raw asset or generating bindings.
• src/main.rs – application entry, initialization of peripherals and main loop.
• src/lib.rs – shared utilities or high-level API surface.
• src/lcd.rs, src/sensor.rs, src/pwm.rs – Rust modules encapsulating drivers for each peripheral.
• src/assets/ferris.raw – bitmap data displayed on the LCD.
README
• Minimal content (“# esp32s3_demo”), so we infer details from code. No external services or network layers in this demo.
Main Components
a. Hardware Layer
– ESP32-S3 MCU core (CPU + on-chip buses)
– External peripherals:
• LCD display (SPI or parallel interface)
• Sensor (I²C, SPI, or ADC input)
• PWM-driven output (motor, LED, buzzer)
b. Software Layer
– Cargo build system
– build.rs (asset embedding / codegen)
– Runtime init (from main.rs)
– Driver modules: lcd.rs, sensor.rs, pwm.rs
– Application logic in main.rs calling into drivers
c. Relationships & Data Flows
– build.rs → embeds ferris.raw → compiled into firmware binary
– MCU Startup → initialize peripherals via driver modules
– sensor.rs reads data → main.rs logic → optionally display or actuate via lcd.rs / pwm.rs
Architectural Patterns & Principles
• Layered driver abstraction: each peripheral has its own module exposing a clean API.
• Single‐threaded, bare-metal execution—no OS.
• Build‐time asset bundling (build.rs) for embedding raw resources.
• Use of Cargo.toml features or conditional compilation for different hardware configs.