swm341_pac/usbh/
token.rs

1#[doc = "Register `TOKEN` reader"]
2pub struct R(crate::R<TOKEN_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<TOKEN_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<TOKEN_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<TOKEN_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `TOKEN` writer"]
17pub struct W(crate::W<TOKEN_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<TOKEN_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<TOKEN_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<TOKEN_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `ADDR` reader - ADDR field"]
38pub type ADDR_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `ADDR` writer - ADDR field"]
40pub type ADDR_W<'a, const O: u8> = crate::FieldWriter<'a, u32, TOKEN_SPEC, u8, u8, 7, O>;
41#[doc = "Field `EPNR` reader - EPNR field"]
42pub type EPNR_R = crate::FieldReader<u8, u8>;
43#[doc = "Field `EPNR` writer - EPNR field"]
44pub type EPNR_W<'a, const O: u8> = crate::FieldWriter<'a, u32, TOKEN_SPEC, u8, u8, 4, O>;
45#[doc = "Field `DATAX` reader - DATAX field"]
46pub type DATAX_R = crate::BitReader<bool>;
47#[doc = "Field `DATAX` writer - DATAX field"]
48pub type DATAX_W<'a, const O: u8> = crate::BitWriter<'a, u32, TOKEN_SPEC, bool, O>;
49#[doc = "Field `TYPE` reader - TYPE field"]
50pub type TYPE_R = crate::FieldReader<u8, u8>;
51#[doc = "Field `TYPE` writer - TYPE field"]
52pub type TYPE_W<'a, const O: u8> = crate::FieldWriter<'a, u32, TOKEN_SPEC, u8, u8, 4, O>;
53#[doc = "Field `ISO` reader - ISO field"]
54pub type ISO_R = crate::BitReader<bool>;
55#[doc = "Field `ISO` writer - ISO field"]
56pub type ISO_W<'a, const O: u8> = crate::BitWriter<'a, u32, TOKEN_SPEC, bool, O>;
57#[doc = "Field `SPEED` reader - SPEED field"]
58pub type SPEED_R = crate::FieldReader<u8, u8>;
59#[doc = "Field `SPEED` writer - SPEED field"]
60pub type SPEED_W<'a, const O: u8> = crate::FieldWriter<'a, u32, TOKEN_SPEC, u8, u8, 2, O>;
61#[doc = "Field `TRSZ` reader - TRSZ field"]
62pub type TRSZ_R = crate::FieldReader<u16, u16>;
63#[doc = "Field `TRSZ` writer - TRSZ field"]
64pub type TRSZ_W<'a, const O: u8> = crate::FieldWriter<'a, u32, TOKEN_SPEC, u16, u16, 10, O>;
65impl R {
66    #[doc = "Bits 0:6 - ADDR field"]
67    #[inline(always)]
68    pub fn addr(&self) -> ADDR_R {
69        ADDR_R::new((self.bits & 0x7f) as u8)
70    }
71    #[doc = "Bits 7:10 - EPNR field"]
72    #[inline(always)]
73    pub fn epnr(&self) -> EPNR_R {
74        EPNR_R::new(((self.bits >> 7) & 0x0f) as u8)
75    }
76    #[doc = "Bit 11 - DATAX field"]
77    #[inline(always)]
78    pub fn datax(&self) -> DATAX_R {
79        DATAX_R::new(((self.bits >> 11) & 1) != 0)
80    }
81    #[doc = "Bits 13:16 - TYPE field"]
82    #[inline(always)]
83    pub fn type_(&self) -> TYPE_R {
84        TYPE_R::new(((self.bits >> 13) & 0x0f) as u8)
85    }
86    #[doc = "Bit 17 - ISO field"]
87    #[inline(always)]
88    pub fn iso(&self) -> ISO_R {
89        ISO_R::new(((self.bits >> 17) & 1) != 0)
90    }
91    #[doc = "Bits 18:19 - SPEED field"]
92    #[inline(always)]
93    pub fn speed(&self) -> SPEED_R {
94        SPEED_R::new(((self.bits >> 18) & 3) as u8)
95    }
96    #[doc = "Bits 20:29 - TRSZ field"]
97    #[inline(always)]
98    pub fn trsz(&self) -> TRSZ_R {
99        TRSZ_R::new(((self.bits >> 20) & 0x03ff) as u16)
100    }
101}
102impl W {
103    #[doc = "Bits 0:6 - ADDR field"]
104    #[inline(always)]
105    pub fn addr(&mut self) -> ADDR_W<0> {
106        ADDR_W::new(self)
107    }
108    #[doc = "Bits 7:10 - EPNR field"]
109    #[inline(always)]
110    pub fn epnr(&mut self) -> EPNR_W<7> {
111        EPNR_W::new(self)
112    }
113    #[doc = "Bit 11 - DATAX field"]
114    #[inline(always)]
115    pub fn datax(&mut self) -> DATAX_W<11> {
116        DATAX_W::new(self)
117    }
118    #[doc = "Bits 13:16 - TYPE field"]
119    #[inline(always)]
120    pub fn type_(&mut self) -> TYPE_W<13> {
121        TYPE_W::new(self)
122    }
123    #[doc = "Bit 17 - ISO field"]
124    #[inline(always)]
125    pub fn iso(&mut self) -> ISO_W<17> {
126        ISO_W::new(self)
127    }
128    #[doc = "Bits 18:19 - SPEED field"]
129    #[inline(always)]
130    pub fn speed(&mut self) -> SPEED_W<18> {
131        SPEED_W::new(self)
132    }
133    #[doc = "Bits 20:29 - TRSZ field"]
134    #[inline(always)]
135    pub fn trsz(&mut self) -> TRSZ_W<20> {
136        TRSZ_W::new(self)
137    }
138    #[doc = "Writes raw bits to the register."]
139    #[inline(always)]
140    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
141        self.0.bits(bits);
142        self
143    }
144}
145#[doc = "TOKEN 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 [token](index.html) module"]
146pub struct TOKEN_SPEC;
147impl crate::RegisterSpec for TOKEN_SPEC {
148    type Ux = u32;
149}
150#[doc = "`read()` method returns [token::R](R) reader structure"]
151impl crate::Readable for TOKEN_SPEC {
152    type Reader = R;
153}
154#[doc = "`write(|w| ..)` method takes [token::W](W) writer structure"]
155impl crate::Writable for TOKEN_SPEC {
156    type Writer = W;
157}
158#[doc = "`reset()` method sets TOKEN to value 0"]
159impl crate::Resettable for TOKEN_SPEC {
160    #[inline(always)]
161    fn reset_value() -> Self::Ux {
162        0
163    }
164}