Skip to content

Commit 863a3c1

Browse files
hannobraunYatekii
authored andcommitted
Remove RngExt
1 parent 2504eae commit 863a3c1

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

nrf52-hal-common/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ pub mod prelude {
2929

3030
pub use crate::clocks::ClocksExt;
3131
pub use crate::gpio::GpioExt;
32-
pub use crate::rng::RngExt;
3332
pub use crate::rtc::RtcExt;
3433
pub use crate::saadc::SaadcExt;
3534
pub use crate::spim::SpimExt;

nrf52-hal-common/src/rng.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,9 @@
33
//! See nRF52832 product specification, chapter 26.
44
55

6-
use core::ops::Deref;
76
use rand_core::{CryptoRng, RngCore};
87

9-
use crate::target::{
10-
rng,
11-
RNG,
12-
};
13-
14-
15-
pub trait RngExt : Deref<Target=rng::RegisterBlock> + Sized {
16-
fn constrain(self) -> Rng;
17-
}
18-
19-
impl RngExt for RNG {
20-
fn constrain(self) -> Rng {
21-
self.config.write(|w| w.dercen().enabled());
22-
Rng(self)
23-
}
24-
}
8+
use crate::target::RNG;
259

2610

2711
/// Interface to the RNG peripheral
@@ -30,6 +14,11 @@ impl RngExt for RNG {
3014
pub struct Rng(RNG);
3115

3216
impl Rng {
17+
pub fn new(rng: RNG) -> Self {
18+
rng.config.write(|w| w.dercen().enabled());
19+
Self(rng)
20+
}
21+
3322
/// Fill the provided buffer with random bytes
3423
///
3524
/// Will block until the buffer is full.

0 commit comments

Comments
 (0)