#[doc = "Register `USBIO_CR1` reader"]
pub struct R(crate::R<USBIO_CR1_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<USBIO_CR1_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<USBIO_CR1_SPEC>> for R {
    fn from(reader: crate::R<USBIO_CR1_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `USBIO_CR1` writer"]
pub struct W(crate::W<USBIO_CR1_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<USBIO_CR1_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_CR1_SPEC>> for W {
    fn from(writer: crate::W<USBIO_CR1_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "Field `DMO` reader - This read only bit gives the state of the D- pin."]
pub struct DMO_R(crate::FieldReader<bool, bool>);
impl DMO_R {
    pub(crate) fn new(bits: bool) -> Self {
        DMO_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for DMO_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `DPO` reader - This read only bit gives the state of the D+ pin."]
pub struct DPO_R(crate::FieldReader<bool, bool>);
impl DPO_R {
    pub(crate) fn new(bits: bool) -> Self {
        DPO_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for DPO_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `USBPUEN` reader - This bit enables the connection of the internal 1.5 k pull up resistor on the D+ pin."]
pub struct USBPUEN_R(crate::FieldReader<bool, bool>);
impl USBPUEN_R {
    pub(crate) fn new(bits: bool) -> Self {
        USBPUEN_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for USBPUEN_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `USBPUEN` writer - This bit enables the connection of the internal 1.5 k pull up resistor on the D+ pin."]
pub struct USBPUEN_W<'a> {
    w: &'a mut W,
}
impl<'a> USBPUEN_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 << 2)) | ((value as u32 & 0x01) << 2);
        self.w
    }
}
#[doc = "Field `IOMODE` reader - This bit allows the D+ and D- pins to be configured for either USB mode or bit-banged modes. If this bit is set the DMI and DPI bits are used to drive the D- and D+ pins."]
pub struct IOMODE_R(crate::FieldReader<bool, bool>);
impl IOMODE_R {
    pub(crate) fn new(bits: bool) -> Self {
        IOMODE_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for IOMODE_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `IOMODE` writer - This bit allows the D+ and D- pins to be configured for either USB mode or bit-banged modes. If this bit is set the DMI and DPI bits are used to drive the D- and D+ pins."]
pub struct IOMODE_W<'a> {
    w: &'a mut W,
}
impl<'a> IOMODE_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
    }
}
impl R {
    #[doc = "Bit 0 - This read only bit gives the state of the D- pin."]
    #[inline(always)]
    pub fn dmo(&self) -> DMO_R {
        DMO_R::new((self.bits & 0x01) != 0)
    }
    #[doc = "Bit 1 - This read only bit gives the state of the D+ pin."]
    #[inline(always)]
    pub fn dpo(&self) -> DPO_R {
        DPO_R::new(((self.bits >> 1) & 0x01) != 0)
    }
    #[doc = "Bit 2 - This bit enables the connection of the internal 1.5 k pull up resistor on the D+ pin."]
    #[inline(always)]
    pub fn usbpuen(&self) -> USBPUEN_R {
        USBPUEN_R::new(((self.bits >> 2) & 0x01) != 0)
    }
    #[doc = "Bit 5 - This bit allows the D+ and D- pins to be configured for either USB mode or bit-banged modes. If this bit is set the DMI and DPI bits are used to drive the D- and D+ pins."]
    #[inline(always)]
    pub fn iomode(&self) -> IOMODE_R {
        IOMODE_R::new(((self.bits >> 5) & 0x01) != 0)
    }
}
impl W {
    #[doc = "Bit 2 - This bit enables the connection of the internal 1.5 k pull up resistor on the D+ pin."]
    #[inline(always)]
    pub fn usbpuen(&mut self) -> USBPUEN_W {
        USBPUEN_W { w: self }
    }
    #[doc = "Bit 5 - This bit allows the D+ and D- pins to be configured for either USB mode or bit-banged modes. If this bit is set the DMI and DPI bits are used to drive the D- and D+ pins."]
    #[inline(always)]
    pub fn iomode(&mut self) -> IOMODE_W {
        IOMODE_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 = "USBIO control 1 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_cr1](index.html) module"]
pub struct USBIO_CR1_SPEC;
impl crate::RegisterSpec for USBIO_CR1_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [usbio_cr1::R](R) reader structure"]
impl crate::Readable for USBIO_CR1_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [usbio_cr1::W](W) writer structure"]
impl crate::Writable for USBIO_CR1_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets USBIO_CR1 to value 0"]
impl crate::Resettable for USBIO_CR1_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0
    }
}
