Skip to content

Commit 4ea7435

Browse files
authored
Merge pull request #559 from Dirbaio/spi-doucment-cs-delays
spi: document `Operation::DelayNs` is not for CS delays.
2 parents 94a7844 + ff1f469 commit 4ea7435

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

embedded-hal/src/spi.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@
160160
//! why, because these methods can't return before receiving all the read data. However it's still technically possible
161161
//! for them to return before the bus is idle. For example, assuming SPI mode 0, the last bit is sampled on the first (rising) edge
162162
//! of SCK, at which point a method could return, but the second (falling) SCK edge still has to happen before the bus is idle.
163+
//!
164+
//! # CS-to-clock delays
165+
//!
166+
//! Many chips require a minimum delay between asserting CS and the first SCK edge, and the last SCK edge and deasserting CS.
167+
//! Drivers should *NOT* use [`Operation::DelayNs`] for this, they should instead document that the user should configure the
168+
//! delays when creating the `SpiDevice` instance, same as they have to configure the SPI frequency and mode. This has a few advantages:
169+
//!
170+
//! - Allows implementations that use hardware-managed CS to program the delay in hardware
171+
//! - Allows the end user more flexibility. For example, they can choose to not configure any delay if their MCU is slow
172+
//! enough to "naturally" do the delay (very common if the delay is in the order of nanoseconds).
163173
164174
use core::fmt::Debug;
165175

0 commit comments

Comments
 (0)