stm32-rs / fdcan

FDCAN peripheral driver for STM32 chips
Apache License 2.0
12 stars 14 forks source link

The crate is not building not being recoginzed as a crate #40

Closed FranciscoAmaro24 closed 1 year ago

FranciscoAmaro24 commented 1 year ago

Im building a project using nucleo h7432xx board and im trying to set up a can bus but everytime i declare the crate the cargo does not build and it says it does not recognize the Interrupt and Interrupts objects implementation

richardeoin commented 1 year ago

This is usually related to either the rt feature on stm32h7xx-hal, or using multiple versions of cortex-m-rt

FranciscoAmaro24 commented 1 year ago
name = "fsm"
version = "0.1.0"
edition = "2021"
enum_dispatch = "0.3.12"

[dependencies]
cortex-m = "0.7.7"
cortex-m-rt = "0.7.3"
cortex-m-rtic = "1.1.4"
nb = "1.1.0"
cortex-m-semihosting = "0.5.0"
stm32h7xx-hal = { version = "0.15.0", features = ["stm32h743","rt"] }
rtt-target =  {version="0.3.1",  features = ["cortex-m"]}
#panic-halt = "0.2.0"
panic-probe = { version = "0.3.1", features = ["print-rtt"] }
fdcan = "0.2.0"

[dependencies.embedded-hal]
version = "0.2"
features = ["unproven"]

[dependencies.stm32h7]
version = "0.15.1"
features = ["stm32h743", "rt"]

Thank you very much for the reply!

My cargo.toml is looking like this and every time i try to build it i get this error description:

"nresolved imports super::interrupt::Interrupt, super::interrupt::Interrupts --> /home/---/.cargo/registry/src/index.crates.io-6f17d22bba15001f/fdcan-0.2.0/src/config.rs:1:28 1 ...::{Interrupt, InterruptLine, Interrupts}; ^^^^^^^^^ ^^^^^^^^^^ no Interrupts in interrupt
no Interrupt in interrupt

. . ... error[E0432]: unresolved imports interrupt::Interrupt, interrupt::Interrupts

Some errors have detailed explanations: E0412, E0432, E0433, E0609. For more information about an error, try rustc --explain E0412. error: could not compile fdcan (lib) due to 29 previous errors", plus all the 29 error why it failed to compile .

richardeoin commented 1 year ago

Ok. Although you have listed the fdcan crate as a dependency, you haven't enabled the CAN "feature flag" in stm32h7xx-hal.

Try updating this line:

stm32h7xx-hal = { version = "0.15.0", features = ["stm32h743","rt","can"] }

See the extra "can" at the end!

There is a list of feature flags in the stm32h7xx-hal documentation. However not knowing about these is an easy mistake to make for beginners. I'm open to suggestions about how the documentation could be improved.

FranciscoAmaro24 commented 1 year ago

Amazing it works, I had tried that but Rust Rover was not recognizing the crate so I thought it was not working appeared red as if the crate did not exist. But that way it compiled. Thank you very much In terms of documentation, it would be nice to know that importing fdcan is needed to run the can feature.