use crate::peripherals::EFUSE;
#[cfg_attr(not(feature = "unstable"), allow(dead_code))]
mod fields;
#[instability::unstable]
pub use fields::*;
#[instability::unstable]
pub fn flash_encryption() -> bool {
!super::read_field_le::<u8>(SPI_BOOT_CRYPT_CNT)
.count_ones()
.is_multiple_of(2)
}
#[instability::unstable]
pub fn rwdt_multiplier() -> u8 {
super::read_field_le::<u8>(WDT_DELAY_SEL)
}
#[instability::unstable]
pub fn block_version() -> (u8, u8) {
(
super::read_field_le::<u8>(BLK_VERSION_MAJOR),
super::read_field_le::<u8>(BLK_VERSION_MINOR),
)
}
#[instability::unstable]
pub fn rtc_calib_version() -> u8 {
let (_major, minor) = block_version();
if minor >= 1 { 1 } else { 0 }
}
#[instability::unstable]
pub fn major_chip_version() -> u8 {
super::read_field_le(WAFER_VERSION_MAJOR)
}
#[instability::unstable]
pub fn minor_chip_version() -> u8 {
super::read_field_le(WAFER_VERSION_MINOR)
}
#[derive(Debug, Clone, Copy, strum::FromRepr)]
#[repr(u32)]
pub(crate) enum EfuseBlock {
Block0,
Block1,
Block2,
Block3,
Block4,
Block5,
Block6,
Block7,
Block8,
Block9,
Block10,
}
impl EfuseBlock {
pub(crate) fn address(self) -> *const u32 {
let efuse = EFUSE::regs();
match self {
Self::Block0 => efuse.rd_wr_dis0().as_ptr(),
Self::Block1 => efuse.rd_mac_sys0().as_ptr(),
Self::Block2 => efuse.rd_sys_part1_data(0).as_ptr(),
Self::Block3 => efuse.rd_usr_data(0).as_ptr(),
Self::Block4 => efuse.rd_key0_data(0).as_ptr(),
Self::Block5 => efuse.rd_key1_data(0).as_ptr(),
Self::Block6 => efuse.rd_key2_data(0).as_ptr(),
Self::Block7 => efuse.rd_key3_data(0).as_ptr(),
Self::Block8 => efuse.rd_key4_data(0).as_ptr(),
Self::Block9 => efuse.rd_key5_data(0).as_ptr(),
Self::Block10 => efuse.rd_sys_part2_data(0).as_ptr(),
}
}
}