#[doc = "Register `USBIO_CTRL` reader"]
pub struct R(crate::R<USBIO_CTRL_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<USBIO_CTRL_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<USBIO_CTRL_SPEC>> for R {
    fn from(reader: crate::R<USBIO_CTRL_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `USBIO_CTRL` writer"]
pub struct W(crate::W<USBIO_CTRL_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<USBIO_CTRL_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<USBIO_CTRL_SPEC>> for W {
    fn from(writer: crate::W<USBIO_CTRL_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "The GPIO Drive Mode for DP IO pad. This field only applies if USBIO_CR1.IOMODE =1. Data comes from the corresponding GPIO.DR register.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum DM_P_A {
    #[doc = "0: No description available"]
    OFF = 0,
    #[doc = "1: No description available"]
    INPUT = 1,
    #[doc = "2: No description available"]
    CY0_PU = 2,
    #[doc = "4: No description available"]
    CY0_Z = 4,
    #[doc = "6: No description available"]
    CY0_1 = 6,
}
impl From<DM_P_A> for u8 {
    #[inline(always)]
    fn from(variant: DM_P_A) -> Self {
        variant as _
    }
}
#[doc = "Field `DM_P` reader - The GPIO Drive Mode for DP IO pad. This field only applies if USBIO_CR1.IOMODE =1. Data comes from the corresponding GPIO.DR register."]
pub struct DM_P_R(crate::FieldReader<u8, DM_P_A>);
impl DM_P_R {
    pub(crate) fn new(bits: u8) -> Self {
        DM_P_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> Option<DM_P_A> {
        match self.bits {
            0 => Some(DM_P_A::OFF),
            1 => Some(DM_P_A::INPUT),
            2 => Some(DM_P_A::CY0_PU),
            4 => Some(DM_P_A::CY0_Z),
            6 => Some(DM_P_A::CY0_1),
            _ => None,
        }
    }
    #[doc = "Checks if the value of the field is `OFF`"]
    #[inline(always)]
    pub fn is_off(&self) -> bool {
        **self == DM_P_A::OFF
    }
    #[doc = "Checks if the value of the field is `INPUT`"]
    #[inline(always)]
    pub fn is_input(&self) -> bool {
        **self == DM_P_A::INPUT
    }
    #[doc = "Checks if the value of the field is `CY0_PU`"]
    #[inline(always)]
    pub fn is_cy0_pu(&self) -> bool {
        **self == DM_P_A::CY0_PU
    }
    #[doc = "Checks if the value of the field is `CY0_Z`"]
    #[inline(always)]
    pub fn is_cy0_z(&self) -> bool {
        **self == DM_P_A::CY0_Z
    }
    #[doc = "Checks if the value of the field is `CY0_1`"]
    #[inline(always)]
    pub fn is_cy0_1(&self) -> bool {
        **self == DM_P_A::CY0_1
    }
}
impl core::ops::Deref for DM_P_R {
    type Target = crate::FieldReader<u8, DM_P_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `DM_P` writer - The GPIO Drive Mode for DP IO pad. This field only applies if USBIO_CR1.IOMODE =1. Data comes from the corresponding GPIO.DR register."]
pub struct DM_P_W<'a> {
    w: &'a mut W,
}
impl<'a> DM_P_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: DM_P_A) -> &'a mut W {
        unsafe { self.bits(variant.into()) }
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn off(self) -> &'a mut W {
        self.variant(DM_P_A::OFF)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn input(self) -> &'a mut W {
        self.variant(DM_P_A::INPUT)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn cy0_pu(self) -> &'a mut W {
        self.variant(DM_P_A::CY0_PU)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn cy0_z(self) -> &'a mut W {
        self.variant(DM_P_A::CY0_Z)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn cy0_1(self) -> &'a mut W {
        self.variant(DM_P_A::CY0_1)
    }
    #[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) | (value as u32 & 0x07);
        self.w
    }
}
#[doc = "Field `DM_M` reader - The GPIO Drive Mode for DM IO pad."]
pub struct DM_M_R(crate::FieldReader<u8, u8>);
impl DM_M_R {
    pub(crate) fn new(bits: u8) -> Self {
        DM_M_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for DM_M_R {
    type Target = crate::FieldReader<u8, u8>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `DM_M` writer - The GPIO Drive Mode for DM IO pad."]
pub struct DM_M_W<'a> {
    w: &'a mut W,
}
impl<'a> DM_M_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 << 3)) | ((value as u32 & 0x07) << 3);
        self.w
    }
}
impl R {
    #[doc = "Bits 0:2 - The GPIO Drive Mode for DP IO pad. This field only applies if USBIO_CR1.IOMODE =1. Data comes from the corresponding GPIO.DR register."]
    #[inline(always)]
    pub fn dm_p(&self) -> DM_P_R {
        DM_P_R::new((self.bits & 0x07) as u8)
    }
    #[doc = "Bits 3:5 - The GPIO Drive Mode for DM IO pad."]
    #[inline(always)]
    pub fn dm_m(&self) -> DM_M_R {
        DM_M_R::new(((self.bits >> 3) & 0x07) as u8)
    }
}
impl W {
    #[doc = "Bits 0:2 - The GPIO Drive Mode for DP IO pad. This field only applies if USBIO_CR1.IOMODE =1. Data comes from the corresponding GPIO.DR register."]
    #[inline(always)]
    pub fn dm_p(&mut self) -> DM_P_W {
        DM_P_W { w: self }
    }
    #[doc = "Bits 3:5 - The GPIO Drive Mode for DM IO pad."]
    #[inline(always)]
    pub fn dm_m(&mut self) -> DM_M_W {
        DM_M_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 = "USB IO Control Register\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 [usbio_ctrl](index.html) module"]
pub struct USBIO_CTRL_SPEC;
impl crate::RegisterSpec for USBIO_CTRL_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [usbio_ctrl::R](R) reader structure"]
impl crate::Readable for USBIO_CTRL_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [usbio_ctrl::W](W) writer structure"]
impl crate::Writable for USBIO_CTRL_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets USBIO_CTRL to value 0"]
impl crate::Resettable for USBIO_CTRL_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0
    }
}
