Skip to main content

ssh_stamp_esp32_boards/
lib.rs

1// SPDX-FileCopyrightText: 2026 Roman Valls Guimera <brainstorm@nopcode.org>
2// SPDX-FileCopyrightText: 2026 Marko Malenic <mmalenic1@gmail.com>
3//
4// SPDX-License-Identifier: GPL-3.0-or-later
5
6//! Board Support Package for ssh-stamp-esp32.
7//!
8//! Board definitions live in `boards/*.toml` (one file per board, containing
9//! pin mappings and an optional documentation URL). The `build.rs` reads
10//! those TOML files and generates all Rust code — board structs, the
11//! [`take_uart_pins!`] macro, and the [`select_board!`] macro — into
12//! `OUT_DIR/boards_gen.rs`, which is included here.
13//!
14//! The TOML files are the single source of truth for pin numbers. No human
15//! writes or edits the generated Rust code.
16#![doc = include_str!(concat!(env!("OUT_DIR"), "/board_catalog.md"))]
17//! # Adding a board
18//!
19//! 1. Create `boards/{board-name}.toml` with a `[pins]` section (`uart_rx`
20//!    and `uart_tx`, plus `can_tx`/`can_rx` and `i2c_sda`/`i2c_scl` for the
21//!    buses the board breaks out), a `[build]` section naming its chip, and
22//!    an optional `url`.
23//! 2. Add `board-{name} = []` to `[features]` in `Cargo.toml`.
24//!
25//! No `.rs` file, no macro editing, no binary changes. The `build.rs`
26//! validates that selected features have matching TOML files, and the board
27//! shows up in the catalog above on the next `cargo xtask <board> doc`.
28#![no_std]
29
30/// Board identification trait.
31///
32/// Each board struct generated from `boards/*.toml` implements this trait.
33/// The `NAME` const is the board's filename (without `.toml`), used for
34/// boot-time logging.
35pub trait Board {
36    /// Human-readable board name (e.g. `"esp32c6-devkitc"`).
37    const NAME: &'static str;
38}
39
40include!(concat!(env!("OUT_DIR"), "/boards_gen.rs"));