#[doc = "Register `BBPS` reader"]
pub type R = crate::R<BbpsSpec>;
#[doc = "Register `BBPS` writer"]
pub type W = crate::W<BbpsSpec>;
#[doc = "Battery Backup Configuration\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum Confselect {
    #[doc = "0: The backup domain is always supplied by main power"]
    None = 0,
    #[doc = "1: The power switch is handled by the automatic power switch"]
    Apws = 1,
    #[doc = "2: The backup domain is always supplied by battery backup power"]
    Forced = 2,
    #[doc = "3: The power switch is handled by the BOD33"]
    Bod33 = 3,
}
impl From<Confselect> for u8 {
    #[inline(always)]
    fn from(variant: Confselect) -> Self {
        variant as _
    }
}
impl crate::FieldSpec for Confselect {
    type Ux = u8;
}
impl crate::IsEnum for Confselect {}
#[doc = "Field `CONF` reader - Battery Backup Configuration"]
pub type ConfR = crate::FieldReader<Confselect>;
impl ConfR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Confselect {
        match self.bits {
            0 => Confselect::None,
            1 => Confselect::Apws,
            2 => Confselect::Forced,
            3 => Confselect::Bod33,
            _ => unreachable!(),
        }
    }
    #[doc = "The backup domain is always supplied by main power"]
    #[inline(always)]
    pub fn is_none(&self) -> bool {
        *self == Confselect::None
    }
    #[doc = "The power switch is handled by the automatic power switch"]
    #[inline(always)]
    pub fn is_apws(&self) -> bool {
        *self == Confselect::Apws
    }
    #[doc = "The backup domain is always supplied by battery backup power"]
    #[inline(always)]
    pub fn is_forced(&self) -> bool {
        *self == Confselect::Forced
    }
    #[doc = "The power switch is handled by the BOD33"]
    #[inline(always)]
    pub fn is_bod33(&self) -> bool {
        *self == Confselect::Bod33
    }
}
#[doc = "Field `CONF` writer - Battery Backup Configuration"]
pub type ConfW<'a, REG> = crate::FieldWriter<'a, REG, 2, Confselect, crate::Safe>;
impl<'a, REG> ConfW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
    #[doc = "The backup domain is always supplied by main power"]
    #[inline(always)]
    pub fn none(self) -> &'a mut crate::W<REG> {
        self.variant(Confselect::None)
    }
    #[doc = "The power switch is handled by the automatic power switch"]
    #[inline(always)]
    pub fn apws(self) -> &'a mut crate::W<REG> {
        self.variant(Confselect::Apws)
    }
    #[doc = "The backup domain is always supplied by battery backup power"]
    #[inline(always)]
    pub fn forced(self) -> &'a mut crate::W<REG> {
        self.variant(Confselect::Forced)
    }
    #[doc = "The power switch is handled by the BOD33"]
    #[inline(always)]
    pub fn bod33(self) -> &'a mut crate::W<REG> {
        self.variant(Confselect::Bod33)
    }
}
#[doc = "Field `WAKEEN` reader - Wake Enable"]
pub type WakeenR = crate::BitReader;
#[doc = "Field `WAKEEN` writer - Wake Enable"]
pub type WakeenW<'a, REG> = crate::BitWriter<'a, REG>;
#[doc = "Field `PSOKEN` reader - Power Supply OK Enable"]
pub type PsokenR = crate::BitReader;
#[doc = "Field `PSOKEN` writer - Power Supply OK Enable"]
pub type PsokenW<'a, REG> = crate::BitWriter<'a, REG>;
impl R {
    #[doc = "Bits 0:1 - Battery Backup Configuration"]
    #[inline(always)]
    pub fn conf(&self) -> ConfR {
        ConfR::new((self.bits & 3) as u8)
    }
    #[doc = "Bit 2 - Wake Enable"]
    #[inline(always)]
    pub fn wakeen(&self) -> WakeenR {
        WakeenR::new(((self.bits >> 2) & 1) != 0)
    }
    #[doc = "Bit 3 - Power Supply OK Enable"]
    #[inline(always)]
    pub fn psoken(&self) -> PsokenR {
        PsokenR::new(((self.bits >> 3) & 1) != 0)
    }
}
impl W {
    #[doc = "Bits 0:1 - Battery Backup Configuration"]
    #[inline(always)]
    pub fn conf(&mut self) -> ConfW<BbpsSpec> {
        ConfW::new(self, 0)
    }
    #[doc = "Bit 2 - Wake Enable"]
    #[inline(always)]
    pub fn wakeen(&mut self) -> WakeenW<BbpsSpec> {
        WakeenW::new(self, 2)
    }
    #[doc = "Bit 3 - Power Supply OK Enable"]
    #[inline(always)]
    pub fn psoken(&mut self) -> PsokenW<BbpsSpec> {
        PsokenW::new(self, 3)
    }
}
#[doc = "Battery Backup Power Switch\n\nYou can [`read`](crate::Reg::read) this register and get [`bbps::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`bbps::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct BbpsSpec;
impl crate::RegisterSpec for BbpsSpec {
    type Ux = u32;
}
#[doc = "`read()` method returns [`bbps::R`](R) reader structure"]
impl crate::Readable for BbpsSpec {}
#[doc = "`write(|w| ..)` method takes [`bbps::W`](W) writer structure"]
impl crate::Writable for BbpsSpec {
    type Safety = crate::Unsafe;
    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
}
#[doc = "`reset()` method sets BBPS to value 0"]
impl crate::Resettable for BbpsSpec {
    const RESET_VALUE: u32 = 0;
}
