@@ -39,6 +39,14 @@ pub enum BbqError {
3939 MaxFrameTooLarge ,
4040}
4141
42+ impl core:: fmt:: Display for BbqError {
43+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
44+ <Self as core:: fmt:: Debug >:: fmt ( self , f)
45+ }
46+ }
47+
48+ impl core:: error:: Error for BbqError { }
49+
4250/// RX Reception mode
4351#[ derive( Debug , Clone , Copy , Default ) ]
4452#[ non_exhaustive]
@@ -259,6 +267,22 @@ impl BbqParts {
259267 vtable : BbqVtable :: for_lpuart :: < T > ( ) ,
260268 } )
261269 }
270+
271+ /// Access a borrow of the contained RX pin
272+ pub fn rx_pin ( & mut self ) -> Peri < ' _ , AnyPin > {
273+ self . rx_pin . reborrow ( )
274+ }
275+
276+ /// Access a borrow of the contained TX pin
277+ pub fn tx_pin ( & mut self ) -> Peri < ' _ , AnyPin > {
278+ self . tx_pin . reborrow ( )
279+ }
280+
281+ /// Access a borrow of both the RX and TX pin (in that order)
282+ pub fn pins ( & mut self ) -> ( Peri < ' _ , AnyPin > , Peri < ' _ , AnyPin > ) {
283+ let Self { tx_pin, rx_pin, .. } = self ;
284+ ( rx_pin. reborrow ( ) , tx_pin. reborrow ( ) )
285+ }
262286}
263287
264288impl BbqHalfParts {
@@ -448,6 +472,12 @@ impl LpuartBbq {
448472 self . tx . blocking_flush ( ) ;
449473 }
450474
475+ /// Borrow split parts.
476+ pub fn split_ref ( & mut self ) -> ( & mut LpuartBbqRx , & mut LpuartBbqTx ) {
477+ let Self { tx, rx } = self ;
478+ ( rx, tx)
479+ }
480+
451481 /// Teardown the LpuartBbq, retrieving the original parts
452482 pub fn teardown ( self ) -> BbqParts {
453483 let Self { tx, rx } = self ;
@@ -706,6 +736,32 @@ impl LpuartBbqTx {
706736 }
707737}
708738
739+ use embedded_io_async:: ErrorType ;
740+ impl embedded_io_async:: Error for BbqError {
741+ fn kind ( & self ) -> embedded_io:: ErrorKind {
742+ match self {
743+ BbqError :: Basic ( error) => error. kind ( ) ,
744+ BbqError :: Busy => embedded_io:: ErrorKind :: Other ,
745+ BbqError :: WrongParts => embedded_io:: ErrorKind :: Other ,
746+ BbqError :: MaxFrameTooLarge => embedded_io:: ErrorKind :: OutOfMemory ,
747+ }
748+ }
749+ }
750+ impl ErrorType for LpuartBbqTx {
751+ type Error = BbqError ;
752+ }
753+
754+ impl embedded_io_async:: Write for LpuartBbqTx {
755+ fn write ( & mut self , buf : & [ u8 ] ) -> impl Future < Output = Result < usize , Self :: Error > > {
756+ self . write ( buf)
757+ }
758+
759+ async fn flush ( & mut self ) -> Result < ( ) , Self :: Error > {
760+ self . flush ( ) . await ;
761+ Ok ( ( ) )
762+ }
763+ }
764+
709765pub struct LpuartBbqRx {
710766 state : & ' static BbqState ,
711767 info : & ' static Info ,
@@ -988,6 +1044,16 @@ impl LpuartBbqRx {
9881044 }
9891045}
9901046
1047+ impl embedded_io_async:: ErrorType for LpuartBbqRx {
1048+ type Error = BbqError ;
1049+ }
1050+
1051+ impl embedded_io_async:: Read for LpuartBbqRx {
1052+ fn read ( & mut self , buf : & mut [ u8 ] ) -> impl Future < Output = Result < usize , Self :: Error > > {
1053+ self . read ( buf)
1054+ }
1055+ }
1056+
9911057// A wrapper type representing a `&'static mut [u8]` buffer
9921058struct Container {
9931059 ptr : NonNull < u8 > ,
0 commit comments