Impl Drop for stm32 Rng

This commit is contained in:
Tobias Naumann 2025-05-16 13:05:35 +02:00
parent ee23412d91
commit 466e1ee9ef

View File

@ -186,6 +186,15 @@ impl<'d, T: Instance> Rng<'d, T> {
}
}
impl<'d, T: Instance> Drop for Rng<'d, T> {
fn drop(&mut self) {
T::regs().cr().modify(|reg| {
reg.set_rngen(false);
});
rcc::disable::<T>();
}
}
impl<'d, T: Instance> RngCore for Rng<'d, T> {
fn next_u32(&mut self) -> u32 {
loop {