Skip to content

Commit f1257f2

Browse files
committed
Added transactional SPI interface
See: #178 for work to get here
1 parent 62a5dc6 commit f1257f2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/blocking/spi.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,26 @@ pub mod write_iter {
104104
}
105105
}
106106
}
107+
108+
/// Operation for transactional SPI trait
109+
///
110+
/// This allows composition of SPI operations into a single bus transaction
111+
#[cfg(feature = "unproven")]
112+
#[derive(Debug, PartialEq)]
113+
pub enum Operation<'a, W: 'static> {
114+
/// Write data from the provided buffer, discarding read data
115+
Write(&'a [W]),
116+
/// Write data out while reading data into the provided buffer
117+
Transfer(&'a mut [W]),
118+
}
119+
120+
/// Transactional trait allows multiple actions to be executed
121+
/// as part of a single SPI transaction
122+
#[cfg(feature = "unproven")]
123+
pub trait Transactional<W: 'static> {
124+
/// Associated error type
125+
type Error;
126+
127+
/// Execute the provided transactions
128+
fn exec<'a>(&mut self, operations: &mut [Operation<'a, W>]) -> Result<(), Self::Error>;
129+
}

0 commit comments

Comments
 (0)