Skip to content

Commit cf6fdd4

Browse files
committed
SpiDevice: add guidelines for behaviour of CS pin upon bus failures
1 parent d5cdf33 commit cf6fdd4

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

embedded-hal-async/src/spi.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ pub trait SpiDevice: ErrorType {
6666
/// transactions from executing concurrently against the same bus. Examples of implementations are:
6767
/// critical sections, blocking mutexes, async mutexes, returning an error or panicking if the bus is already busy.
6868
///
69+
/// On bus errors the implementation should try to deassert CS.
70+
/// If an error occurs while deasserting CS the bus error should take priority as the return value.
71+
///
6972
/// The current state of the Rust typechecker doesn't allow expressing the necessary lifetime constraints, so
7073
/// the `f` closure receives a lifetime-less `*mut Bus` raw pointer instead. The pointer is guaranteed
7174
/// to be valid for the entire duration the closure is running, so dereferencing it is safe.

src/spi/blocking.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ pub trait SpiDevice: ErrorType {
195195
/// The locking mechanism is implementation-defined. The only requirement is it must prevent two
196196
/// transactions from executing concurrently against the same bus. Examples of implementations are:
197197
/// critical sections, blocking mutexes, returning an error or panicking if the bus is already busy.
198+
///
199+
/// On bus errors the implementation should try to deassert CS.
200+
/// If an error occurs while deasserting CS the bus error should take priority as the return value.
198201
fn transaction<R>(
199202
&mut self,
200203
f: impl FnOnce(&mut Self::Bus) -> Result<R, <Self::Bus as ErrorType>::Error>,

0 commit comments

Comments
 (0)