81
81
type Error = ( ) ;
82
82
83
83
fn read ( & mut self , _pin : & mut PIN ) -> nb:: Result < i16 , Self :: Error > {
84
+ let original_inpsel = self . 0 . config . read ( ) . inpsel ( ) ;
84
85
match PIN :: channel ( ) {
85
86
0 => self . 0 . config . modify ( |_, w| w. psel ( ) . analog_input0 ( ) ) ,
86
87
1 => self . 0 . config . modify ( |_, w| w. psel ( ) . analog_input1 ( ) ) ,
90
91
5 => self . 0 . config . modify ( |_, w| w. psel ( ) . analog_input5 ( ) ) ,
91
92
6 => self . 0 . config . modify ( |_, w| w. psel ( ) . analog_input6 ( ) ) ,
92
93
7 => self . 0 . config . modify ( |_, w| w. psel ( ) . analog_input7 ( ) ) ,
94
+ 8 => self . 0 . config . modify ( |_, w| w. inpsel ( ) . supply_one_third_prescaling ( ) ) ,
95
+ 9 => self . 0 . config . modify ( |_, w| w. inpsel ( ) . supply_two_thirds_prescaling ( ) ) ,
93
96
// This can never happen the only analog pins have already been defined
94
97
// PAY CLOSE ATTENTION TO ANY CHANGES TO THIS IMPL OR THE `channel_mappings!` MACRO
95
98
_ => unsafe { unreachable_unchecked ( ) } ,
@@ -101,6 +104,8 @@ where
101
104
while self . 0 . events_end . read ( ) . bits ( ) == 0 { }
102
105
103
106
self . 0 . events_end . write ( |w| unsafe { w. bits ( 0 ) } ) ;
107
+ // Restore original input selection
108
+ self . 0 . config . modify ( |_, w| w. inpsel ( ) . variant ( original_inpsel. variant ( ) . unwrap ( ) ) ) ;
104
109
105
110
// Max resolution is 10 bits so casting is always safe
106
111
Ok ( self . 0 . result . read ( ) . result ( ) . bits ( ) as i16 )
@@ -129,5 +134,10 @@ channel_mappings! {
129
134
4 => crate :: gpio:: p0:: P0_03 <Input <Floating >>,
130
135
5 => crate :: gpio:: p0:: P0_04 <Input <Floating >>,
131
136
6 => crate :: gpio:: p0:: P0_05 <Input <Floating >>,
132
- 7 => crate :: gpio:: p0:: P0_06 <Input <Floating >>
137
+ 7 => crate :: gpio:: p0:: P0_06 <Input <Floating >>,
138
+ 8 => crate :: adc:: InternalVddOneThird ,
139
+ 9 => crate :: adc:: InternalVddTwoThirds
133
140
}
141
+
142
+ pub struct InternalVddOneThird ;
143
+ pub struct InternalVddTwoThirds ;
0 commit comments