Skip to content

Commit 8cf26d5

Browse files
bors[bot]Dirbaio
andauthored
Merge #396
396: spi: clarify traits are for master mode. r=eldruin a=Dirbaio All dirvers out there assume the traitsare for master mode. However, there are some HALs out there that impl the traits for SPI in slave mode, which will break when used with drivers. (stm32f1xx-hal, stm32f4xx-hal, stm32l4xx-hal, probably more). If we add SPI slave traits in the future, they should be a separate set of traits because the API would look quite different: - you'd want the API to give extra extra info about the transaction lengths: if you start a transfer with 256-byte buffer but the master only sends 10 bytes (sets CS low, sends 10 bytes, sets CS high), you'd want `transfer` to return, saying "I got only 10 bytes", instead of hanging waiting for the other 246 bytes. - The bus/device split doesn't make sense in slave mode. Also IMO the `spi, spi_slave` naming is fine even if inconsistent, since the vast majority of uses are master mode. I wouldn't name the `spi` module `spi_master`. Co-authored-by: Dario Nieuwenhuis <[email protected]>
2 parents 707b8c4 + edc2a3f commit 8cf26d5

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

embedded-hal-async/src/spi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Serial Peripheral Interface
1+
//! SPI master mode traits.
22
33
use core::{fmt::Debug, future::Future};
44

src/spi/blocking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Blocking SPI API
1+
//! Blocking SPI master mode traits.
22
//!
33
//! # Bus vs Device
44
//!

src/spi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! SPI traits
1+
//! SPI master mode traits.
22
33
pub mod blocking;
44
pub mod nb;

src/spi/nb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Serial Peripheral Interface
1+
//! SPI master mode traits using `nb`.
22
33
use super::ErrorType;
44

0 commit comments

Comments
 (0)