File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 1515pub mod delay;
1616pub mod digital;
1717pub mod i2c;
18+ pub mod serial;
1819pub mod spi;
Original file line number Diff line number Diff line change 1+ //! Serial interface
2+
3+ pub use embedded_hal:: serial:: { Error , ErrorKind , ErrorType } ;
4+
5+ /// Write half of a serial interface
6+ pub trait Write < Word : ' static + Copy = u8 > : ErrorType {
7+ /// Writes a slice, blocking until everything has been written.
8+ ///
9+ /// An implementation can choose to buffer the write, returning `Ok(())`
10+ /// after the complete slice has been written to a buffer, but before all
11+ /// words have been sent via the serial interface. To make sure that
12+ /// everything has been sent, call [`flush`](Write::flush) after this function returns.
13+ async fn write ( & mut self , words : & [ Word ] ) -> Result < ( ) , Self :: Error > ;
14+
15+ /// Ensures that none of the previously written data is still buffered
16+ async fn flush ( & mut self ) -> Result < ( ) , Self :: Error > ;
17+ }
18+
19+ impl < T : Write < Word > , Word : ' static + Copy > Write < Word > for & mut T {
20+ async fn write ( & mut self , words : & [ Word ] ) -> Result < ( ) , Self :: Error > {
21+ T :: write ( self , words) . await
22+ }
23+
24+ async fn flush ( & mut self ) -> Result < ( ) , Self :: Error > {
25+ T :: flush ( self ) . await
26+ }
27+ }
Original file line number Diff line number Diff line change @@ -80,9 +80,7 @@ pub trait Write<Word: Copy = u8>: ErrorType {
8080 /// An implementation can choose to buffer the write, returning `Ok(())`
8181 /// after the complete slice has been written to a buffer, but before all
8282 /// words have been sent via the serial interface. To make sure that
83- /// everything has been sent, call [`flush`] after this function returns.
84- ///
85- /// [`flush`]: #tymethod.flush
83+ /// everything has been sent, call [`flush`](Write::flush) after this function returns.
8684 fn write ( & mut self , buffer : & [ Word ] ) -> Result < ( ) , Self :: Error > ;
8785
8886 /// Block until the serial interface has sent all buffered words
You can’t perform that action at this time.
0 commit comments