diff --git a/src/riot-rs-random/src/lib.rs b/src/riot-rs-random/src/lib.rs index 7e43e8fbc..fe07716bb 100644 --- a/src/riot-rs-random/src/lib.rs +++ b/src/riot-rs-random/src/lib.rs @@ -28,6 +28,12 @@ use rand_core::{RngCore, SeedableRng}; +// The Mutex can probably be simplified +static RNG: embassy_sync::blocking_mutex::Mutex< + embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex, + core::cell::RefCell>, +> = embassy_sync::blocking_mutex::Mutex::new(core::cell::RefCell::new(None)); + // This is one of the points where we can tune easily. If calls to `get_rng()` are rare, it may // even make sense to move the HWRNG in here to get a global ZST. // #[cfg(feature = "main-is-csprng")] @@ -80,20 +86,14 @@ impl RngCore for Rng { mod main_is_csprng { impl rand_core::CryptoRng for super::Rng {} - /// Assert that SelectedRng is CryptoRng, justifying the implementation above. + /// Asserts that SelectedRng is CryptoRng, justifying the implementation above. fn static_assert_is_cryptorng() -> impl rand_core::CryptoRng { let result: super::SelectedRng = unreachable!("This function is for type checking only"); result } } -// The Mutex can probably be simplified -static RNG: embassy_sync::blocking_mutex::Mutex< - embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex, - core::cell::RefCell>, -> = embassy_sync::blocking_mutex::Mutex::new(core::cell::RefCell::new(None)); - -/// Populate the RNG from a seed value. +/// Populates the RNG from a seed value. /// /// This is called by RIOT-rs's initialization functions. pub fn construct_rng(hwrng: impl RngCore) { @@ -104,7 +104,7 @@ pub fn construct_rng(hwrng: impl RngCore) { }); } -/// Obtain a suitably initialized random number generator +/// Obtains a suitably initialized random number generator. /// /// This may be used by threads or tasks. To avoid synchronizion overhead, in the future, /// dependency injection for task and thread generation might be provided through the riot-rs