///Register `PRIVCFGR` reader
pub type R = crate::R<PRIVCFGRrs>;
///Register `PRIVCFGR` writer
pub type W = crate::W<PRIVCFGRrs>;
/**RCC secure functions privilege configuration Set and reset by software. This bit can be written only by a secure privileged access.

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SPRIV {
    ///0: RCC functions can be modified by privileged or unprivileged access
    Any = 0,
    ///1: RCC functions can only be modified by privileged access
    PrivilegedOnly = 1,
}
impl From<SPRIV> for bool {
    #[inline(always)]
    fn from(variant: SPRIV) -> Self {
        variant as u8 != 0
    }
}
///Field `SPRIV` reader - RCC secure functions privilege configuration Set and reset by software. This bit can be written only by a secure privileged access.
pub type SPRIV_R = crate::BitReader<SPRIV>;
impl SPRIV_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> SPRIV {
        match self.bits {
            false => SPRIV::Any,
            true => SPRIV::PrivilegedOnly,
        }
    }
    ///RCC functions can be modified by privileged or unprivileged access
    #[inline(always)]
    pub fn is_any(&self) -> bool {
        *self == SPRIV::Any
    }
    ///RCC functions can only be modified by privileged access
    #[inline(always)]
    pub fn is_privileged_only(&self) -> bool {
        *self == SPRIV::PrivilegedOnly
    }
}
///Field `SPRIV` writer - RCC secure functions privilege configuration Set and reset by software. This bit can be written only by a secure privileged access.
pub type SPRIV_W<'a, REG> = crate::BitWriter<'a, REG, SPRIV>;
impl<'a, REG> SPRIV_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///RCC functions can be modified by privileged or unprivileged access
    #[inline(always)]
    pub fn any(self) -> &'a mut crate::W<REG> {
        self.variant(SPRIV::Any)
    }
    ///RCC functions can only be modified by privileged access
    #[inline(always)]
    pub fn privileged_only(self) -> &'a mut crate::W<REG> {
        self.variant(SPRIV::PrivilegedOnly)
    }
}
///Field `NSPRIV` reader - RCC non-secure functions privilege configuration Set and reset by software. This bit can be written only by privileged access, secure or non-secure.
pub use SPRIV_R as NSPRIV_R;
///Field `NSPRIV` writer - RCC non-secure functions privilege configuration Set and reset by software. This bit can be written only by privileged access, secure or non-secure.
pub use SPRIV_W as NSPRIV_W;
impl R {
    ///Bit 0 - RCC secure functions privilege configuration Set and reset by software. This bit can be written only by a secure privileged access.
    #[inline(always)]
    pub fn spriv(&self) -> SPRIV_R {
        SPRIV_R::new((self.bits & 1) != 0)
    }
    ///Bit 1 - RCC non-secure functions privilege configuration Set and reset by software. This bit can be written only by privileged access, secure or non-secure.
    #[inline(always)]
    pub fn nspriv(&self) -> NSPRIV_R {
        NSPRIV_R::new(((self.bits >> 1) & 1) != 0)
    }
}
impl core::fmt::Debug for R {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("PRIVCFGR")
            .field("spriv", &self.spriv())
            .field("nspriv", &self.nspriv())
            .finish()
    }
}
impl W {
    ///Bit 0 - RCC secure functions privilege configuration Set and reset by software. This bit can be written only by a secure privileged access.
    #[inline(always)]
    pub fn spriv(&mut self) -> SPRIV_W<PRIVCFGRrs> {
        SPRIV_W::new(self, 0)
    }
    ///Bit 1 - RCC non-secure functions privilege configuration Set and reset by software. This bit can be written only by privileged access, secure or non-secure.
    #[inline(always)]
    pub fn nspriv(&mut self) -> NSPRIV_W<PRIVCFGRrs> {
        NSPRIV_W::new(self, 1)
    }
}
/**RCC privilege configuration register

You can [`read`](crate::Reg::read) this register and get [`privcfgr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`privcfgr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).*/
pub struct PRIVCFGRrs;
impl crate::RegisterSpec for PRIVCFGRrs {
    type Ux = u32;
}
///`read()` method returns [`privcfgr::R`](R) reader structure
impl crate::Readable for PRIVCFGRrs {}
///`write(|w| ..)` method takes [`privcfgr::W`](W) writer structure
impl crate::Writable for PRIVCFGRrs {
    type Safety = crate::Unsafe;
    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
}
///`reset()` method sets PRIVCFGR to value 0
impl crate::Resettable for PRIVCFGRrs {
    const RESET_VALUE: u32 = 0;
}
