Skip to main content

Crate embassy_dt_macros

Crate embassy_dt_macros 

Source
Expand description

The procedural macro crate for embassy-dt: device_tree!.

Two configuration sources:

// 1) Rust DSL
device_tree! {
    name "board-name";                // optional; defaults to the DTS model / "board"
    backend stm32;                    // optional; additionally generates the typed STM32 Board
    bus i2c0: I2c { periph: "I2C1", scl: "PB8", sda: "PB7", freq: 400_000 };
    bus uart0: Uart { periph: "USART1", rx: "PA10", tx: "PA9", baud: 115_200 };
    gpio led0: Out { pin: "PC13", level: "high" };
    periph rng0: Rng { periph: "RNG" };
    device bme280: Bme280Driver { bus: i2c0, addr: 0x76 };
}

// 2) DTS/DTSI files (recommended; supports #include and board-level overlay merging)
device_tree! {
    name "nucleo-h723zi";
    backend stm32;
    chip "stm32h723zg";
    from "boards/nucleo-h723zi.dts";
}

chip selects chip-specific code generation rules (e.g. ADC/CRC/CAN construction differences).

The macro validates at compile time: duplicate ids, dangling dependencies and dependency cycles all become direct compile_error!s.

Macros§

device_tree
device_tree! 宏:解析设备树(Rust DSL 或 DTS/DTSI 文件),编译期校验, 生成 TREE 静态描述;声明 backend stm32; 时额外生成类型化 Board。