diff --git a/embassy-stm32/src/rng.rs b/embassy-stm32/src/rng.rs index 10fc4a75..1e16b847 100644 --- a/embassy-stm32/src/rng.rs +++ b/embassy-stm32/src/rng.rs @@ -32,6 +32,11 @@ impl<'d, T: Instance> Rng<'d, T> { } pub fn reset(&mut self) { + // rng_v2 locks up on seed error, needs reset + #[cfg(rng_v2)] + if unsafe { T::regs().sr().read().seis() } { + T::reset(); + } unsafe { T::regs().cr().modify(|reg| { reg.set_rngen(true); @@ -90,8 +95,10 @@ impl<'d, T: Instance> Rng<'d, T> { impl<'d, T: Instance> RngCore for Rng<'d, T> { fn next_u32(&mut self) -> u32 { loop { - let bits = unsafe { T::regs().sr().read() }; - if bits.drdy() { + let sr = unsafe { T::regs().sr().read() }; + if sr.seis() | sr.ceis() { + self.reset(); + } else if sr.drdy() { return unsafe { T::regs().dr().read() }; } } diff --git a/stm32-data b/stm32-data index cc93f9d1..66252982 160000 --- a/stm32-data +++ b/stm32-data @@ -1 +1 @@ -Subproject commit cc93f9d10395077770bebefb6b9488e06b0e5811 +Subproject commit 66252982939014e94fc4a1b7423c30c3d108ae0b