#[doc = "Register `RXPLEN` reader"]
pub type R = crate::R<RxplenSpec>;
#[doc = "Field `PKT_LNGTH` reader - The remaining number of bytes to be read from the currently selected endpoint's buffer. When this field decrements to 0, the RxENDPKT bit will be set in USBDevIntSt."]
pub type PktLngthR = crate::FieldReader<u16>;
#[doc = "Data valid. This bit is useful for isochronous endpoints. Non-isochronous endpoints do not raise an interrupt when an erroneous data packet is received. But invalid data packet can be produced with a bus reset. For isochronous endpoints, data transfer will happen even if an erroneous packet is received. In this case DV bit will not be set for the packet.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum UsbRxplenDvEnum {
    #[doc = "0: Data is invalid."]
    DataIsInvalid_ = 0,
    #[doc = "1: Data is valid."]
    DataIsValid_ = 1,
}
impl From<UsbRxplenDvEnum> for bool {
    #[inline(always)]
    fn from(variant: UsbRxplenDvEnum) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `DV` reader - Data valid. This bit is useful for isochronous endpoints. Non-isochronous endpoints do not raise an interrupt when an erroneous data packet is received. But invalid data packet can be produced with a bus reset. For isochronous endpoints, data transfer will happen even if an erroneous packet is received. In this case DV bit will not be set for the packet."]
pub type DvR = crate::BitReader<UsbRxplenDvEnum>;
impl DvR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> UsbRxplenDvEnum {
        match self.bits {
            false => UsbRxplenDvEnum::DataIsInvalid_,
            true => UsbRxplenDvEnum::DataIsValid_,
        }
    }
    #[doc = "Data is invalid."]
    #[inline(always)]
    pub fn is_data_is_invalid_(&self) -> bool {
        *self == UsbRxplenDvEnum::DataIsInvalid_
    }
    #[doc = "Data is valid."]
    #[inline(always)]
    pub fn is_data_is_valid_(&self) -> bool {
        *self == UsbRxplenDvEnum::DataIsValid_
    }
}
#[doc = "Field `PKT_RDY` reader - The PKT_LNGTH field is valid and the packet is ready for reading."]
pub type PktRdyR = crate::BitReader;
impl R {
    #[doc = "Bits 0:9 - The remaining number of bytes to be read from the currently selected endpoint's buffer. When this field decrements to 0, the RxENDPKT bit will be set in USBDevIntSt."]
    #[inline(always)]
    pub fn pkt_lngth(&self) -> PktLngthR {
        PktLngthR::new((self.bits & 0x03ff) as u16)
    }
    #[doc = "Bit 10 - Data valid. This bit is useful for isochronous endpoints. Non-isochronous endpoints do not raise an interrupt when an erroneous data packet is received. But invalid data packet can be produced with a bus reset. For isochronous endpoints, data transfer will happen even if an erroneous packet is received. In this case DV bit will not be set for the packet."]
    #[inline(always)]
    pub fn dv(&self) -> DvR {
        DvR::new(((self.bits >> 10) & 1) != 0)
    }
    #[doc = "Bit 11 - The PKT_LNGTH field is valid and the packet is ready for reading."]
    #[inline(always)]
    pub fn pkt_rdy(&self) -> PktRdyR {
        PktRdyR::new(((self.bits >> 11) & 1) != 0)
    }
}
#[doc = "USB Receive Packet Length\n\nYou can [`read`](crate::Reg::read) this register and get [`rxplen::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct RxplenSpec;
impl crate::RegisterSpec for RxplenSpec {
    type Ux = u32;
}
#[doc = "`read()` method returns [`rxplen::R`](R) reader structure"]
impl crate::Readable for RxplenSpec {}
#[doc = "`reset()` method sets RXPLEN to value 0"]
impl crate::Resettable for RxplenSpec {}
