lpc55_pac/usbfsh/
portmode.rs1#[doc = "Register `PORTMODE` reader"]
2pub struct R(crate::R<PORTMODE_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<PORTMODE_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<PORTMODE_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<PORTMODE_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `PORTMODE` writer"]
17pub struct W(crate::W<PORTMODE_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<PORTMODE_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<PORTMODE_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<PORTMODE_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `ID` reader - Port ID pin value."]
38pub struct ID_R(crate::FieldReader<bool, bool>);
39impl ID_R {
40 #[inline(always)]
41 pub(crate) fn new(bits: bool) -> Self {
42 ID_R(crate::FieldReader::new(bits))
43 }
44}
45impl core::ops::Deref for ID_R {
46 type Target = crate::FieldReader<bool, bool>;
47 #[inline(always)]
48 fn deref(&self) -> &Self::Target {
49 &self.0
50 }
51}
52#[doc = "Field `ID` writer - Port ID pin value."]
53pub struct ID_W<'a> {
54 w: &'a mut W,
55}
56impl<'a> ID_W<'a> {
57 #[doc = r"Sets the field bit"]
58 #[inline(always)]
59 pub fn set_bit(self) -> &'a mut W {
60 self.bit(true)
61 }
62 #[doc = r"Clears the field bit"]
63 #[inline(always)]
64 pub fn clear_bit(self) -> &'a mut W {
65 self.bit(false)
66 }
67 #[doc = r"Writes raw bits to the field"]
68 #[inline(always)]
69 pub fn bit(self, value: bool) -> &'a mut W {
70 self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
71 self.w
72 }
73}
74#[doc = "Field `ID_EN` reader - Port ID pin pull-up enable."]
75pub struct ID_EN_R(crate::FieldReader<bool, bool>);
76impl ID_EN_R {
77 #[inline(always)]
78 pub(crate) fn new(bits: bool) -> Self {
79 ID_EN_R(crate::FieldReader::new(bits))
80 }
81}
82impl core::ops::Deref for ID_EN_R {
83 type Target = crate::FieldReader<bool, bool>;
84 #[inline(always)]
85 fn deref(&self) -> &Self::Target {
86 &self.0
87 }
88}
89#[doc = "Field `ID_EN` writer - Port ID pin pull-up enable."]
90pub struct ID_EN_W<'a> {
91 w: &'a mut W,
92}
93impl<'a> ID_EN_W<'a> {
94 #[doc = r"Sets the field bit"]
95 #[inline(always)]
96 pub fn set_bit(self) -> &'a mut W {
97 self.bit(true)
98 }
99 #[doc = r"Clears the field bit"]
100 #[inline(always)]
101 pub fn clear_bit(self) -> &'a mut W {
102 self.bit(false)
103 }
104 #[doc = r"Writes raw bits to the field"]
105 #[inline(always)]
106 pub fn bit(self, value: bool) -> &'a mut W {
107 self.w.bits = (self.w.bits & !(0x01 << 8)) | ((value as u32 & 0x01) << 8);
108 self.w
109 }
110}
111#[doc = "Field `DEV_ENABLE` reader - 1: device 0: host."]
112pub struct DEV_ENABLE_R(crate::FieldReader<bool, bool>);
113impl DEV_ENABLE_R {
114 #[inline(always)]
115 pub(crate) fn new(bits: bool) -> Self {
116 DEV_ENABLE_R(crate::FieldReader::new(bits))
117 }
118}
119impl core::ops::Deref for DEV_ENABLE_R {
120 type Target = crate::FieldReader<bool, bool>;
121 #[inline(always)]
122 fn deref(&self) -> &Self::Target {
123 &self.0
124 }
125}
126#[doc = "Field `DEV_ENABLE` writer - 1: device 0: host."]
127pub struct DEV_ENABLE_W<'a> {
128 w: &'a mut W,
129}
130impl<'a> DEV_ENABLE_W<'a> {
131 #[doc = r"Sets the field bit"]
132 #[inline(always)]
133 pub fn set_bit(self) -> &'a mut W {
134 self.bit(true)
135 }
136 #[doc = r"Clears the field bit"]
137 #[inline(always)]
138 pub fn clear_bit(self) -> &'a mut W {
139 self.bit(false)
140 }
141 #[doc = r"Writes raw bits to the field"]
142 #[inline(always)]
143 pub fn bit(self, value: bool) -> &'a mut W {
144 self.w.bits = (self.w.bits & !(0x01 << 16)) | ((value as u32 & 0x01) << 16);
145 self.w
146 }
147}
148impl R {
149 #[doc = "Bit 0 - Port ID pin value."]
150 #[inline(always)]
151 pub fn id(&self) -> ID_R {
152 ID_R::new((self.bits & 0x01) != 0)
153 }
154 #[doc = "Bit 8 - Port ID pin pull-up enable."]
155 #[inline(always)]
156 pub fn id_en(&self) -> ID_EN_R {
157 ID_EN_R::new(((self.bits >> 8) & 0x01) != 0)
158 }
159 #[doc = "Bit 16 - 1: device 0: host."]
160 #[inline(always)]
161 pub fn dev_enable(&self) -> DEV_ENABLE_R {
162 DEV_ENABLE_R::new(((self.bits >> 16) & 0x01) != 0)
163 }
164}
165impl W {
166 #[doc = "Bit 0 - Port ID pin value."]
167 #[inline(always)]
168 pub fn id(&mut self) -> ID_W {
169 ID_W { w: self }
170 }
171 #[doc = "Bit 8 - Port ID pin pull-up enable."]
172 #[inline(always)]
173 pub fn id_en(&mut self) -> ID_EN_W {
174 ID_EN_W { w: self }
175 }
176 #[doc = "Bit 16 - 1: device 0: host."]
177 #[inline(always)]
178 pub fn dev_enable(&mut self) -> DEV_ENABLE_W {
179 DEV_ENABLE_W { w: self }
180 }
181 #[doc = "Writes raw bits to the register."]
182 #[inline(always)]
183 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
184 self.0.bits(bits);
185 self
186 }
187}
188#[doc = "Controls the port if it is attached to the host block or the device block\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 [portmode](index.html) module"]
189pub struct PORTMODE_SPEC;
190impl crate::RegisterSpec for PORTMODE_SPEC {
191 type Ux = u32;
192}
193#[doc = "`read()` method returns [portmode::R](R) reader structure"]
194impl crate::Readable for PORTMODE_SPEC {
195 type Reader = R;
196}
197#[doc = "`write(|w| ..)` method takes [portmode::W](W) writer structure"]
198impl crate::Writable for PORTMODE_SPEC {
199 type Writer = W;
200}
201#[doc = "`reset()` method sets PORTMODE to value 0"]
202impl crate::Resettable for PORTMODE_SPEC {
203 #[inline(always)]
204 fn reset_value() -> Self::Ux {
205 0
206 }
207}