Skip to content

Commit 253714c

Browse files
committed
Add Miso / Mosi constraint to FullDuplex impls
1 parent 10a25aa commit 253714c

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/spi.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,13 @@ where
315315
}
316316
}
317317

318-
impl<SPI, Pins, Word> FullDuplex<Word> for Spi<SPI, Pins, Word>
318+
impl<SPI, Sck, Miso, Mosi, Word> FullDuplex<Word> for Spi<SPI, (Sck, Miso, Mosi), Word>
319319
where
320320
SPI: Instance,
321+
// Full Duplex needs the Miso and Mosi pins.
322+
// SckPin could technically be omitted, though not advisable.
323+
Miso: MisoPin<SPI>,
324+
Mosi: MosiPin<SPI>,
321325
{
322326
type Error = Error;
323327

@@ -360,8 +364,21 @@ where
360364
}
361365
}
362366

363-
impl<SPI, Pins, Word> spi::transfer::Default<Word> for Spi<SPI, Pins, Word> where SPI: Instance {}
364-
impl<SPI, Pins, Word> spi::write::Default<Word> for Spi<SPI, Pins, Word> where SPI: Instance {}
367+
impl<SPI, Sck, Miso, Mosi, Word> spi::transfer::Default<Word> for Spi<SPI, (Sck, Miso, Mosi), Word>
368+
where
369+
SPI: Instance,
370+
Miso: MisoPin<SPI>,
371+
Mosi: MosiPin<SPI>,
372+
{
373+
}
374+
375+
impl<SPI, Sck, Miso, Mosi, Word> spi::write::Default<Word> for Spi<SPI, (Sck, Miso, Mosi), Word>
376+
where
377+
SPI: Instance,
378+
Miso: MisoPin<SPI>,
379+
Mosi: MosiPin<SPI>,
380+
{
381+
}
365382

366383
/// SPI instance
367384
pub trait Instance:

0 commit comments

Comments
 (0)