@@ -19,7 +19,7 @@ use crate::pac::{uarte0_ns as uarte0, UARTE0_NS as UARTE0, UARTE1_NS as UARTE1};
1919#[ cfg( not( feature = "9160" ) ) ]
2020use crate :: pac:: { uarte0, UARTE0 } ;
2121
22- use crate :: gpio:: { Floating , Input , Output , Pin , PushPull } ;
22+ use crate :: gpio:: { Floating , Input , Output , Pin , Port , PushPull } ;
2323use crate :: prelude:: * ;
2424use crate :: slice_in_ram_or;
2525use crate :: target_constants:: EASY_DMA_SIZE ;
@@ -329,8 +329,48 @@ where
329329 }
330330
331331 /// Return the raw interface to the underlying UARTE peripheral.
332- pub fn free ( self ) -> T {
333- self . 0
332+ pub fn free ( self ) -> ( T , Pins ) {
333+ let rxd = self . 0 . psel . rxd . read ( ) ;
334+ let txd = self . 0 . psel . txd . read ( ) ;
335+ let cts = self . 0 . psel . cts . read ( ) ;
336+ let rts = self . 0 . psel . rts . read ( ) ;
337+ (
338+ self . 0 ,
339+ Pins {
340+ #[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
341+ rxd : Pin :: new ( Port :: from_bit ( rxd. port ( ) . bit ( ) ) , rxd. pin ( ) . bits ( ) ) ,
342+ #[ cfg( not( any( feature = "52833" , feature = "52840" ) ) ) ]
343+ rxd : Pin :: new ( Port :: Port0 , rxd. pin ( ) . bits ( ) ) ,
344+ #[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
345+ txd : Pin :: new ( Port :: from_bit ( txd. port ( ) . bit ( ) ) , txd. pin ( ) . bits ( ) ) ,
346+ #[ cfg( not( any( feature = "52833" , feature = "52840" ) ) ) ]
347+ txd : Pin :: new ( Port :: Port0 , txd. pin ( ) . bits ( ) ) ,
348+ cts : if cts. connect ( ) . bit_is_set ( ) {
349+ #[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
350+ {
351+ Some ( Pin :: new ( Port :: from_bit ( cts. port ( ) . bit ( ) ) , cts. pin ( ) . bits ( ) ) )
352+ }
353+ #[ cfg( not( any( feature = "52833" , feature = "52840" ) ) ) ]
354+ {
355+ Some ( Pin :: new ( Port :: Port0 , cts. pin ( ) . bits ( ) ) )
356+ }
357+ } else {
358+ None
359+ } ,
360+ rts : if rts. connect ( ) . bit_is_set ( ) {
361+ #[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
362+ {
363+ Some ( Pin :: new ( Port :: from_bit ( rts. port ( ) . bit ( ) ) , rts. pin ( ) . bits ( ) ) )
364+ }
365+ #[ cfg( not( any( feature = "52833" , feature = "52840" ) ) ) ]
366+ {
367+ Some ( Pin :: new ( Port :: Port0 , rts. pin ( ) . bits ( ) ) )
368+ }
369+ } else {
370+ None
371+ } ,
372+ } ,
373+ )
334374 }
335375}
336376
0 commit comments