esp_hal/peripherals/
overlay_h2.rs1use core::ops::Deref;
2
3use super::*;
4use crate::efuse::ChipRevision;
5
6impl RNG<'_> {
8 #[inline(always)]
10 #[instability::unstable]
11 pub const fn regs<'a>() -> &'a RngRegisterBlock {
12 &RngRegisterBlock
13 }
14
15 #[inline(always)]
17 #[instability::unstable]
18 pub fn register_block(&self) -> &RngRegisterBlock {
19 &RngRegisterBlock
20 }
21}
22
23#[instability::unstable]
25pub struct RngRegisterBlock;
26
27impl Deref for RngRegisterBlock {
29 type Target = pac::rng::RegisterBlock;
30
31 fn deref(&self) -> &Self::Target {
32 unsafe { &*pac::RNG::ptr() }
33 }
34}
35
36impl RngRegisterBlock {
37 #[instability::unstable]
39 pub fn data(&self) -> &pac::rng::DATA {
40 let ptr = unsafe { pac::RNG::steal().data() as *const pac::rng::DATA };
41 if crate::soc::chip_revision_above(ChipRevision::from_combined(102)) {
42 unsafe { &*ptr.add(1) }
46 } else {
47 unsafe { &*ptr }
48 }
49 }
50}