diff --git a/src/blocking/mod.rs b/src/blocking/mod.rs index ce8497dbe..5a5fc8a11 100644 --- a/src/blocking/mod.rs +++ b/src/blocking/mod.rs @@ -8,3 +8,4 @@ pub mod delay; pub mod i2c; pub mod serial; pub mod spi; +pub mod rng; diff --git a/src/blocking/rng.rs b/src/blocking/rng.rs new file mode 100644 index 000000000..8e7a73d59 --- /dev/null +++ b/src/blocking/rng.rs @@ -0,0 +1,17 @@ +//! Blocking hardware random number generator + +/// Blocking read +#[cfg(feature = "unproven")] +pub trait Read { + /// Error type + type Error; + + /// Reads enough bytes from hardware random number generator to fill `buffer` + /// + /// If any error is encountered then this function immediately returns. The contents of buf are + /// unspecified in this case. + /// + /// If this function returns an error, it is unspecified how many bytes it has read, but it + /// will never read more than would be necessary to completely fill the buffer. + fn read(&mut self, buffer: &mut [u8]) -> Result<(), Self::Error>; +} diff --git a/src/prelude.rs b/src/prelude.rs index a1fdba42b..43341cbe3 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -23,6 +23,8 @@ pub use ::blocking::spi::{ Transfer as _embedded_hal_blocking_spi_Transfer, Write as _embedded_hal_blocking_spi_Write, }; +#[cfg(feature = "unproven")] +pub use ::blocking::rng::Read as _embedded_hal_blocking_rng_Read; pub use ::digital::OutputPin as _embedded_hal_digital_OutputPin; #[cfg(feature = "unproven")] pub use ::digital::InputPin as _embedded_hal_digital_InputPin;