@@ -43,16 +43,6 @@ pub enum Port {
43
43
Port1 ,
44
44
}
45
45
46
- #[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
47
- impl Port {
48
- fn bit ( & self ) -> bool {
49
- match self {
50
- Port :: Port0 => false ,
51
- Port :: Port1 => true ,
52
- }
53
- }
54
- }
55
-
56
46
// ===============================================================
57
47
// Implement Generic Pins for this port, which allows you to use
58
48
// other peripherals without having to be completely rust-generic
@@ -85,7 +75,7 @@ impl<MODE> Pin<MODE> {
85
75
let port_bits = match port {
86
76
Port :: Port0 => 0x00 ,
87
77
#[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
88
- Port :: Port1 => 0x80 ,
78
+ Port :: Port1 => 0x20 ,
89
79
} ;
90
80
Self {
91
81
pin_port : pin | port_bits,
@@ -94,15 +84,8 @@ impl<MODE> Pin<MODE> {
94
84
}
95
85
96
86
pub unsafe fn from_psel_bits ( psel_bits : u32 ) -> Self {
97
- let pin = ( psel_bits & 0x1f ) as u8 ;
98
- let port = ( psel_bits & 0x20 ) as u8 ;
99
- let port_bits = match port {
100
- #[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
101
- 0x20 => 0x80 ,
102
- _ => 0x00 ,
103
- } ;
104
87
Self {
105
- pin_port : pin | port_bits ,
88
+ pin_port : psel_bits as u8 ,
106
89
_mode : PhantomData ,
107
90
}
108
91
}
@@ -111,7 +94,7 @@ impl<MODE> Pin<MODE> {
111
94
pub fn pin ( & self ) -> u8 {
112
95
#[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
113
96
{
114
- self . pin_port & 0x7f
97
+ self . pin_port & 0x1f
115
98
}
116
99
117
100
#[ cfg( not( any( feature = "52833" , feature = "52840" ) ) ) ]
@@ -124,7 +107,7 @@ impl<MODE> Pin<MODE> {
124
107
pub fn port ( & self ) -> Port {
125
108
#[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
126
109
{
127
- if self . pin_port & 0x80 == 0 {
110
+ if self . pin_port & 0x20 == 0 {
128
111
Port :: Port0
129
112
} else {
130
113
Port :: Port1
@@ -139,10 +122,7 @@ impl<MODE> Pin<MODE> {
139
122
140
123
#[ inline]
141
124
pub fn psel_bits ( & self ) -> u32 {
142
- let psel = ( self . pin ( ) & 0x1f ) as u32 ;
143
- #[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
144
- let psel = if self . port ( ) . bit ( ) { psel | 0x20 } else { psel } ;
145
- psel
125
+ self . pin_port as u32
146
126
}
147
127
148
128
fn block ( & self ) -> & gpio:: RegisterBlock {
0 commit comments