/// Retrieve [`SmartEeprom`] instance using information found in relevant HW
/// registers.
Retrieve [`SmartEeprom`] instance using information found in relevant HW
registers.
Retrieve [ ` SmartEeprom ` ] instance using information found in relevant HW registers .
pub(super) fn retrieve(nvm: &'a mut Nvm) -> Result<'a> {
        use SmartEepromMode as Mode;
        use SmartEepromRetrievalFailure::*;
        if nvm.nvm.seecfg.read().aprdis().bit_is_set() {
            return Err(DisabledAutomaticPageReallocationNotSupported);
        }
        if nvm.nvm.seecfg.read().wmode().is_buffered() {
            return Err(BufferedWritesNotSupported);
        }
        let sblk = nvm.nvm.seestat.read().sblk().bits() as u32;
        let psz = nvm.nvm.seestat.read().psz().bits() as u32;
        let virtual_size = match (sblk, psz) {
            (0, _) => return Err(Disabled),
            (sblk @ 11..=u32::MAX, _) => return Err(InvalidBlockCount { sblk }),
            (_, 8..=u32::MAX) => {
                unreachable!("`NVMCTRL.SEESTAT.PSZ` value is represented with 3 bits in user page")
            }
            others => Self::map_sblk_psz_to_virtual_size(others),
        };
        if nvm.nvm.seestat.read().lock().bit_is_set() {
            Ok(Mode::Locked(SmartEeprom {
                nvm,
                virtual_size,
                __: PhantomData::<Locked>,
            }))
        } else {
            Ok(Mode::Unlocked(SmartEeprom {
                nvm,
                virtual_size,
                __: PhantomData::<Unlocked>,
            }))
        }
    }
pub ( super ) fn retrieve ( nvm : & ' a mut Nvm ) -> Result < ' a > { use SmartEepromMode as Mode ; use SmartEepromRetrievalFailure :: * ; if nvm . nvm . seecfg . read ( ) . aprdis ( ) . bit_is_set ( ) { return Err ( DisabledAutomaticPageReallocationNotSupported ) ; } if nvm . nvm . seecfg . read ( ) . wmode ( ) . is_buffered ( ) { return Err ( BufferedWritesNotSupported ) ; } let sblk = nvm . nvm . seestat . read ( ) . sblk ( ) . bits ( ) as u32 ; let psz = nvm . nvm . seestat . read ( ) . psz ( ) . bits ( ) as u32 ; let virtual_size = match ( sblk , psz ) { ( 0 , _ ) => return Err ( Disabled ) , ( sblk @ 11 ..= u32 :: MAX , _ ) => return Err ( InvalidBlockCount { sblk } ) , ( _ , 8 ..= u32 :: MAX ) => { unreachable ! ( " " ) } others => Self :: map_sblk_psz_to_virtual_size ( others ) , } ; if nvm . nvm . seestat . read ( ) . lock ( ) . bit_is_set ( ) { Ok ( Mode :: Locked ( SmartEeprom { nvm , virtual_size , __ : PhantomData :: < Locked > , } ) ) } else { Ok ( Mode :: Unlocked ( SmartEeprom { nvm , virtual_size , __ : PhantomData :: < Unlocked > , } ) ) } }
Retrieve [`SmartEeprom`] instance using information found in relevant HW
registers.
Retrieve [ ` SmartEeprom ` ] instance using information found in relevant HW registers .
nvm
&'a mut Nvm