Merge pull request #4214 from embedded-rust-iml/feature/drop-impl-for-stm32-rng

Impl Drop for stm32 Rng
This commit is contained in:
Dario Nieuwenhuis 2025-05-16 14:36:35 +02:00 committed by GitHub
commit a32e665f63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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 {