Skip to content

Commit b8b5e23

Browse files
Moved configuration constants to the entropy module
1 parent ff7af46 commit b8b5e23

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

chips/stm32u545/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44

55
#![no_std]
66

7+
use stm32u5xx::entropy::{RNG_CR_CONFIG_U545, RNG_HTCR_CONFIG_U545, RNG_NSCR_CONFIG_U545};
78
pub use stm32u5xx::{chip, dma, entropy, exti, gpio, rcc, tim, usart};
89

910
use cortexm33::{CortexM33, CortexMVariant};
1011
// specified in the documentation (NIST compliant RNG configuration table in AN4230 available from www.st.com.)
1112
// that values for the CR, HTCR and NSCR should be 0x00F11F00, 0x76B3 and 0x24C2 respectivly. CR config
1213
// is that value, 0x00F11F00, plus the CONDRST bit
13-
pub const RNG_CR_CONFIG: u32 = 0x40F11F00;
14-
pub const RNG_HTCR_CONFIG: u32 = 0x76B3;
15-
pub const RNG_NSCR_CONFIG: u32 = 0x24C2;
1614

17-
pub type Trng<'a> = stm32u5xx::entropy::Trng<'a, RNG_CR_CONFIG, RNG_HTCR_CONFIG, RNG_NSCR_CONFIG>;
15+
pub type Trng<'a> =
16+
stm32u5xx::entropy::Trng<'a, RNG_CR_CONFIG_U545, RNG_HTCR_CONFIG_U545, RNG_NSCR_CONFIG_U545>;
1817

1918
#[cfg_attr(all(target_arch = "arm", target_os = "none"), used)]
2019
#[cfg_attr(all(target_arch = "arm", target_os = "none"), link_section = ".irqs")]

chips/stm32u5xx/src/entropy.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ use kernel::utilities::registers::interfaces::{ReadWriteable, Readable, Writeabl
1111
use kernel::utilities::registers::{register_bitfields, register_structs, ReadOnly, ReadWrite};
1212
use kernel::utilities::StaticRef;
1313

14+
pub const RNG_CR_CONFIG_U545: u32 = 0x40F11F00;
15+
pub const RNG_HTCR_CONFIG_U545: u32 = 0x76B3;
16+
pub const RNG_NSCR_CONFIG_U545: u32 = 0x24C2;
17+
1418
register_structs! {
1519
/// Random number generator
1620
pub RngRegisters {

0 commit comments

Comments
 (0)