efm32gg11b/usb/
doep3_tsiz.rs1#[doc = "Reader of register DOEP3_TSIZ"]
2pub type R = crate::R<u32, super::DOEP3_TSIZ>;
3#[doc = "Writer for register DOEP3_TSIZ"]
4pub type W = crate::W<u32, super::DOEP3_TSIZ>;
5#[doc = "Register DOEP3_TSIZ `reset()`'s with value 0"]
6impl crate::ResetValue for super::DOEP3_TSIZ {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type { 0 }
10}
11#[doc = "Reader of field `XFERSIZE`"]
12pub type XFERSIZE_R = crate::R<u32, u32>;
13#[doc = "Write proxy for field `XFERSIZE`"]
14pub struct XFERSIZE_W<'a> {
15    w: &'a mut W,
16}
17impl<'a> XFERSIZE_W<'a> {
18    #[doc = r"Writes raw bits to the field"]
19    #[inline(always)]
20    pub unsafe fn bits(self, value: u32) -> &'a mut W {
21        self.w.bits = (self.w.bits & !0x0007_ffff) | ((value as u32) & 0x0007_ffff);
22        self.w
23    }
24}
25#[doc = "Reader of field `PKTCNT`"]
26pub type PKTCNT_R = crate::R<u16, u16>;
27#[doc = "Write proxy for field `PKTCNT`"]
28pub struct PKTCNT_W<'a> {
29    w: &'a mut W,
30}
31impl<'a> PKTCNT_W<'a> {
32    #[doc = r"Writes raw bits to the field"]
33    #[inline(always)]
34    pub unsafe fn bits(self, value: u16) -> &'a mut W {
35        self.w.bits = (self.w.bits & !(0x03ff << 19)) | (((value as u32) & 0x03ff) << 19);
36        self.w
37    }
38}
39#[doc = "Receive Data PID / SETUP Packet Count\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u8)]
42pub enum RXDPIDSUPCNT_A {
43    #[doc = "0: DATA0 PID."]
44    DATA0 = 0,
45    #[doc = "1: DATA2 PID / 1 Packet."]
46    DATA2 = 1,
47    #[doc = "2: DATA1 PID / 2 Packets."]
48    DATA1 = 2,
49    #[doc = "3: MDATA PID / 3 Packets."]
50    MDATA = 3,
51}
52impl From<RXDPIDSUPCNT_A> for u8 {
53    #[inline(always)]
54    fn from(variant: RXDPIDSUPCNT_A) -> Self { variant as _ }
55}
56#[doc = "Reader of field `RXDPIDSUPCNT`"]
57pub type RXDPIDSUPCNT_R = crate::R<u8, RXDPIDSUPCNT_A>;
58impl RXDPIDSUPCNT_R {
59    #[doc = r"Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> RXDPIDSUPCNT_A {
62        match self.bits {
63            0 => RXDPIDSUPCNT_A::DATA0,
64            1 => RXDPIDSUPCNT_A::DATA2,
65            2 => RXDPIDSUPCNT_A::DATA1,
66            3 => RXDPIDSUPCNT_A::MDATA,
67            _ => unreachable!(),
68        }
69    }
70    #[doc = "Checks if the value of the field is `DATA0`"]
71    #[inline(always)]
72    pub fn is_data0(&self) -> bool { *self == RXDPIDSUPCNT_A::DATA0 }
73    #[doc = "Checks if the value of the field is `DATA2`"]
74    #[inline(always)]
75    pub fn is_data2(&self) -> bool { *self == RXDPIDSUPCNT_A::DATA2 }
76    #[doc = "Checks if the value of the field is `DATA1`"]
77    #[inline(always)]
78    pub fn is_data1(&self) -> bool { *self == RXDPIDSUPCNT_A::DATA1 }
79    #[doc = "Checks if the value of the field is `MDATA`"]
80    #[inline(always)]
81    pub fn is_mdata(&self) -> bool { *self == RXDPIDSUPCNT_A::MDATA }
82}
83impl R {
84    #[doc = "Bits 0:18 - Transfer Size"]
85    #[inline(always)]
86    pub fn xfersize(&self) -> XFERSIZE_R { XFERSIZE_R::new((self.bits & 0x0007_ffff) as u32) }
87    #[doc = "Bits 19:28 - Packet Count"]
88    #[inline(always)]
89    pub fn pktcnt(&self) -> PKTCNT_R { PKTCNT_R::new(((self.bits >> 19) & 0x03ff) as u16) }
90    #[doc = "Bits 29:30 - Receive Data PID / SETUP Packet Count"]
91    #[inline(always)]
92    pub fn rxdpidsupcnt(&self) -> RXDPIDSUPCNT_R {
93        RXDPIDSUPCNT_R::new(((self.bits >> 29) & 0x03) as u8)
94    }
95}
96impl W {
97    #[doc = "Bits 0:18 - Transfer Size"]
98    #[inline(always)]
99    pub fn xfersize(&mut self) -> XFERSIZE_W { XFERSIZE_W { w: self } }
100    #[doc = "Bits 19:28 - Packet Count"]
101    #[inline(always)]
102    pub fn pktcnt(&mut self) -> PKTCNT_W { PKTCNT_W { w: self } }
103}