Merge #1205
1205: stm32/rng Fix rng generation lock-up r=Dirbaio a=lucasgranberg This PR fixes a problem where the device gets locked in case of rng errors. The PR also includes a hack for stm32wl based devices where the more complicated RNG peripheral can get stuck on seed errors. Co-authored-by: Lucas Granberg <lukkeg@gmail.com>
This commit is contained in:
commit
e1a0df7d46
@ -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() };
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit cc93f9d10395077770bebefb6b9488e06b0e5811
|
||||
Subproject commit 66252982939014e94fc4a1b7423c30c3d108ae0b
|
Loading…
Reference in New Issue
Block a user