@@ -19,7 +19,7 @@ use crate::pac::{uarte0_ns as uarte0, UARTE0_NS as UARTE0, UARTE1_NS as UARTE1};
19
19
#[ cfg( not( feature = "9160" ) ) ]
20
20
use crate :: pac:: { uarte0, UARTE0 } ;
21
21
22
- use crate :: gpio:: { Floating , Input , Output , Pin , PushPull } ;
22
+ use crate :: gpio:: { Floating , Input , Output , Pin , Port , PushPull } ;
23
23
use crate :: prelude:: * ;
24
24
use crate :: slice_in_ram_or;
25
25
use crate :: target_constants:: EASY_DMA_SIZE ;
@@ -329,8 +329,48 @@ where
329
329
}
330
330
331
331
/// 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
+ )
334
374
}
335
375
}
336
376
0 commit comments