Rust 如何让中断从stm32f30x中的cortex-m-rt重新导出以运行

Rust 如何让中断从stm32f30x中的cortex-m-rt重新导出以运行,rust,embedded,cortex-m,rust-crates,stm32f3,Rust,Embedded,Cortex M,Rust Crates,Stm32f3,我想用rust和cortex-m-rt和stm32f30x板条箱为STM32F3发现板编写一个程序。更确切地说,我想实现一个外部中断,我想使用#[interrupt]属性。但再出口似乎有问题 说明不应直接使用#[中断]属性,而应使用设备机箱中的重新导出: extern crate device; // the attribute comes from the device crate not from cortex-m-rt use device::interrupt; #[interrup

我想用rust和
cortex-m-rt
stm32f30x
板条箱为STM32F3发现板编写一个程序。更确切地说,我想实现一个外部中断,我想使用
#[interrupt]
属性。但再出口似乎有问题

说明不应直接使用
#[中断]
属性,而应使用设备机箱中的重新导出:

extern crate device;

// the attribute comes from the device crate not from cortex-m-rt
use device::interrupt;

#[interrupt]
fn USART1() {
    // ..
}
事实上,的文档显示,cortex-m-rt板条箱中的属性被重新导出。然而,汇编:

#![no_main]
#![no_std]

use cortex_m_rt::entry;
extern crate stm32f30x;
use stm32f30x::interrupt;

给出了错误

error[E0432]: unresolved import `stm32f30x::interrupt`
 --> src\main.rs:9:5
  |
9 | use stm32f30x::interrupt;
  |     ^^^^^^^^^^^---------
  |     |          |
  |     |          help: a similar name exists in the module (notice the capitalization): `Interrupt`
  |     no `interrupt` in the root
我不知道为什么会发生这样的事情,就像他们一样。我在Cargo.toml中的依赖项如下所示:

[dependencies]
stm32f30x = "0.8.0"
cortex-m-rt = "0.6.3"
cortex-m = "0.6.3"

非常感谢您的帮助:)

您需要启用的
rt
功能

简言之,按如下方式更改依赖项:

[dependencies]
stm32f30x = { version = "0.8.0", features = ["rt"] }
cortex-m-rt = "0.6.3"
cortex-m = "0.6.3"

该功能未出现在上的原因是,该版本早于“功能标志”本身(),这就是页面提到“功能标志数据不适用于此版本”的原因

如果文档中没有提到功能。如果问题是由某个特性引起的,那么最“简单”的方法就是知道。是检查是否包含任何功能。然后,查找任何功能门。在本例中,如果您查看,您将看到以下内容:

[dependencies]
stm32f30x = "0.8.0"
cortex-m-rt = "0.6.3"
cortex-m = "0.6.3"
#[cfg(feature=“rt”)]
pub使用self::Interrupt作为中断;

谢谢,这个解决方案对我很有效:)但它让我想到了一个问题,为什么这里没有记录该功能:?不客气!:)我已经更新了答案,让大家了解一下