rustfmt rng

This commit is contained in:
Dario Nieuwenhuis 2021-05-10 01:19:07 +02:00
parent 6c3299c82f
commit 9492b8555c

View File

@ -1,15 +1,16 @@
#![macro_use]
//use crate::pac::rng::{regs, Rng};
use crate::pac;
use crate::peripherals;
use crate::interrupt;
use futures::future::poll_fn;
use embassy::util::{Unborrow, AtomicWaker};
use embassy_extras::unborrow;
use rand_core::{RngCore, CryptoRng};
use core::future::Future;
use core::task::Poll;
use defmt::*;
use embassy::traits;
use embassy::util::{AtomicWaker, Unborrow};
use embassy_extras::unborrow;
use futures::future::poll_fn;
use rand_core::{CryptoRng, RngCore};
use crate::interrupt;
use crate::pac;
static RNG_WAKER: AtomicWaker = AtomicWaker::new();
@ -55,7 +56,7 @@ impl<T: Instance> RngCore for Random<T> {
loop {
let bits = unsafe { T::regs().sr().read() };
if bits.drdy() {
return unsafe{ T::regs().dr().read() }
return unsafe { T::regs().dr().read() };
}
}
}
@ -83,12 +84,6 @@ impl<T: Instance> RngCore for Random<T> {
impl<T: Instance> CryptoRng for Random<T> {}
use core::future::Future;
use core::marker::PhantomData;
use embassy::traits;
use core::task::{Poll, Context};
use core::pin::Pin;
pub enum Error {
SeedError,
ClockError,
@ -96,6 +91,7 @@ pub enum Error {
impl<T: Instance> traits::rng::Rng for Random<T> {
type Error = Error;
#[rustfmt::skip]
type RngFuture<'a> where Self: 'a = impl Future<Output=Result<(), Self::Error>>;
fn fill_bytes<'a>(&'a mut self, dest: &'a mut [u8]) -> Self::RngFuture<'a> {
@ -127,7 +123,8 @@ impl<T: Instance> traits::rng::Rng for Random<T> {
} else {
Poll::Pending
}
} ).await?;
})
.await?;
let random_bytes = unsafe { T::regs().dr().read() }.to_be_bytes();
for (dest, src) in chunk.iter_mut().zip(random_bytes.iter()) {
*dest = *src