Skip to content

Commit 593d794

Browse files
committed
Configure GPIOx_ASCR register for STM32L47x/STM32L48x
1 parent 8ef2415 commit 593d794

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/gpio/convert.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,26 @@ impl<MODE, HL, const P: char, const N: u8> Pin<MODE, HL, P, N> {
150150
_pupdr: &mut PUPDR<P>,
151151
) -> Pin<Analog, HL, P, N> {
152152
self.mode::<Analog>();
153+
154+
#[cfg(any(
155+
feature = "stm32l471",
156+
feature = "stm32l475",
157+
feature = "stm32l476",
158+
feature = "stm32l485",
159+
feature = "stm32l486",
160+
))]
161+
{
162+
// On STM32L47x/L48x devices, before any conversion of an input channel coming from
163+
// GPIO pads, it is necessary to configure the corresponding GPIOx_ASCR register
164+
// in the GPIO, in addition to the I/O configuration in analog mode.
165+
let offset = { N };
166+
unsafe {
167+
(*Gpio::<P>::ptr())
168+
.ascr
169+
.modify(|r, w| w.bits(r.bits() | (1 << offset)))
170+
};
171+
}
172+
153173
Pin::new()
154174
}
155175

0 commit comments

Comments
 (0)