ra6m4/usbfs/
usbaddr.rs

1#[doc = "Register `USBADDR` reader"]
2pub struct R(crate::R<USBADDR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<USBADDR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<USBADDR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<USBADDR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `USBADDR` writer"]
17pub struct W(crate::W<USBADDR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<USBADDR_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<USBADDR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<USBADDR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `USBADDR` reader - USB Address"]
38pub type USBADDR_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `USBADDR` writer - USB Address"]
40pub type USBADDR_W<'a, const O: u8> = crate::FieldWriter<'a, u16, USBADDR_SPEC, u8, u8, 7, O>;
41#[doc = "Field `STSRECOV` reader - Status Recovery"]
42pub type STSRECOV_R = crate::FieldReader<u8, STSRECOV_A>;
43#[doc = "Status Recovery\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum STSRECOV_A {
47    #[doc = "4: Recovery in device controller mode: Setting prohibited Recovery in host controller mode: Return to the low-speed state (bits DVSTCTR0.RHST\\[2:0\\]
48= 001b)"]
49    _0X4 = 4,
50    #[doc = "8: Recovery in device controller mode: Setting prohibited Recovery in host controller mode: Return to the full-speed state (bits DVSTCTR0.RHST\\[2:0\\]
51= 010b)"]
52    _0X8 = 8,
53    #[doc = "9: Recovery in device controller mode: Return to the full-speed state (bits DVSTCTR0.RHST\\[2:0\\]
54= 010b), bits INTSTS0.DVSQ\\[2:0\\]
55= 001b (default state) Recovery in host controller mode: Setting prohibited"]
56    _0X9 = 9,
57    #[doc = "10: Recovery in device controller mode: Return to the full-speed state (bits DVSTCTR0.RHST\\[2:0\\]
58= 010b), bits INTSTS0.DVSQ\\[2:0\\]
59= 010b (address state) Recovery in host controller mode: Setting prohibited"]
60    _0X_A = 10,
61    #[doc = "11: Recovery in device controller mode: Return to the full-speed state (bits DVSTCTR0.RHST\\[2:0\\]
62= 010b), bits INTSTS0.DVSQ\\[2:0\\]
63= 011b (configured state) Recovery in host controller mode: Setting prohibited"]
64    _0X_B = 11,
65}
66impl From<STSRECOV_A> for u8 {
67    #[inline(always)]
68    fn from(variant: STSRECOV_A) -> Self {
69        variant as _
70    }
71}
72impl STSRECOV_R {
73    #[doc = "Get enumerated values variant"]
74    #[inline(always)]
75    pub fn variant(&self) -> Option<STSRECOV_A> {
76        match self.bits {
77            4 => Some(STSRECOV_A::_0X4),
78            8 => Some(STSRECOV_A::_0X8),
79            9 => Some(STSRECOV_A::_0X9),
80            10 => Some(STSRECOV_A::_0X_A),
81            11 => Some(STSRECOV_A::_0X_B),
82            _ => None,
83        }
84    }
85    #[doc = "Checks if the value of the field is `_0X4`"]
86    #[inline(always)]
87    pub fn is_0x4(&self) -> bool {
88        *self == STSRECOV_A::_0X4
89    }
90    #[doc = "Checks if the value of the field is `_0X8`"]
91    #[inline(always)]
92    pub fn is_0x8(&self) -> bool {
93        *self == STSRECOV_A::_0X8
94    }
95    #[doc = "Checks if the value of the field is `_0X9`"]
96    #[inline(always)]
97    pub fn is_0x9(&self) -> bool {
98        *self == STSRECOV_A::_0X9
99    }
100    #[doc = "Checks if the value of the field is `_0X_A`"]
101    #[inline(always)]
102    pub fn is_0x_a(&self) -> bool {
103        *self == STSRECOV_A::_0X_A
104    }
105    #[doc = "Checks if the value of the field is `_0X_B`"]
106    #[inline(always)]
107    pub fn is_0x_b(&self) -> bool {
108        *self == STSRECOV_A::_0X_B
109    }
110}
111#[doc = "Field `STSRECOV` writer - Status Recovery"]
112pub type STSRECOV_W<'a, const O: u8> =
113    crate::FieldWriter<'a, u16, USBADDR_SPEC, u8, STSRECOV_A, 4, O>;
114impl<'a, const O: u8> STSRECOV_W<'a, O> {
115    #[doc = "Recovery in device controller mode: Setting prohibited Recovery in host controller mode: Return to the low-speed state (bits DVSTCTR0.RHST\\[2:0\\]
116= 001b)"]
117    #[inline(always)]
118    pub fn _0x4(self) -> &'a mut W {
119        self.variant(STSRECOV_A::_0X4)
120    }
121    #[doc = "Recovery in device controller mode: Setting prohibited Recovery in host controller mode: Return to the full-speed state (bits DVSTCTR0.RHST\\[2:0\\]
122= 010b)"]
123    #[inline(always)]
124    pub fn _0x8(self) -> &'a mut W {
125        self.variant(STSRECOV_A::_0X8)
126    }
127    #[doc = "Recovery in device controller mode: Return to the full-speed state (bits DVSTCTR0.RHST\\[2:0\\]
128= 010b), bits INTSTS0.DVSQ\\[2:0\\]
129= 001b (default state) Recovery in host controller mode: Setting prohibited"]
130    #[inline(always)]
131    pub fn _0x9(self) -> &'a mut W {
132        self.variant(STSRECOV_A::_0X9)
133    }
134    #[doc = "Recovery in device controller mode: Return to the full-speed state (bits DVSTCTR0.RHST\\[2:0\\]
135= 010b), bits INTSTS0.DVSQ\\[2:0\\]
136= 010b (address state) Recovery in host controller mode: Setting prohibited"]
137    #[inline(always)]
138    pub fn _0x_a(self) -> &'a mut W {
139        self.variant(STSRECOV_A::_0X_A)
140    }
141    #[doc = "Recovery in device controller mode: Return to the full-speed state (bits DVSTCTR0.RHST\\[2:0\\]
142= 010b), bits INTSTS0.DVSQ\\[2:0\\]
143= 011b (configured state) Recovery in host controller mode: Setting prohibited"]
144    #[inline(always)]
145    pub fn _0x_b(self) -> &'a mut W {
146        self.variant(STSRECOV_A::_0X_B)
147    }
148}
149impl R {
150    #[doc = "Bits 0:6 - USB Address"]
151    #[inline(always)]
152    pub fn usbaddr(&self) -> USBADDR_R {
153        USBADDR_R::new((self.bits & 0x7f) as u8)
154    }
155    #[doc = "Bits 8:11 - Status Recovery"]
156    #[inline(always)]
157    pub fn stsrecov(&self) -> STSRECOV_R {
158        STSRECOV_R::new(((self.bits >> 8) & 0x0f) as u8)
159    }
160}
161impl W {
162    #[doc = "Bits 0:6 - USB Address"]
163    #[inline(always)]
164    #[must_use]
165    pub fn usbaddr(&mut self) -> USBADDR_W<0> {
166        USBADDR_W::new(self)
167    }
168    #[doc = "Bits 8:11 - Status Recovery"]
169    #[inline(always)]
170    #[must_use]
171    pub fn stsrecov(&mut self) -> STSRECOV_W<8> {
172        STSRECOV_W::new(self)
173    }
174    #[doc = "Writes raw bits to the register."]
175    #[inline(always)]
176    pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
177        self.0.bits(bits);
178        self
179    }
180}
181#[doc = "USB Address 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 [usbaddr](index.html) module"]
182pub struct USBADDR_SPEC;
183impl crate::RegisterSpec for USBADDR_SPEC {
184    type Ux = u16;
185}
186#[doc = "`read()` method returns [usbaddr::R](R) reader structure"]
187impl crate::Readable for USBADDR_SPEC {
188    type Reader = R;
189}
190#[doc = "`write(|w| ..)` method takes [usbaddr::W](W) writer structure"]
191impl crate::Writable for USBADDR_SPEC {
192    type Writer = W;
193    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
194    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
195}
196#[doc = "`reset()` method sets USBADDR to value 0"]
197impl crate::Resettable for USBADDR_SPEC {
198    const RESET_VALUE: Self::Ux = 0;
199}