HAL-Bus SPI Exclusive Device Unsatisfied Traits

未关闭
#581 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
rust
领域
embedded-iot

调研方向

Reproduce the failure from examples/tiva-c-connected-launchpad/examples/spi_hello.rs, then inspect embedded-hal-bus-0.1.0/src/spi/exclusive.rs and the tm4c129x_hal SPI implementation. Trace the required blocking SPI Write and Default trait bounds and compare them with the HAL's implemented traits. Done means identifying which component causes the mismatch and documenting or correcting the compatible trait usage.

由索引模型根据 Issue 内容生成。

描述

Good morning,

I am trying to understand if the unsatisfied traits error I am receiving in my implementation is due to an error in my implementation, the platform HAL package, or the underlying embedded HAL code.

I am trying to use the embedded_hal_bus ExclusiveDevice struct to wrap an SPI bus into an SPI device.

The SPI bus I have initialised using the platform HAL package (tm4c129x_hal):

let mut spi0 = hal::spi::Spi::spi0(
    p.SSI0,
    (
        porta
            .pa2
            .into_af_push_pull::<hal::gpio::AF15>(&mut porta.control),
        porta
            .pa5
            .into_af_push_pull::<hal::gpio::AF15>(&mut porta.control),
        porta
            .pa4
            .into_af_push_pull::<hal::gpio::AF15>(&mut porta.control),
    ),
    hal::spi::MODE_0,
    1_u32.mhz(),
    &clocks,
    &sc.power_control,
);

I'm then wrapping that up in the ExclusiveDevice object (cs0 is just a normal GPIO pin in output mode).

let mut spi0_dev0 = ExclusiveDevice::new_no_delay(
    &spi0, cs0
);

However, this won't compile when I try to use the write() method of the ExlusiveDevice object. (message is a Vec of bytes).

error[E0599]: the method `write` exists for struct `ExclusiveDevice<&Spi<SSI0, (PA2<AlternateFunction<AF15, ...>>, ..., ...)>, ..., ...>`, but its trait bounds were not satisfied
  --> examples/tiva-c-connected-launchpad/examples/spi_hello.rs:67:27
   |
67 |         let _ = spi0_dev0.write(message);
   |                           ^^^^^ method cannot be called due to unsatisfied trait bounds
   |
  ::: /home/***/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embedded-hal-bus-0.1.0/src/spi/exclusive.rs:19:1
   |
19 | pub struct ExclusiveDevice<BUS, CS, D> {
   | --------------------------------------
   | |
   | doesn't satisfy `_: Default<_>`
   | doesn't satisfy `_: _embedded_hal_blocking_spi_Write<_>`
   |
   = note: the full type name has been written to '.../target/thumbv7em-none-eabihf/debug/examples/spi_hello-b9cc2dd24018ba0e.long-type-5094367532974101285.txt'
   = note: the following trait bounds were not satisfied:
           `ExclusiveDevice<&tm4c129x_hal::spi::Spi<tm4c129x_hal::tm4c129x::SSI0, (PA2<AlternateFunction<AF15, PushPull>>, PA5<AlternateFunction<AF15, PushPull>>, PA4<AlternateFunction<AF15, PushPull>>)>, PA6<Output<PushPull>>, NoDelay>: embedded_hal::blocking::spi::write::Default<_>`
           which is required by `ExclusiveDevice<&tm4c129x_hal::spi::Spi<tm4c129x_hal::tm4c129x::SSI0, (PA2<AlternateFunction<AF15, PushPull>>, PA5<AlternateFunction<AF15, PushPull>>, PA4<AlternateFunction<AF15, PushPull>>)>, PA6<Output<PushPull>>, NoDelay>: tm4c129x_hal::prelude::_embedded_hal_blocking_spi_Write<_>`

What I can't work out is what needs to be changed so that the trait bounds are satisfied. Can anyone shed some light?

主要语言
Rust
星标
2.7k
派生
283
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

rust-embedded/embedded-hal 的其他 Issue

查看 rust-embedded/embedded-hal 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。