File tree 1 file changed +13
-7
lines changed
1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -31,16 +31,22 @@ pub(in crate::pio) unsafe trait RegisterInterface {
31
31
fn into_peripheral ( & mut self , cfg : DynPeripheral ) {
32
32
use DynPeripheral :: * ;
33
33
let ( sr0, sr1) = match cfg {
34
- A => ( 0 , 0 ) ,
35
- B => ( 1 , 0 ) ,
36
- C => ( 0 , 1 ) ,
37
- D => ( 1 , 1 ) ,
34
+ A => ( false , false ) ,
35
+ B => ( true , false ) ,
36
+ C => ( false , true ) ,
37
+ D => ( true , true ) ,
38
38
} ;
39
39
let idx = self . id ( ) . num ;
40
40
41
- // configure function
42
- self . reg ( ) . pio_abcdsr [ 0 ] . modify ( |_, w| unsafe { w. bits ( sr0 << idx) } ) ;
43
- self . reg ( ) . pio_abcdsr [ 1 ] . modify ( |_, w| unsafe { w. bits ( sr1 << idx) } ) ;
41
+ // configure function, preserving other pin bits
42
+ for ( i, bit) in ( 0 ..=1 ) . zip ( [ sr0, sr1] ) {
43
+ self . reg ( ) . pio_abcdsr [ i] . modify ( |r, w| unsafe {
44
+ w. bits ( match bit {
45
+ true => r. bits ( ) | 1 << idx,
46
+ false => r. bits ( ) & !( 1 << idx) ,
47
+ } )
48
+ } ) ;
49
+ }
44
50
45
51
// give pin to peripheral
46
52
self . reg ( ) . pio_pdr . write ( |w| unsafe { w. bits ( self . mask ( ) ) } ) ;
You can’t perform that action at this time.
0 commit comments