#[doc = "Register `PWR_BG_CONFIG` reader"]
pub struct R(crate::R<PWR_BG_CONFIG_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<PWR_BG_CONFIG_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<PWR_BG_CONFIG_SPEC>> for R {
    fn from(reader: crate::R<PWR_BG_CONFIG_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `PWR_BG_CONFIG` writer"]
pub struct W(crate::W<PWR_BG_CONFIG_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<PWR_BG_CONFIG_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::ops::DerefMut for W {
    #[inline(always)]
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}
impl core::convert::From<crate::W<PWR_BG_CONFIG_SPEC>> for W {
    fn from(writer: crate::W<PWR_BG_CONFIG_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "Field `BG_DFT_EN` reader - Enables DFT capability for Bandgap. (engineering only)"]
pub struct BG_DFT_EN_R(crate::FieldReader<bool, bool>);
impl BG_DFT_EN_R {
    pub(crate) fn new(bits: bool) -> Self {
        BG_DFT_EN_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for BG_DFT_EN_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `BG_DFT_EN` writer - Enables DFT capability for Bandgap. (engineering only)"]
pub struct BG_DFT_EN_W<'a> {
    w: &'a mut W,
}
impl<'a> BG_DFT_EN_W<'a> {
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
        self.w
    }
}
#[doc = "Field `BG_DFT_VREF_SEL` reader - ADFT mux select for Reference System characterization (engineering only). Select a voltage reference to output on adft_bg_ref?0=vgnd?1=vref_fast\\[0\\]?2=vref_fast\\[1\\]?3=vref_fast\\[2\\]?4=vref_fast\\[3\\]?5=vref_fast\\[4\\]?6=vref_fast\\[5\\]?7=vref_fast\\[6\\]?8=vref_fast\\[7\\]?9=vref\\[0\\]?10=vref\\[1\\]?11=vref\\[2\\]?12=vctat?13=iref_dft (see BG_DFT_ICORE_SEL)?14=imo_iref (current)?15=inl_imoref (voltage)"]
pub struct BG_DFT_VREF_SEL_R(crate::FieldReader<u8, u8>);
impl BG_DFT_VREF_SEL_R {
    pub(crate) fn new(bits: u8) -> Self {
        BG_DFT_VREF_SEL_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for BG_DFT_VREF_SEL_R {
    type Target = crate::FieldReader<u8, u8>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `BG_DFT_VREF_SEL` writer - ADFT mux select for Reference System characterization (engineering only). Select a voltage reference to output on adft_bg_ref?0=vgnd?1=vref_fast\\[0\\]?2=vref_fast\\[1\\]?3=vref_fast\\[2\\]?4=vref_fast\\[3\\]?5=vref_fast\\[4\\]?6=vref_fast\\[5\\]?7=vref_fast\\[6\\]?8=vref_fast\\[7\\]?9=vref\\[0\\]?10=vref\\[1\\]?11=vref\\[2\\]?12=vctat?13=iref_dft (see BG_DFT_ICORE_SEL)?14=imo_iref (current)?15=inl_imoref (voltage)"]
pub struct BG_DFT_VREF_SEL_W<'a> {
    w: &'a mut W,
}
impl<'a> BG_DFT_VREF_SEL_W<'a> {
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x0f << 1)) | ((value as u32 & 0x0f) << 1);
        self.w
    }
}
#[doc = "Field `BG_DFT_CORE_SEL` reader - ADFT mux select for Bandgap characterization (engineering only). Selects which BG core signal to output on adft_bg_core?0=BG core voltage selected by BG_DFT_VCORE_SEL (mux2out)?1=BG core current selected by BG_DFT_ICORE_SEL (mux1out)"]
pub struct BG_DFT_CORE_SEL_R(crate::FieldReader<bool, bool>);
impl BG_DFT_CORE_SEL_R {
    pub(crate) fn new(bits: bool) -> Self {
        BG_DFT_CORE_SEL_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for BG_DFT_CORE_SEL_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `BG_DFT_CORE_SEL` writer - ADFT mux select for Bandgap characterization (engineering only). Selects which BG core signal to output on adft_bg_core?0=BG core voltage selected by BG_DFT_VCORE_SEL (mux2out)?1=BG core current selected by BG_DFT_ICORE_SEL (mux1out)"]
pub struct BG_DFT_CORE_SEL_W<'a> {
    w: &'a mut W,
}
impl<'a> BG_DFT_CORE_SEL_W<'a> {
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 5)) | ((value as u32 & 0x01) << 5);
        self.w
    }
}
#[doc = "Field `BG_DFT_ICORE_SEL` reader - ADFT mux select for Bandgap characterization (engineering only). Selects a BG core current to output on mux1out?0=iptat (current?1=ictat (current)?2=inl_cross_over detect (voltage)?3=iref9p6u_dft (dedicated output for DFT)?Also selects a currect for iref_dft (when BG_DFT_VREF_SEL=13)?0=iref2p4u\\[1\\]?1=iptat2p4u\\[7\\]?2=iref_imo (9.6uA current output from IMO IBG)?3=iref3u_dft (dedicated output for DFT)"]
pub struct BG_DFT_ICORE_SEL_R(crate::FieldReader<u8, u8>);
impl BG_DFT_ICORE_SEL_R {
    pub(crate) fn new(bits: u8) -> Self {
        BG_DFT_ICORE_SEL_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for BG_DFT_ICORE_SEL_R {
    type Target = crate::FieldReader<u8, u8>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `BG_DFT_ICORE_SEL` writer - ADFT mux select for Bandgap characterization (engineering only). Selects a BG core current to output on mux1out?0=iptat (current?1=ictat (current)?2=inl_cross_over detect (voltage)?3=iref9p6u_dft (dedicated output for DFT)?Also selects a currect for iref_dft (when BG_DFT_VREF_SEL=13)?0=iref2p4u\\[1\\]?1=iptat2p4u\\[7\\]?2=iref_imo (9.6uA current output from IMO IBG)?3=iref3u_dft (dedicated output for DFT)"]
pub struct BG_DFT_ICORE_SEL_W<'a> {
    w: &'a mut W,
}
impl<'a> BG_DFT_ICORE_SEL_W<'a> {
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x03 << 6)) | ((value as u32 & 0x03) << 6);
        self.w
    }
}
#[doc = "Field `BG_DFT_VCORE_SEL` reader - ADFT mux select for Bandgap characterization (engineering only). Selects a BG core voltage to output on mux2out?0=vout?1=vgnd"]
pub struct BG_DFT_VCORE_SEL_R(crate::FieldReader<bool, bool>);
impl BG_DFT_VCORE_SEL_R {
    pub(crate) fn new(bits: bool) -> Self {
        BG_DFT_VCORE_SEL_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for BG_DFT_VCORE_SEL_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `BG_DFT_VCORE_SEL` writer - ADFT mux select for Bandgap characterization (engineering only). Selects a BG core voltage to output on mux2out?0=vout?1=vgnd"]
pub struct BG_DFT_VCORE_SEL_W<'a> {
    w: &'a mut W,
}
impl<'a> BG_DFT_VCORE_SEL_W<'a> {
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 8)) | ((value as u32 & 0x01) << 8);
        self.w
    }
}
#[doc = "Field `VREF_EN` reader - Reference voltage enable. Each bit enables a reference voltage used by a peripheral:?vref\\[0\\]
= 1 enables SRSS.VREF\\[0\\]
to 1.024V?vref\\[1\\]
= 1 enables SRSS.VREF\\[1\\]
to 1.024V?vref\\[2\\]
= 1 enables SRSS.VREF\\[2\\]
to 1.2V??These references require 40us to settle after enabling them and 30us to settle after wakng from DeepSleep."]
pub struct VREF_EN_R(crate::FieldReader<u8, u8>);
impl VREF_EN_R {
    pub(crate) fn new(bits: u8) -> Self {
        VREF_EN_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for VREF_EN_R {
    type Target = crate::FieldReader<u8, u8>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `VREF_EN` writer - Reference voltage enable. Each bit enables a reference voltage used by a peripheral:?vref\\[0\\]
= 1 enables SRSS.VREF\\[0\\]
to 1.024V?vref\\[1\\]
= 1 enables SRSS.VREF\\[1\\]
to 1.024V?vref\\[2\\]
= 1 enables SRSS.VREF\\[2\\]
to 1.2V??These references require 40us to settle after enabling them and 30us to settle after wakng from DeepSleep."]
pub struct VREF_EN_W<'a> {
    w: &'a mut W,
}
impl<'a> VREF_EN_W<'a> {
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x07 << 16)) | ((value as u32 & 0x07) << 16);
        self.w
    }
}
impl R {
    #[doc = "Bit 0 - Enables DFT capability for Bandgap. (engineering only)"]
    #[inline(always)]
    pub fn bg_dft_en(&self) -> BG_DFT_EN_R {
        BG_DFT_EN_R::new((self.bits & 0x01) != 0)
    }
    #[doc = "Bits 1:4 - ADFT mux select for Reference System characterization (engineering only). Select a voltage reference to output on adft_bg_ref?0=vgnd?1=vref_fast\\[0\\]?2=vref_fast\\[1\\]?3=vref_fast\\[2\\]?4=vref_fast\\[3\\]?5=vref_fast\\[4\\]?6=vref_fast\\[5\\]?7=vref_fast\\[6\\]?8=vref_fast\\[7\\]?9=vref\\[0\\]?10=vref\\[1\\]?11=vref\\[2\\]?12=vctat?13=iref_dft (see BG_DFT_ICORE_SEL)?14=imo_iref (current)?15=inl_imoref (voltage)"]
    #[inline(always)]
    pub fn bg_dft_vref_sel(&self) -> BG_DFT_VREF_SEL_R {
        BG_DFT_VREF_SEL_R::new(((self.bits >> 1) & 0x0f) as u8)
    }
    #[doc = "Bit 5 - ADFT mux select for Bandgap characterization (engineering only). Selects which BG core signal to output on adft_bg_core?0=BG core voltage selected by BG_DFT_VCORE_SEL (mux2out)?1=BG core current selected by BG_DFT_ICORE_SEL (mux1out)"]
    #[inline(always)]
    pub fn bg_dft_core_sel(&self) -> BG_DFT_CORE_SEL_R {
        BG_DFT_CORE_SEL_R::new(((self.bits >> 5) & 0x01) != 0)
    }
    #[doc = "Bits 6:7 - ADFT mux select for Bandgap characterization (engineering only). Selects a BG core current to output on mux1out?0=iptat (current?1=ictat (current)?2=inl_cross_over detect (voltage)?3=iref9p6u_dft (dedicated output for DFT)?Also selects a currect for iref_dft (when BG_DFT_VREF_SEL=13)?0=iref2p4u\\[1\\]?1=iptat2p4u\\[7\\]?2=iref_imo (9.6uA current output from IMO IBG)?3=iref3u_dft (dedicated output for DFT)"]
    #[inline(always)]
    pub fn bg_dft_icore_sel(&self) -> BG_DFT_ICORE_SEL_R {
        BG_DFT_ICORE_SEL_R::new(((self.bits >> 6) & 0x03) as u8)
    }
    #[doc = "Bit 8 - ADFT mux select for Bandgap characterization (engineering only). Selects a BG core voltage to output on mux2out?0=vout?1=vgnd"]
    #[inline(always)]
    pub fn bg_dft_vcore_sel(&self) -> BG_DFT_VCORE_SEL_R {
        BG_DFT_VCORE_SEL_R::new(((self.bits >> 8) & 0x01) != 0)
    }
    #[doc = "Bits 16:18 - Reference voltage enable. Each bit enables a reference voltage used by a peripheral:?vref\\[0\\]
= 1 enables SRSS.VREF\\[0\\]
to 1.024V?vref\\[1\\]
= 1 enables SRSS.VREF\\[1\\]
to 1.024V?vref\\[2\\]
= 1 enables SRSS.VREF\\[2\\]
to 1.2V??These references require 40us to settle after enabling them and 30us to settle after wakng from DeepSleep."]
    #[inline(always)]
    pub fn vref_en(&self) -> VREF_EN_R {
        VREF_EN_R::new(((self.bits >> 16) & 0x07) as u8)
    }
}
impl W {
    #[doc = "Bit 0 - Enables DFT capability for Bandgap. (engineering only)"]
    #[inline(always)]
    pub fn bg_dft_en(&mut self) -> BG_DFT_EN_W {
        BG_DFT_EN_W { w: self }
    }
    #[doc = "Bits 1:4 - ADFT mux select for Reference System characterization (engineering only). Select a voltage reference to output on adft_bg_ref?0=vgnd?1=vref_fast\\[0\\]?2=vref_fast\\[1\\]?3=vref_fast\\[2\\]?4=vref_fast\\[3\\]?5=vref_fast\\[4\\]?6=vref_fast\\[5\\]?7=vref_fast\\[6\\]?8=vref_fast\\[7\\]?9=vref\\[0\\]?10=vref\\[1\\]?11=vref\\[2\\]?12=vctat?13=iref_dft (see BG_DFT_ICORE_SEL)?14=imo_iref (current)?15=inl_imoref (voltage)"]
    #[inline(always)]
    pub fn bg_dft_vref_sel(&mut self) -> BG_DFT_VREF_SEL_W {
        BG_DFT_VREF_SEL_W { w: self }
    }
    #[doc = "Bit 5 - ADFT mux select for Bandgap characterization (engineering only). Selects which BG core signal to output on adft_bg_core?0=BG core voltage selected by BG_DFT_VCORE_SEL (mux2out)?1=BG core current selected by BG_DFT_ICORE_SEL (mux1out)"]
    #[inline(always)]
    pub fn bg_dft_core_sel(&mut self) -> BG_DFT_CORE_SEL_W {
        BG_DFT_CORE_SEL_W { w: self }
    }
    #[doc = "Bits 6:7 - ADFT mux select for Bandgap characterization (engineering only). Selects a BG core current to output on mux1out?0=iptat (current?1=ictat (current)?2=inl_cross_over detect (voltage)?3=iref9p6u_dft (dedicated output for DFT)?Also selects a currect for iref_dft (when BG_DFT_VREF_SEL=13)?0=iref2p4u\\[1\\]?1=iptat2p4u\\[7\\]?2=iref_imo (9.6uA current output from IMO IBG)?3=iref3u_dft (dedicated output for DFT)"]
    #[inline(always)]
    pub fn bg_dft_icore_sel(&mut self) -> BG_DFT_ICORE_SEL_W {
        BG_DFT_ICORE_SEL_W { w: self }
    }
    #[doc = "Bit 8 - ADFT mux select for Bandgap characterization (engineering only). Selects a BG core voltage to output on mux2out?0=vout?1=vgnd"]
    #[inline(always)]
    pub fn bg_dft_vcore_sel(&mut self) -> BG_DFT_VCORE_SEL_W {
        BG_DFT_VCORE_SEL_W { w: self }
    }
    #[doc = "Bits 16:18 - Reference voltage enable. Each bit enables a reference voltage used by a peripheral:?vref\\[0\\]
= 1 enables SRSS.VREF\\[0\\]
to 1.024V?vref\\[1\\]
= 1 enables SRSS.VREF\\[1\\]
to 1.024V?vref\\[2\\]
= 1 enables SRSS.VREF\\[2\\]
to 1.2V??These references require 40us to settle after enabling them and 30us to settle after wakng from DeepSleep."]
    #[inline(always)]
    pub fn vref_en(&mut self) -> VREF_EN_W {
        VREF_EN_W { w: self }
    }
    #[doc = "Writes raw bits to the register."]
    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
        self.0.bits(bits);
        self
    }
}
#[doc = "Bandgap Trim and Configuration\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [pwr_bg_config](index.html) module"]
pub struct PWR_BG_CONFIG_SPEC;
impl crate::RegisterSpec for PWR_BG_CONFIG_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [pwr_bg_config::R](R) reader structure"]
impl crate::Readable for PWR_BG_CONFIG_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [pwr_bg_config::W](W) writer structure"]
impl crate::Writable for PWR_BG_CONFIG_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets PWR_BG_CONFIG to value 0"]
impl crate::Resettable for PWR_BG_CONFIG_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0
    }
}
