nrf52840_pac/usbd/
dtoggle.rs
1#[doc = "Register `DTOGGLE` reader"]
2pub struct R(crate::R<DTOGGLE_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<DTOGGLE_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<DTOGGLE_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<DTOGGLE_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `DTOGGLE` writer"]
17pub struct W(crate::W<DTOGGLE_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<DTOGGLE_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<DTOGGLE_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<DTOGGLE_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `EP` reader - Select bulk endpoint number"]
38pub type EP_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `EP` writer - Select bulk endpoint number"]
40pub type EP_W<'a, const O: u8> = crate::FieldWriter<'a, u32, DTOGGLE_SPEC, u8, u8, 3, O>;
41#[doc = "Field `IO` reader - Selects IN or OUT endpoint"]
42pub type IO_R = crate::BitReader<IO_A>;
43#[doc = "Selects IN or OUT endpoint\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq)]
45pub enum IO_A {
46 #[doc = "0: Selects OUT endpoint"]
47 OUT = 0,
48 #[doc = "1: Selects IN endpoint"]
49 IN = 1,
50}
51impl From<IO_A> for bool {
52 #[inline(always)]
53 fn from(variant: IO_A) -> Self {
54 variant as u8 != 0
55 }
56}
57impl IO_R {
58 #[doc = "Get enumerated values variant"]
59 #[inline(always)]
60 pub fn variant(&self) -> IO_A {
61 match self.bits {
62 false => IO_A::OUT,
63 true => IO_A::IN,
64 }
65 }
66 #[doc = "Checks if the value of the field is `OUT`"]
67 #[inline(always)]
68 pub fn is_out(&self) -> bool {
69 *self == IO_A::OUT
70 }
71 #[doc = "Checks if the value of the field is `IN`"]
72 #[inline(always)]
73 pub fn is_in(&self) -> bool {
74 *self == IO_A::IN
75 }
76}
77#[doc = "Field `IO` writer - Selects IN or OUT endpoint"]
78pub type IO_W<'a, const O: u8> = crate::BitWriter<'a, u32, DTOGGLE_SPEC, IO_A, O>;
79impl<'a, const O: u8> IO_W<'a, O> {
80 #[doc = "Selects OUT endpoint"]
81 #[inline(always)]
82 pub fn out(self) -> &'a mut W {
83 self.variant(IO_A::OUT)
84 }
85 #[doc = "Selects IN endpoint"]
86 #[inline(always)]
87 pub fn in_(self) -> &'a mut W {
88 self.variant(IO_A::IN)
89 }
90}
91#[doc = "Field `VALUE` reader - Data toggle value"]
92pub type VALUE_R = crate::FieldReader<u8, VALUE_A>;
93#[doc = "Data toggle value\n\nValue on reset: 1"]
94#[derive(Clone, Copy, Debug, PartialEq)]
95#[repr(u8)]
96pub enum VALUE_A {
97 #[doc = "0: No action on data toggle when writing the register with this value"]
98 NOP = 0,
99 #[doc = "1: Data toggle is DATA0 on endpoint set by EP and IO"]
100 DATA0 = 1,
101 #[doc = "2: Data toggle is DATA1 on endpoint set by EP and IO"]
102 DATA1 = 2,
103}
104impl From<VALUE_A> for u8 {
105 #[inline(always)]
106 fn from(variant: VALUE_A) -> Self {
107 variant as _
108 }
109}
110impl VALUE_R {
111 #[doc = "Get enumerated values variant"]
112 #[inline(always)]
113 pub fn variant(&self) -> Option<VALUE_A> {
114 match self.bits {
115 0 => Some(VALUE_A::NOP),
116 1 => Some(VALUE_A::DATA0),
117 2 => Some(VALUE_A::DATA1),
118 _ => None,
119 }
120 }
121 #[doc = "Checks if the value of the field is `NOP`"]
122 #[inline(always)]
123 pub fn is_nop(&self) -> bool {
124 *self == VALUE_A::NOP
125 }
126 #[doc = "Checks if the value of the field is `DATA0`"]
127 #[inline(always)]
128 pub fn is_data0(&self) -> bool {
129 *self == VALUE_A::DATA0
130 }
131 #[doc = "Checks if the value of the field is `DATA1`"]
132 #[inline(always)]
133 pub fn is_data1(&self) -> bool {
134 *self == VALUE_A::DATA1
135 }
136}
137#[doc = "Field `VALUE` writer - Data toggle value"]
138pub type VALUE_W<'a, const O: u8> = crate::FieldWriter<'a, u32, DTOGGLE_SPEC, u8, VALUE_A, 2, O>;
139impl<'a, const O: u8> VALUE_W<'a, O> {
140 #[doc = "No action on data toggle when writing the register with this value"]
141 #[inline(always)]
142 pub fn nop(self) -> &'a mut W {
143 self.variant(VALUE_A::NOP)
144 }
145 #[doc = "Data toggle is DATA0 on endpoint set by EP and IO"]
146 #[inline(always)]
147 pub fn data0(self) -> &'a mut W {
148 self.variant(VALUE_A::DATA0)
149 }
150 #[doc = "Data toggle is DATA1 on endpoint set by EP and IO"]
151 #[inline(always)]
152 pub fn data1(self) -> &'a mut W {
153 self.variant(VALUE_A::DATA1)
154 }
155}
156impl R {
157 #[doc = "Bits 0:2 - Select bulk endpoint number"]
158 #[inline(always)]
159 pub fn ep(&self) -> EP_R {
160 EP_R::new((self.bits & 7) as u8)
161 }
162 #[doc = "Bit 7 - Selects IN or OUT endpoint"]
163 #[inline(always)]
164 pub fn io(&self) -> IO_R {
165 IO_R::new(((self.bits >> 7) & 1) != 0)
166 }
167 #[doc = "Bits 8:9 - Data toggle value"]
168 #[inline(always)]
169 pub fn value(&self) -> VALUE_R {
170 VALUE_R::new(((self.bits >> 8) & 3) as u8)
171 }
172}
173impl W {
174 #[doc = "Bits 0:2 - Select bulk endpoint number"]
175 #[inline(always)]
176 pub fn ep(&mut self) -> EP_W<0> {
177 EP_W::new(self)
178 }
179 #[doc = "Bit 7 - Selects IN or OUT endpoint"]
180 #[inline(always)]
181 pub fn io(&mut self) -> IO_W<7> {
182 IO_W::new(self)
183 }
184 #[doc = "Bits 8:9 - Data toggle value"]
185 #[inline(always)]
186 pub fn value(&mut self) -> VALUE_W<8> {
187 VALUE_W::new(self)
188 }
189 #[doc = "Writes raw bits to the register."]
190 #[inline(always)]
191 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
192 self.0.bits(bits);
193 self
194 }
195}
196#[doc = "Data toggle control and status\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 [dtoggle](index.html) module"]
197pub struct DTOGGLE_SPEC;
198impl crate::RegisterSpec for DTOGGLE_SPEC {
199 type Ux = u32;
200}
201#[doc = "`read()` method returns [dtoggle::R](R) reader structure"]
202impl crate::Readable for DTOGGLE_SPEC {
203 type Reader = R;
204}
205#[doc = "`write(|w| ..)` method takes [dtoggle::W](W) writer structure"]
206impl crate::Writable for DTOGGLE_SPEC {
207 type Writer = W;
208}
209#[doc = "`reset()` method sets DTOGGLE to value 0x0100"]
210impl crate::Resettable for DTOGGLE_SPEC {
211 #[inline(always)]
212 fn reset_value() -> Self::Ux {
213 0x0100
214 }
215}