File tree 2 files changed +48
-0
lines changed
2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ pub use digital::ToggleableOutputPin as _embedded_hal_digital_ToggleableOutputPi
28
28
pub use serial:: Read as _embedded_hal_serial_Read;
29
29
pub use serial:: Write as _embedded_hal_serial_Write;
30
30
pub use spi:: FullDuplex as _embedded_hal_spi_FullDuplex;
31
+ #[ cfg( feature = "unproven" ) ]
32
+ pub use spi:: Send as _embedded_hal_spi_Send;
31
33
pub use timer:: CountDown as _embedded_hal_timer_CountDown;
32
34
#[ cfg( feature = "unproven" ) ]
33
35
pub use watchdog:: Watchdog as _embedded_hal_watchdog_Watchdog;
Original file line number Diff line number Diff line change @@ -26,6 +26,52 @@ pub trait FullDuplex<Word> {
26
26
fn send ( & mut self , word : Word ) -> nb:: Result < ( ) , Self :: Error > ;
27
27
}
28
28
29
+ /// Write (master mode)
30
+ ///
31
+ /// # Notes
32
+ ///
33
+ /// - It's the task of the user of this interface to manage the slave select lines
34
+ #[ cfg( feature = "unproven" ) ]
35
+ pub trait Send < Word > {
36
+ /// An enumeration of SPI errors
37
+ type Error ;
38
+
39
+ /// Sends a word to the slave
40
+ fn send ( & mut self , word : Word ) -> nb:: Result < ( ) , Self :: Error > ;
41
+ }
42
+
43
+ /// Write (master mode)
44
+ #[ cfg( feature = "unproven" ) ]
45
+ pub mod full_duplex {
46
+ /// Default implementation of `spi::FullDuplex<W>` for implementers of
47
+ /// `spi::Send<W>`
48
+ ///
49
+ /// Also needs a `send` method to return the bit read during the last send
50
+ pub trait Default < W > : :: spi:: Send < W > {
51
+ /// Reads the word stored in the shift register
52
+ ///
53
+ /// **NOTE** A word must be sent to the slave before attempting to call this
54
+ /// method.
55
+ fn read ( & mut self ) -> nb:: Result < W , Self :: Error > ;
56
+ }
57
+
58
+ impl < W , S > :: spi:: FullDuplex < W > for S
59
+ where
60
+ S : Default < W > ,
61
+ W : Clone ,
62
+ {
63
+ type Error = S :: Error ;
64
+
65
+ fn read ( & mut self ) -> nb:: Result < W , Self :: Error > {
66
+ self . read ( )
67
+ }
68
+
69
+ fn send ( & mut self , word : W ) -> nb:: Result < ( ) , Self :: Error > {
70
+ self . send ( word)
71
+ }
72
+ }
73
+ }
74
+
29
75
/// Clock polarity
30
76
#[ derive( Clone , Copy , PartialEq ) ]
31
77
pub enum Polarity {
You can’t perform that action at this time.
0 commit comments