• 先配置Rust开发STM32所需的环境,文章地址:

https://fake-rick.github.io/posts/rust%E9%85%8D%E7%BD%AEstm32%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83/

安装项目创建CLI工具

cargo install cargo-embassy

生成项目

cargo embassy init my_project --chip stm32f407vgtx

在Cargo.toml中[dependencies]添加:

embassy-stm32 = { version = "0.1.0", features = ["defmt", "stm32f407vg", "unstable-pac", "memory-x", "time-driver-any", "exti", "chrono"] }

Embed.toml文件

# This file was automatically generated.

[default.general]
chip = "STM32F407VGTx"

[default.reset]
halt_afterwards = false

[default.rtt]
enabled = true

[default.gdb]
enabled = false

运行

cargo run

如果在终端出现以下内容则表示运行成功: