File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -247,11 +247,18 @@ impl<MODE> Rng<MODE> {
247247 /// Automatically resets the seed error flag upon SeedError but will still return SeedError
248248 /// Upon receiving SeedError the user is expected to keep polling this function until a valid value is returned
249249 pub fn value ( & mut self ) -> Result < u32 , Error > {
250- loop {
250+ ' outer : loop {
251251 let status = self . rb . sr ( ) . read ( ) ;
252252
253253 if status. cecs ( ) . bit ( ) {
254- return Err ( Error :: ClockError ) ;
254+ let sr = self . rb . sr ( ) ;
255+ // Give rng some time to recover from clock disturbance, this time seems to be about a handful of milliseconds
256+ for _ in 0 ..100_000 {
257+ if sr. read ( ) . cecs ( ) . bit_is_clear ( ) {
258+ continue ' outer;
259+ }
260+ }
261+ panic ! ( "Failed to automatically recover from Rng Clock Error" ) ;
255262 } else if status. secs ( ) . bit ( ) {
256263 // Reset seed error flag so as to leave the peripheral in a valid state ready for use
257264 self . rb . sr ( ) . modify ( |_, w| w. seis ( ) . clear_bit ( ) ) ;
You can’t perform that action at this time.
0 commit comments