@@ -9,8 +9,8 @@ use embedded_hal::{digital::blocking::OutputPin, spi::blocking};
99
1010/// SPI device trait
1111///
12- /// SpiDevice represents ownership over a single SPI device on a (possibly shared) bus, selected
13- /// with a CS pin.
12+ /// ` SpiDevice` represents ownership over a single SPI device on a (possibly shared) bus, selected
13+ /// with a CS (Chip Select) pin.
1414///
1515/// See (the docs on embedded-hal)[embedded_hal::spi::blocking] for important information on SPI Bus vs Device traits.
1616pub trait SpiDevice : ErrorType {
@@ -30,17 +30,18 @@ pub trait SpiDevice: ErrorType {
3030 ) ,
3131 > + ' a ;
3232
33- /// Start a transaction against the device.
33+ /// Perform a transaction against the device.
3434 ///
3535 /// - Locks the bus
3636 /// - Asserts the CS (Chip Select) pin.
3737 /// - Calls `f` with an exclusive reference to the bus, which can then be used to do transfers against the device.
38+ /// - [Flushes](SpiBusFlush::flush) the bus.
3839 /// - Deasserts the CS pin.
39- /// - Unlocks the bus,
40+ /// - Unlocks the bus.
4041 ///
41- /// The lock mechanism is implementation-defined. The only requirement is it must prevent two
42+ /// The locking mechanism is implementation-defined. The only requirement is it must prevent two
4243 /// transactions from executing concurrently against the same bus. Examples of implementations are:
43- /// critical sections, blocking mutexes, async mutexes, or returning an error or panicking if the bus is already busy.
44+ /// critical sections, blocking mutexes, async mutexes, returning an error or panicking if the bus is already busy.
4445 fn transaction < ' a , R , F , Fut > ( & ' a mut self , f : F ) -> Self :: TransactionFuture < ' a , R , F , Fut >
4546 where
4647 F : FnOnce ( & ' a mut Self :: Bus ) -> Fut + ' a ,
@@ -74,14 +75,16 @@ impl<T: SpiDevice> SpiDevice for &mut T {
7475 }
7576}
7677
77- /// Flush for SPI bus
78+ /// Flush support for SPI bus
7879pub trait SpiBusFlush : ErrorType {
7980 /// Future returned by the `flush` method.
8081 type FlushFuture < ' a > : Future < Output = Result < ( ) , Self :: Error > > + ' a
8182 where
8283 Self : ' a ;
8384
84- /// Flush
85+ /// Wait until all operations have completed and the bus is idle.
86+ ///
87+ /// See (the docs on embedded-hal)[embedded_hal::spi::blocking] for information on flushing.
8588 fn flush < ' a > ( & ' a mut self ) -> Self :: FlushFuture < ' a > ;
8689}
8790
@@ -104,6 +107,9 @@ pub trait SpiBusRead<Word: 'static + Copy = u8>: SpiBusFlush {
104107 ///
105108 /// The word value sent on MOSI during reading is implementation-defined,
106109 /// typically `0x00`, `0xFF`, or configurable.
110+ ///
111+ /// Implementations are allowed to return before the operation is
112+ /// complete. See (the docs on embedded-hal)[embedded_hal::spi::blocking] for details on flushing.
107113 fn read < ' a > ( & ' a mut self , words : & ' a mut [ Word ] ) -> Self :: ReadFuture < ' a > ;
108114}
109115
@@ -123,6 +129,9 @@ pub trait SpiBusWrite<Word: 'static + Copy = u8>: SpiBusFlush {
123129 Self : ' a ;
124130
125131 /// Write `words` to the slave, ignoring all the incoming words
132+ ///
133+ /// Implementations are allowed to return before the operation is
134+ /// complete. See (the docs on embedded-hal)[embedded_hal::spi::blocking] for details on flushing.
126135 fn write < ' a > ( & ' a mut self , words : & ' a [ Word ] ) -> Self :: WriteFuture < ' a > ;
127136}
128137
@@ -136,7 +145,7 @@ impl<T: SpiBusWrite<Word>, Word: 'static + Copy> SpiBusWrite<Word> for &mut T {
136145
137146/// Read-write SPI bus
138147///
139- /// SpiBus represents **exclusive ownership** over the whole SPI bus, with SCK, MOSI and MISO pins.
148+ /// ` SpiBus` represents **exclusive ownership** over the whole SPI bus, with SCK, MOSI and MISO pins.
140149///
141150/// See (the docs on embedded-hal)[embedded_hal::spi::blocking] for important information on SPI Bus vs Device traits.
142151pub trait SpiBus < Word : ' static + Copy = u8 > : SpiBusRead < Word > + SpiBusWrite < Word > {
@@ -153,6 +162,9 @@ pub trait SpiBus<Word: 'static + Copy = u8>: SpiBusRead<Word> + SpiBusWrite<Word
153162 /// incoming words after `read` has been filled will be discarded. If `write` is shorter,
154163 /// the value of words sent in MOSI after all `write` has been sent is implementation-defined,
155164 /// typically `0x00`, `0xFF`, or configurable.
165+ ///
166+ /// Implementations are allowed to return before the operation is
167+ /// complete. See (the docs on embedded-hal)[embedded_hal::spi::blocking] for details on flushing.
156168 fn transfer < ' a > (
157169 & ' a mut self ,
158170 read : & ' a mut [ Word ] ,
@@ -167,6 +179,9 @@ pub trait SpiBus<Word: 'static + Copy = u8>: SpiBusRead<Word> + SpiBusWrite<Word
167179 /// Write and read simultaneously. The contents of `words` are
168180 /// written to the slave, and the received words are stored into the same
169181 /// `words` buffer, overwriting it.
182+ ///
183+ /// Implementations are allowed to return before the operation is
184+ /// complete. See (the docs on embedded-hal)[embedded_hal::spi::blocking] for details on flushing.
170185 fn transfer_in_place < ' a > (
171186 & ' a mut self ,
172187 words : & ' a mut [ Word ] ,
0 commit comments