Same for nrf

This commit is contained in:
Ugljesa Jovanovic 2024-09-21 11:41:25 +02:00
parent 766f415ba8
commit 057579bce5
No known key found for this signature in database
GPG Key ID: 5884AC34A0EC67DB
5 changed files with 23 additions and 5 deletions

View File

@ -155,7 +155,7 @@ log = { version = "0.4.14", optional = true }
cortex-m-rt = ">=0.6.15,<0.8"
cortex-m = "0.7.6"
critical-section = "1.1"
rand_core = "0.6.3"
rand_core = "0.9.0-alpha.2"
fixed = "1.10.0"
embedded-storage = "0.3.1"
embedded-storage-async = "0.4.1"

View File

@ -3,6 +3,7 @@
#![macro_use]
use core::cell::{RefCell, RefMut};
use core::convert::Infallible;
use core::future::poll_fn;
use core::marker::PhantomData;
use core::ptr;
@ -199,8 +200,25 @@ impl<'d, T: Instance> rand_core::RngCore for Rng<'d, T> {
self.blocking_fill_bytes(&mut bytes);
u64::from_ne_bytes(bytes)
}
}
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
impl<'d, T: crate::rng::Instance> rand_core::TryRngCore for Rng<'d, T> {
type Error = Infallible;
fn try_next_u32(&mut self) -> Result<u32, Self::Error> {
let mut bytes = [0; 4];
self.blocking_fill_bytes(&mut bytes);
// We don't care about the endianness, so just use the native one.
Ok(u32::from_ne_bytes(bytes))
}
fn try_next_u64(&mut self) -> Result<u64, Self::Error> {
let mut bytes = [0; 8];
self.blocking_fill_bytes(&mut bytes);
Ok(u64::from_ne_bytes(bytes))
}
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Self::Error> {
self.blocking_fill_bytes(dest);
Ok(())
}

View File

@ -23,7 +23,7 @@ embassy-nrf = { version = "0.2.0", path = "../../embassy-nrf", features = ["nrf5
cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
cortex-m-rt = "0.7.0"
panic-probe = { version = "0.3" }
rand = { version = "0.8.4", default-features = false }
rand = { version = "0.9.0-alpha.2", default-features = false }
serde = { version = "1.0.136", default-features = false }
rtos-trace = "0.1.3"
systemview-target = { version = "0.1.2", features = ["callbacks-app", "callbacks-os", "log", "cortex-m"] }

View File

@ -25,7 +25,7 @@ static_cell = { version = "2" }
cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
cortex-m-rt = "0.7.0"
panic-probe = { version = "0.3", features = ["print-defmt"] }
rand = { version = "0.8.4", default-features = false }
rand = { version = "0.9.0-alpha.2", default-features = false }
embedded-storage = "0.3.1"
usbd-hid = "0.8.1"
serde = { version = "1.0.136", default-features = false }

View File

@ -21,7 +21,7 @@ static_cell = "2"
cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
cortex-m-rt = "0.7.0"
panic-probe = { version = "0.3", features = ["print-defmt"] }
rand = { version = "0.8.4", default-features = false }
rand = { version = "0.9.0-alpha.2", default-features = false }
embedded-storage = "0.3.1"
usbd-hid = "0.8.1"
serde = { version = "1.0.136", default-features = false }