Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use embedded_hal::blocking::spi::Write instead of FullDuplex #28

Closed
wants to merge 2 commits into from

Conversation

andy31415
Copy link

Issue description

Trying to compile the stm32f0 examples results in an error because embedded_hal::spi::FullDuplex is not implemented for SPI on stm32f0xx_hal:

error[E0277]: the trait bound `Spi<stm32f0xx_hal::pac::SPI1, stm32f0xx_hal::gpio::gpioa::PA5<Alternate<stm32f0xx_hal::gpio::AF0>>, stm32f0xx_hal::gpio::gpioa::PA6<Alternate<stm32f0xx_hal::gpio::AF0>>, stm32f0xx_hal::gpio::gpioa::PA7<Alternate<stm32f0xx_hal::gpio::AF0>>, EightBit>: _embedded_hal_spi_FullDuplex<u8>` is not satisfied
  --> examples/stm32f0_ws2812_spi_blink.rs:54:34
   |
54 |         let mut ws = Ws2812::new(spi);
   |                      ----------- ^^^ the trait `_embedded_hal_spi_FullDuplex<u8>` is not implemented for `Spi<stm32f0xx_hal::pac::SPI1, stm32f0xx_hal::gpio::gpioa::PA5<Alternate<stm32f0xx_hal::gpio::AF0>>, stm32f0xx_hal::gpio::gpioa::PA6<Alternate<stm32f0xx_hal::gpio::AF0>>, stm32f0xx_hal::gpio::gpioa::PA7<Alternate<stm32f0xx_hal::gpio::AF0>>, EightBit>`
   |                      |
   |                      required by a bound introduced by this call
   |
note: required by a bound in `ws2812_spi::Ws2812::<SPI>::new`
  --> /home/andrei/.cargo/registry/src/github.com-1ecc6299db9ec823/ws2812-spi-0.4.0/src/lib.rs:49:10
   |
49 |     SPI: FullDuplex<u8, Error = E>,
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ws2812_spi::Ws2812::<SPI>::new`

However embedded_hal::blocking::spi::Write is implemented. This implementation should be available for all FullDuplex implementations:

https://docs.rs/embedded-hal/latest/embedded_hal/blocking/spi/write/trait.Default.html

Testing

Compiled and ran examples on a STM32F030C8Tx, observed LED examples worked well.
Compiled other targets and observed compilation finished (did not run, however this seems to confirm that Write trait is implemented where previously FullDuplex was provided).

This replaces FullDuplex as on some HALs (specifically
stm32f0 hals) FullDuplex is NOT implemeneted however
write is.

All FullDuplex implementations have a Write Default
implementation.
@david-sawatzke
Copy link
Collaborator

This isn't a distinction offered by e-h 1.0.0 anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants