Remove rand(), fixes #50
This commit is contained in:
parent
11be9170ec
commit
17cf301d4f
@ -7,4 +7,3 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
embassy = { version = "0.1.0", path = "../embassy", features = ["std"] }
|
embassy = { version = "0.1.0", path = "../embassy", features = ["std"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
rand_core = { version = "0.6.0", features = ["std"] }
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use embassy::executor::{raw, Spawner};
|
use embassy::executor::{raw, Spawner};
|
||||||
use embassy::time::TICKS_PER_SECOND;
|
use embassy::time::TICKS_PER_SECOND;
|
||||||
use embassy::time::{Alarm, Clock};
|
use embassy::time::{Alarm, Clock};
|
||||||
use rand_core::{OsRng, RngCore};
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::mem::MaybeUninit;
|
use std::mem::MaybeUninit;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
@ -19,13 +18,6 @@ impl Clock for StdClock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct StdRand;
|
|
||||||
impl embassy::rand::Rand for StdRand {
|
|
||||||
fn rand(&self, buf: &mut [u8]) {
|
|
||||||
OsRng.fill_bytes(buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static mut ALARM_AT: u64 = u64::MAX;
|
static mut ALARM_AT: u64 = u64::MAX;
|
||||||
|
|
||||||
pub struct StdAlarm;
|
pub struct StdAlarm;
|
||||||
@ -101,7 +93,6 @@ impl Executor {
|
|||||||
unsafe {
|
unsafe {
|
||||||
CLOCK_ZERO.as_mut_ptr().write(StdInstant::now());
|
CLOCK_ZERO.as_mut_ptr().write(StdInstant::now());
|
||||||
embassy::time::set_clock(&StdClock);
|
embassy::time::set_clock(&StdClock);
|
||||||
embassy::rand::set_rand(&StdRand);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
@ -13,7 +13,6 @@ pub mod flash;
|
|||||||
pub mod gpio;
|
pub mod gpio;
|
||||||
pub mod interrupt;
|
pub mod interrupt;
|
||||||
pub mod io;
|
pub mod io;
|
||||||
pub mod rand;
|
|
||||||
pub mod time;
|
pub mod time;
|
||||||
pub mod uart;
|
pub mod uart;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
use crate::fmt::*;
|
|
||||||
|
|
||||||
pub trait Rand {
|
|
||||||
fn rand(&self, buf: &mut [u8]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static mut RAND: Option<&'static dyn Rand> = None;
|
|
||||||
|
|
||||||
pub unsafe fn set_rand(rand: &'static dyn Rand) {
|
|
||||||
RAND = Some(rand);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn rand(buf: &mut [u8]) {
|
|
||||||
unsafe { unwrap!(RAND, "No rand set").rand(buf) }
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user