#[doc = "Register `USBIO_TRIM` reader"]
pub struct R(crate::R<USBIO_TRIM_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<USBIO_TRIM_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<USBIO_TRIM_SPEC>> for R {
    fn from(reader: crate::R<USBIO_TRIM_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `USBIO_TRIM` writer"]
pub struct W(crate::W<USBIO_TRIM_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<USBIO_TRIM_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_TRIM_SPEC>> for W {
    fn from(writer: crate::W<USBIO_TRIM_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "These two bits of trim are for the suspend mode resistor.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum TRIM_A {
    #[doc = "0: No description available"]
    TRIM_NO = 0,
    #[doc = "1: No description available"]
    TRIM_LOWER = 1,
    #[doc = "2: No description available"]
    TRIM_HIGHER = 2,
    #[doc = "3: No description available"]
    TRIM_DONT_USE = 3,
}
impl From<TRIM_A> for u8 {
    #[inline(always)]
    fn from(variant: TRIM_A) -> Self {
        variant as _
    }
}
#[doc = "Field `TRIM` reader - These two bits of trim are for the suspend mode resistor."]
pub struct TRIM_R(crate::FieldReader<u8, TRIM_A>);
impl TRIM_R {
    pub(crate) fn new(bits: u8) -> Self {
        TRIM_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> TRIM_A {
        match self.bits {
            0 => TRIM_A::TRIM_NO,
            1 => TRIM_A::TRIM_LOWER,
            2 => TRIM_A::TRIM_HIGHER,
            3 => TRIM_A::TRIM_DONT_USE,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `TRIM_NO`"]
    #[inline(always)]
    pub fn is_trim_no(&self) -> bool {
        **self == TRIM_A::TRIM_NO
    }
    #[doc = "Checks if the value of the field is `TRIM_LOWER`"]
    #[inline(always)]
    pub fn is_trim_lower(&self) -> bool {
        **self == TRIM_A::TRIM_LOWER
    }
    #[doc = "Checks if the value of the field is `TRIM_HIGHER`"]
    #[inline(always)]
    pub fn is_trim_higher(&self) -> bool {
        **self == TRIM_A::TRIM_HIGHER
    }
    #[doc = "Checks if the value of the field is `TRIM_DONT_USE`"]
    #[inline(always)]
    pub fn is_trim_dont_use(&self) -> bool {
        **self == TRIM_A::TRIM_DONT_USE
    }
}
impl core::ops::Deref for TRIM_R {
    type Target = crate::FieldReader<u8, TRIM_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `TRIM` writer - These two bits of trim are for the suspend mode resistor."]
pub struct TRIM_W<'a> {
    w: &'a mut W,
}
impl<'a> TRIM_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: TRIM_A) -> &'a mut W {
        self.bits(variant.into())
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn trim_no(self) -> &'a mut W {
        self.variant(TRIM_A::TRIM_NO)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn trim_lower(self) -> &'a mut W {
        self.variant(TRIM_A::TRIM_LOWER)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn trim_higher(self) -> &'a mut W {
        self.variant(TRIM_A::TRIM_HIGHER)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn trim_dont_use(self) -> &'a mut W {
        self.variant(TRIM_A::TRIM_DONT_USE)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !0x03) | (value as u32 & 0x03);
        self.w
    }
}
#[doc = "Field `MDEC` reader - When set this bit decreases the USB edge matching ratio."]
pub struct MDEC_R(crate::FieldReader<bool, bool>);
impl MDEC_R {
    pub(crate) fn new(bits: bool) -> Self {
        MDEC_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for MDEC_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `MDEC` writer - When set this bit decreases the USB edge matching ratio."]
pub struct MDEC_W<'a> {
    w: &'a mut W,
}
impl<'a> MDEC_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 `MINC` reader - When set this bit increases the USB edge matching ratio"]
pub struct MINC_R(crate::FieldReader<bool, bool>);
impl MINC_R {
    pub(crate) fn new(bits: bool) -> Self {
        MINC_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for MINC_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `MINC` writer - When set this bit increases the USB edge matching ratio"]
pub struct MINC_W<'a> {
    w: &'a mut W,
}
impl<'a> MINC_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 << 3)) | ((value as u32 & 0x01) << 3);
        self.w
    }
}
#[doc = "Field `X_INC` reader - This bit enables a increase of the USB crossover voltage."]
pub struct X_INC_R(crate::FieldReader<bool, bool>);
impl X_INC_R {
    pub(crate) fn new(bits: bool) -> Self {
        X_INC_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for X_INC_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `X_INC` writer - This bit enables a increase of the USB crossover voltage."]
pub struct X_INC_W<'a> {
    w: &'a mut W,
}
impl<'a> X_INC_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 << 4)) | ((value as u32 & 0x01) << 4);
        self.w
    }
}
#[doc = "Field `X_DEC` reader - This bit enables a decrease of the USB crossover voltage."]
pub struct X_DEC_R(crate::FieldReader<bool, bool>);
impl X_DEC_R {
    pub(crate) fn new(bits: bool) -> Self {
        X_DEC_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for X_DEC_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `X_DEC` writer - This bit enables a decrease of the USB crossover voltage."]
pub struct X_DEC_W<'a> {
    w: &'a mut W,
}
impl<'a> X_DEC_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 = "Bits 0:1 - These two bits of trim are for the suspend mode resistor."]
    #[inline(always)]
    pub fn trim(&self) -> TRIM_R {
        TRIM_R::new((self.bits & 0x03) as u8)
    }
    #[doc = "Bit 2 - When set this bit decreases the USB edge matching ratio."]
    #[inline(always)]
    pub fn mdec(&self) -> MDEC_R {
        MDEC_R::new(((self.bits >> 2) & 0x01) != 0)
    }
    #[doc = "Bit 3 - When set this bit increases the USB edge matching ratio"]
    #[inline(always)]
    pub fn minc(&self) -> MINC_R {
        MINC_R::new(((self.bits >> 3) & 0x01) != 0)
    }
    #[doc = "Bit 4 - This bit enables a increase of the USB crossover voltage."]
    #[inline(always)]
    pub fn x_inc(&self) -> X_INC_R {
        X_INC_R::new(((self.bits >> 4) & 0x01) != 0)
    }
    #[doc = "Bit 5 - This bit enables a decrease of the USB crossover voltage."]
    #[inline(always)]
    pub fn x_dec(&self) -> X_DEC_R {
        X_DEC_R::new(((self.bits >> 5) & 0x01) != 0)
    }
}
impl W {
    #[doc = "Bits 0:1 - These two bits of trim are for the suspend mode resistor."]
    #[inline(always)]
    pub fn trim(&mut self) -> TRIM_W {
        TRIM_W { w: self }
    }
    #[doc = "Bit 2 - When set this bit decreases the USB edge matching ratio."]
    #[inline(always)]
    pub fn mdec(&mut self) -> MDEC_W {
        MDEC_W { w: self }
    }
    #[doc = "Bit 3 - When set this bit increases the USB edge matching ratio"]
    #[inline(always)]
    pub fn minc(&mut self) -> MINC_W {
        MINC_W { w: self }
    }
    #[doc = "Bit 4 - This bit enables a increase of the USB crossover voltage."]
    #[inline(always)]
    pub fn x_inc(&mut self) -> X_INC_W {
        X_INC_W { w: self }
    }
    #[doc = "Bit 5 - This bit enables a decrease of the USB crossover voltage."]
    #[inline(always)]
    pub fn x_dec(&mut self) -> X_DEC_W {
        X_DEC_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 = "trim values for IOs\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_trim](index.html) module"]
pub struct USBIO_TRIM_SPEC;
impl crate::RegisterSpec for USBIO_TRIM_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [usbio_trim::R](R) reader structure"]
impl crate::Readable for USBIO_TRIM_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [usbio_trim::W](W) writer structure"]
impl crate::Writable for USBIO_TRIM_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets USBIO_TRIM to value 0"]
impl crate::Resettable for USBIO_TRIM_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0
    }
}
