#[doc = "Register `PWR_DFT_KEY` reader"]
pub struct R(crate::R<PWR_DFT_KEY_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<PWR_DFT_KEY_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<PWR_DFT_KEY_SPEC>> for R {
    fn from(reader: crate::R<PWR_DFT_KEY_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `PWR_DFT_KEY` writer"]
pub struct W(crate::W<PWR_DFT_KEY_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<PWR_DFT_KEY_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_DFT_KEY_SPEC>> for W {
    fn from(writer: crate::W<PWR_DFT_KEY_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "Field `KEY16` reader - This field must be set to 0xE4C5 for any of the other fields in this register to have effect and for scan_mode to be allowed. When this fields has any other value, all other fields in this register are ignored and assumed to be 0 by the hardware, and scan_mode is ignored inside the power generation system. It is assumed that this register will always be set to 0xE4C5 before entering scan."]
pub struct KEY16_R(crate::FieldReader<u16, u16>);
impl KEY16_R {
    pub(crate) fn new(bits: u16) -> Self {
        KEY16_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for KEY16_R {
    type Target = crate::FieldReader<u16, u16>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `KEY16` writer - This field must be set to 0xE4C5 for any of the other fields in this register to have effect and for scan_mode to be allowed. When this fields has any other value, all other fields in this register are ignored and assumed to be 0 by the hardware, and scan_mode is ignored inside the power generation system. It is assumed that this register will always be set to 0xE4C5 before entering scan."]
pub struct KEY16_W<'a> {
    w: &'a mut W,
}
impl<'a> KEY16_W<'a> {
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u16) -> &'a mut W {
        self.w.bits = (self.w.bits & !0xffff) | (value as u32 & 0xffff);
        self.w
    }
}
#[doc = "Field `HBOD_OFF_AWAKE` reader - Forces the output of the HBOD to be blocked (ignored) while in Active or Sleep mode (i.e. when under the umbrella of PBOD)."]
pub struct HBOD_OFF_AWAKE_R(crate::FieldReader<bool, bool>);
impl HBOD_OFF_AWAKE_R {
    pub(crate) fn new(bits: bool) -> Self {
        HBOD_OFF_AWAKE_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for HBOD_OFF_AWAKE_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `HBOD_OFF_AWAKE` writer - Forces the output of the HBOD to be blocked (ignored) while in Active or Sleep mode (i.e. when under the umbrella of PBOD)."]
pub struct HBOD_OFF_AWAKE_W<'a> {
    w: &'a mut W,
}
impl<'a> HBOD_OFF_AWAKE_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 << 16)) | ((value as u32 & 0x01) << 16);
        self.w
    }
}
#[doc = "Field `BODS_OFF` reader - Forces all outputs of BOD detectors to be ignored, effectively disabling all brown-out detection. Can be used in conjunction with DDFT to test the detectors without triggering reset."]
pub struct BODS_OFF_R(crate::FieldReader<bool, bool>);
impl BODS_OFF_R {
    pub(crate) fn new(bits: bool) -> Self {
        BODS_OFF_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for BODS_OFF_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `BODS_OFF` writer - Forces all outputs of BOD detectors to be ignored, effectively disabling all brown-out detection. Can be used in conjunction with DDFT to test the detectors without triggering reset."]
pub struct BODS_OFF_W<'a> {
    w: &'a mut W,
}
impl<'a> BODS_OFF_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 << 17)) | ((value as u32 & 0x01) << 17);
        self.w
    }
}
#[doc = "Field `DFT_MODE` reader - Enable DfT modes other than the above. Currently gates power_up comparator for characterization."]
pub struct DFT_MODE_R(crate::FieldReader<bool, bool>);
impl DFT_MODE_R {
    pub(crate) fn new(bits: bool) -> Self {
        DFT_MODE_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for DFT_MODE_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `DFT_MODE` writer - Enable DfT modes other than the above. Currently gates power_up comparator for characterization."]
pub struct DFT_MODE_W<'a> {
    w: &'a mut W,
}
impl<'a> DFT_MODE_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 << 18)) | ((value as u32 & 0x01) << 18);
        self.w
    }
}
#[doc = "Field `IO_DISABLE_BYPASS` reader - Bypasses the IO disable logic for testing the delay-line that is part of the glitch-free IO reset circuitry. Internally, prevents the outputs from getting disabled (io_disable_req_hv=0) and blocks resets (io_disable_ack_hv=0). The delay-line continues to function and can be routed to DDFT for testing."]
pub struct IO_DISABLE_BYPASS_R(crate::FieldReader<bool, bool>);
impl IO_DISABLE_BYPASS_R {
    pub(crate) fn new(bits: bool) -> Self {
        IO_DISABLE_BYPASS_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for IO_DISABLE_BYPASS_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `IO_DISABLE_BYPASS` writer - Bypasses the IO disable logic for testing the delay-line that is part of the glitch-free IO reset circuitry. Internally, prevents the outputs from getting disabled (io_disable_req_hv=0) and blocks resets (io_disable_ack_hv=0). The delay-line continues to function and can be routed to DDFT for testing."]
pub struct IO_DISABLE_BYPASS_W<'a> {
    w: &'a mut W,
}
impl<'a> IO_DISABLE_BYPASS_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 << 19)) | ((value as u32 & 0x01) << 19);
        self.w
    }
}
#[doc = "Field `VMON_PD` reader - Disables the VMON block, which includes PBOD, HVBOD, and LVD circuits. Set BODS_OFF=1 in a previous write cycle to prevent an unintended reset."]
pub struct VMON_PD_R(crate::FieldReader<bool, bool>);
impl VMON_PD_R {
    pub(crate) fn new(bits: bool) -> Self {
        VMON_PD_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for VMON_PD_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `VMON_PD` writer - Disables the VMON block, which includes PBOD, HVBOD, and LVD circuits. Set BODS_OFF=1 in a previous write cycle to prevent an unintended reset."]
pub struct VMON_PD_W<'a> {
    w: &'a mut W,
}
impl<'a> VMON_PD_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 << 20)) | ((value as u32 & 0x01) << 20);
        self.w
    }
}
impl R {
    #[doc = "Bits 0:15 - This field must be set to 0xE4C5 for any of the other fields in this register to have effect and for scan_mode to be allowed. When this fields has any other value, all other fields in this register are ignored and assumed to be 0 by the hardware, and scan_mode is ignored inside the power generation system. It is assumed that this register will always be set to 0xE4C5 before entering scan."]
    #[inline(always)]
    pub fn key16(&self) -> KEY16_R {
        KEY16_R::new((self.bits & 0xffff) as u16)
    }
    #[doc = "Bit 16 - Forces the output of the HBOD to be blocked (ignored) while in Active or Sleep mode (i.e. when under the umbrella of PBOD)."]
    #[inline(always)]
    pub fn hbod_off_awake(&self) -> HBOD_OFF_AWAKE_R {
        HBOD_OFF_AWAKE_R::new(((self.bits >> 16) & 0x01) != 0)
    }
    #[doc = "Bit 17 - Forces all outputs of BOD detectors to be ignored, effectively disabling all brown-out detection. Can be used in conjunction with DDFT to test the detectors without triggering reset."]
    #[inline(always)]
    pub fn bods_off(&self) -> BODS_OFF_R {
        BODS_OFF_R::new(((self.bits >> 17) & 0x01) != 0)
    }
    #[doc = "Bit 18 - Enable DfT modes other than the above. Currently gates power_up comparator for characterization."]
    #[inline(always)]
    pub fn dft_mode(&self) -> DFT_MODE_R {
        DFT_MODE_R::new(((self.bits >> 18) & 0x01) != 0)
    }
    #[doc = "Bit 19 - Bypasses the IO disable logic for testing the delay-line that is part of the glitch-free IO reset circuitry. Internally, prevents the outputs from getting disabled (io_disable_req_hv=0) and blocks resets (io_disable_ack_hv=0). The delay-line continues to function and can be routed to DDFT for testing."]
    #[inline(always)]
    pub fn io_disable_bypass(&self) -> IO_DISABLE_BYPASS_R {
        IO_DISABLE_BYPASS_R::new(((self.bits >> 19) & 0x01) != 0)
    }
    #[doc = "Bit 20 - Disables the VMON block, which includes PBOD, HVBOD, and LVD circuits. Set BODS_OFF=1 in a previous write cycle to prevent an unintended reset."]
    #[inline(always)]
    pub fn vmon_pd(&self) -> VMON_PD_R {
        VMON_PD_R::new(((self.bits >> 20) & 0x01) != 0)
    }
}
impl W {
    #[doc = "Bits 0:15 - This field must be set to 0xE4C5 for any of the other fields in this register to have effect and for scan_mode to be allowed. When this fields has any other value, all other fields in this register are ignored and assumed to be 0 by the hardware, and scan_mode is ignored inside the power generation system. It is assumed that this register will always be set to 0xE4C5 before entering scan."]
    #[inline(always)]
    pub fn key16(&mut self) -> KEY16_W {
        KEY16_W { w: self }
    }
    #[doc = "Bit 16 - Forces the output of the HBOD to be blocked (ignored) while in Active or Sleep mode (i.e. when under the umbrella of PBOD)."]
    #[inline(always)]
    pub fn hbod_off_awake(&mut self) -> HBOD_OFF_AWAKE_W {
        HBOD_OFF_AWAKE_W { w: self }
    }
    #[doc = "Bit 17 - Forces all outputs of BOD detectors to be ignored, effectively disabling all brown-out detection. Can be used in conjunction with DDFT to test the detectors without triggering reset."]
    #[inline(always)]
    pub fn bods_off(&mut self) -> BODS_OFF_W {
        BODS_OFF_W { w: self }
    }
    #[doc = "Bit 18 - Enable DfT modes other than the above. Currently gates power_up comparator for characterization."]
    #[inline(always)]
    pub fn dft_mode(&mut self) -> DFT_MODE_W {
        DFT_MODE_W { w: self }
    }
    #[doc = "Bit 19 - Bypasses the IO disable logic for testing the delay-line that is part of the glitch-free IO reset circuitry. Internally, prevents the outputs from getting disabled (io_disable_req_hv=0) and blocks resets (io_disable_ack_hv=0). The delay-line continues to function and can be routed to DDFT for testing."]
    #[inline(always)]
    pub fn io_disable_bypass(&mut self) -> IO_DISABLE_BYPASS_W {
        IO_DISABLE_BYPASS_W { w: self }
    }
    #[doc = "Bit 20 - Disables the VMON block, which includes PBOD, HVBOD, and LVD circuits. Set BODS_OFF=1 in a previous write cycle to prevent an unintended reset."]
    #[inline(always)]
    pub fn vmon_pd(&mut self) -> VMON_PD_W {
        VMON_PD_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 = "DFT Safety Override\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_dft_key](index.html) module"]
pub struct PWR_DFT_KEY_SPEC;
impl crate::RegisterSpec for PWR_DFT_KEY_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [pwr_dft_key::R](R) reader structure"]
impl crate::Readable for PWR_DFT_KEY_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [pwr_dft_key::W](W) writer structure"]
impl crate::Writable for PWR_DFT_KEY_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets PWR_DFT_KEY to value 0"]
impl crate::Resettable for PWR_DFT_KEY_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0
    }
}
