Skip to content

Commit 4df32b5

Browse files
boondocklabsusbalbin
authored andcommitted
Use rand_core in dependencies, move rand into dev-dependencies for the example.
1 parent 14a0889 commit 4df32b5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ stm32-usbd = { version = "0.7.0", optional = true }
2020
fixed = { version = "1.28.0", optional = true }
2121
embedded-io = "0.6"
2222
stm32-hrtim = { version = "0.1.0", optional = true }
23-
rand = { version = "0.9", default-features = false }
23+
rand_core = { version = "0.9", default-features = false }
2424

2525
[dependencies.cortex-m]
2626
version = "0.7.7"
@@ -73,6 +73,7 @@ bme680 = "0.6.0"
7373
embedded-sdmmc = "0.3.0"
7474
usb-device = { version = "0.3.2", features = ["defmt"] }
7575
usbd-serial = "0.2.2"
76+
rand = { version = "0.9", default-features = false }
7677

7778
#TODO: Separate feature sets
7879
[features]

src/rng.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! True Random Number Generator (TRNG)
22
3-
use rand::TryRngCore;
3+
use rand_core::TryRngCore;
44

55
use crate::{rcc::Rcc, stm32::RNG};
66
use core::{fmt::Formatter, marker::PhantomData};
@@ -27,6 +27,17 @@ impl core::fmt::Display for RngError {
2727
}
2828
}
2929

30+
#[cfg(feature = "defmt")]
31+
impl defmt::Format for RngError {
32+
fn format(&self, fmt: defmt::Formatter) {
33+
match self {
34+
RngError::NotReady => defmt::write!(fmt, "RNG Not ready"),
35+
RngError::SeedError => defmt::write!(fmt, "RNG Seed error"),
36+
RngError::ClockError => defmt::write!(fmt, "RNG Clock error"),
37+
}
38+
}
39+
}
40+
3041
/// Extension trait for the RNG register block
3142
pub trait RngExt {
3243
fn constrain(self, rcc: &mut Rcc) -> Rng<Stopped>;

0 commit comments

Comments
 (0)