Skip to content

Commit 78905ca

Browse files
committed
fix spi for use with embedded-hal v1.0.0-alpha.8
1 parent cfc394b commit 78905ca

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

spi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ edition = "2018"
1818
all-features = true
1919

2020
[dependencies]
21-
embedded-hal = "1.0.0-alpha.7"
21+
embedded-hal = "1.0.0-alpha.8"
2222
display-interface = "0.4.1"
2323
byte-slice-cast = { version = "0.3.5", default-features = false }

spi/src/lib.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22

33
//! Generic SPI interface for display drivers
44
5-
use embedded_hal::digital::blocking::OutputPin;
6-
use embedded_hal::spi::blocking::Write;
5+
use embedded_hal::{
6+
digital::blocking::OutputPin,
7+
spi::blocking::{SpiBusWrite, SpiDevice},
8+
};
79

810
use display_interface::{DataFormat, DisplayError, WriteOnlyDataCommand};
911

1012
type Result = core::result::Result<(), DisplayError>;
1113

12-
fn send_u8<SPI: Write<u8>>(spi: &mut SPI, words: DataFormat<'_>) -> Result {
14+
fn send_u8<SPI>(spi: &mut SPI, words: DataFormat<'_>) -> Result
15+
where
16+
SPI: SpiDevice,
17+
SPI::Bus: SpiBusWrite,
18+
{
1319
match words {
1420
DataFormat::U8(slice) => spi.write(slice).map_err(|_| DisplayError::BusWriteError),
1521
DataFormat::U16(slice) => {
@@ -115,7 +121,8 @@ pub struct SPIInterface<SPI, DC, CS> {
115121

116122
impl<SPI, DC, CS> SPIInterface<SPI, DC, CS>
117123
where
118-
SPI: Write<u8>,
124+
SPI: SpiDevice,
125+
SPI::Bus: SpiBusWrite,
119126
DC: OutputPin,
120127
CS: OutputPin,
121128
{
@@ -149,7 +156,8 @@ where
149156

150157
impl<SPI, DC, CS> WriteOnlyDataCommand for SPIInterface<SPI, DC, CS>
151158
where
152-
SPI: Write<u8>,
159+
SPI: SpiDevice,
160+
SPI::Bus: SpiBusWrite,
153161
DC: OutputPin,
154162
CS: OutputPin,
155163
{
@@ -172,7 +180,8 @@ pub struct SPIInterfaceNoCS<SPI, DC> {
172180

173181
impl<SPI, DC> SPIInterfaceNoCS<SPI, DC>
174182
where
175-
SPI: Write<u8>,
183+
SPI: SpiDevice,
184+
SPI::Bus: SpiBusWrite,
176185
DC: OutputPin,
177186
{
178187
/// Create new SPI interface for communciation with a display driver
@@ -189,7 +198,8 @@ where
189198

190199
impl<SPI, DC> WriteOnlyDataCommand for SPIInterfaceNoCS<SPI, DC>
191200
where
192-
SPI: Write<u8>,
201+
SPI: SpiDevice,
202+
SPI::Bus: SpiBusWrite,
193203
DC: OutputPin,
194204
{
195205
fn send_commands(&mut self, cmds: DataFormat<'_>) -> Result {

0 commit comments

Comments
 (0)