Adjust pin-names to FooPin.
Move common bits up to spi/mod.rs. Isolate the RNG interrupt in a sub-module to avoid conflict with the const.
This commit is contained in:
@ -2,18 +2,22 @@
|
||||
|
||||
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};
|
||||
|
||||
//Guse crate::interrupt;
|
||||
use crate::interrupt;
|
||||
use crate::pac;
|
||||
|
||||
pub(crate) static RNG_WAKER: AtomicWaker = AtomicWaker::new();
|
||||
|
||||
pub enum Error {
|
||||
SeedError,
|
||||
ClockError,
|
||||
}
|
||||
|
||||
pub struct Random<T: Instance> {
|
||||
inner: T,
|
||||
}
|
||||
@ -75,11 +79,6 @@ impl<T: Instance> RngCore for Random<T> {
|
||||
|
||||
impl<T: Instance> CryptoRng for Random<T> {}
|
||||
|
||||
pub enum Error {
|
||||
SeedError,
|
||||
ClockError,
|
||||
}
|
||||
|
||||
impl<T: Instance> traits::rng::Rng for Random<T> {
|
||||
type Error = Error;
|
||||
#[rustfmt::skip]
|
||||
@ -146,12 +145,16 @@ macro_rules! impl_rng {
|
||||
|
||||
impl crate::rng::Instance for peripherals::RNG {}
|
||||
|
||||
#[$crate::interrupt]
|
||||
unsafe fn $irq() {
|
||||
let bits = $crate::pac::RNG.sr().read();
|
||||
if bits.drdy() || bits.seis() || bits.ceis() {
|
||||
$crate::pac::RNG.cr().write(|reg| reg.set_ie(false));
|
||||
$crate::rng::RNG_WAKER.wake();
|
||||
mod rng_irq {
|
||||
use crate::interrupt;
|
||||
|
||||
#[interrupt]
|
||||
unsafe fn $irq() {
|
||||
let bits = $crate::pac::RNG.sr().read();
|
||||
if bits.drdy() || bits.seis() || bits.ceis() {
|
||||
$crate::pac::RNG.cr().write(|reg| reg.set_ie(false));
|
||||
$crate::rng::RNG_WAKER.wake();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user