1#[doc = "Register `PIN_CNF[%s]` reader"]
2pub struct R(crate::R<PIN_CNF_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<PIN_CNF_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<PIN_CNF_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<PIN_CNF_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `PIN_CNF[%s]` writer"]
17pub struct W(crate::W<PIN_CNF_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<PIN_CNF_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<PIN_CNF_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<PIN_CNF_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `DIR` reader - Pin direction. Same physical register as DIR register"]
38pub type DIR_R = crate::BitReader<DIR_A>;
39#[doc = "Pin direction. Same physical register as DIR register\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41pub enum DIR_A {
42 #[doc = "0: Configure pin as an input pin"]
43 INPUT = 0,
44 #[doc = "1: Configure pin as an output pin"]
45 OUTPUT = 1,
46}
47impl From<DIR_A> for bool {
48 #[inline(always)]
49 fn from(variant: DIR_A) -> Self {
50 variant as u8 != 0
51 }
52}
53impl DIR_R {
54 #[doc = "Get enumerated values variant"]
55 #[inline(always)]
56 pub fn variant(&self) -> DIR_A {
57 match self.bits {
58 false => DIR_A::INPUT,
59 true => DIR_A::OUTPUT,
60 }
61 }
62 #[doc = "Checks if the value of the field is `INPUT`"]
63 #[inline(always)]
64 pub fn is_input(&self) -> bool {
65 *self == DIR_A::INPUT
66 }
67 #[doc = "Checks if the value of the field is `OUTPUT`"]
68 #[inline(always)]
69 pub fn is_output(&self) -> bool {
70 *self == DIR_A::OUTPUT
71 }
72}
73#[doc = "Field `DIR` writer - Pin direction. Same physical register as DIR register"]
74pub type DIR_W<'a, const O: u8> = crate::BitWriter<'a, u32, PIN_CNF_SPEC, DIR_A, O>;
75impl<'a, const O: u8> DIR_W<'a, O> {
76 #[doc = "Configure pin as an input pin"]
77 #[inline(always)]
78 pub fn input(self) -> &'a mut W {
79 self.variant(DIR_A::INPUT)
80 }
81 #[doc = "Configure pin as an output pin"]
82 #[inline(always)]
83 pub fn output(self) -> &'a mut W {
84 self.variant(DIR_A::OUTPUT)
85 }
86}
87#[doc = "Field `INPUT` reader - Connect or disconnect input buffer"]
88pub type INPUT_R = crate::BitReader<INPUT_A>;
89#[doc = "Connect or disconnect input buffer\n\nValue on reset: 1"]
90#[derive(Clone, Copy, Debug, PartialEq)]
91pub enum INPUT_A {
92 #[doc = "0: Connect input buffer"]
93 CONNECT = 0,
94 #[doc = "1: Disconnect input buffer"]
95 DISCONNECT = 1,
96}
97impl From<INPUT_A> for bool {
98 #[inline(always)]
99 fn from(variant: INPUT_A) -> Self {
100 variant as u8 != 0
101 }
102}
103impl INPUT_R {
104 #[doc = "Get enumerated values variant"]
105 #[inline(always)]
106 pub fn variant(&self) -> INPUT_A {
107 match self.bits {
108 false => INPUT_A::CONNECT,
109 true => INPUT_A::DISCONNECT,
110 }
111 }
112 #[doc = "Checks if the value of the field is `CONNECT`"]
113 #[inline(always)]
114 pub fn is_connect(&self) -> bool {
115 *self == INPUT_A::CONNECT
116 }
117 #[doc = "Checks if the value of the field is `DISCONNECT`"]
118 #[inline(always)]
119 pub fn is_disconnect(&self) -> bool {
120 *self == INPUT_A::DISCONNECT
121 }
122}
123#[doc = "Field `INPUT` writer - Connect or disconnect input buffer"]
124pub type INPUT_W<'a, const O: u8> = crate::BitWriter<'a, u32, PIN_CNF_SPEC, INPUT_A, O>;
125impl<'a, const O: u8> INPUT_W<'a, O> {
126 #[doc = "Connect input buffer"]
127 #[inline(always)]
128 pub fn connect(self) -> &'a mut W {
129 self.variant(INPUT_A::CONNECT)
130 }
131 #[doc = "Disconnect input buffer"]
132 #[inline(always)]
133 pub fn disconnect(self) -> &'a mut W {
134 self.variant(INPUT_A::DISCONNECT)
135 }
136}
137#[doc = "Field `PULL` reader - Pull configuration"]
138pub type PULL_R = crate::FieldReader<u8, PULL_A>;
139#[doc = "Pull configuration\n\nValue on reset: 0"]
140#[derive(Clone, Copy, Debug, PartialEq)]
141#[repr(u8)]
142pub enum PULL_A {
143 #[doc = "0: No pull"]
144 DISABLED = 0,
145 #[doc = "1: Pull down on pin"]
146 PULLDOWN = 1,
147 #[doc = "3: Pull up on pin"]
148 PULLUP = 3,
149}
150impl From<PULL_A> for u8 {
151 #[inline(always)]
152 fn from(variant: PULL_A) -> Self {
153 variant as _
154 }
155}
156impl PULL_R {
157 #[doc = "Get enumerated values variant"]
158 #[inline(always)]
159 pub fn variant(&self) -> Option<PULL_A> {
160 match self.bits {
161 0 => Some(PULL_A::DISABLED),
162 1 => Some(PULL_A::PULLDOWN),
163 3 => Some(PULL_A::PULLUP),
164 _ => None,
165 }
166 }
167 #[doc = "Checks if the value of the field is `DISABLED`"]
168 #[inline(always)]
169 pub fn is_disabled(&self) -> bool {
170 *self == PULL_A::DISABLED
171 }
172 #[doc = "Checks if the value of the field is `PULLDOWN`"]
173 #[inline(always)]
174 pub fn is_pulldown(&self) -> bool {
175 *self == PULL_A::PULLDOWN
176 }
177 #[doc = "Checks if the value of the field is `PULLUP`"]
178 #[inline(always)]
179 pub fn is_pullup(&self) -> bool {
180 *self == PULL_A::PULLUP
181 }
182}
183#[doc = "Field `PULL` writer - Pull configuration"]
184pub type PULL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, PIN_CNF_SPEC, u8, PULL_A, 2, O>;
185impl<'a, const O: u8> PULL_W<'a, O> {
186 #[doc = "No pull"]
187 #[inline(always)]
188 pub fn disabled(self) -> &'a mut W {
189 self.variant(PULL_A::DISABLED)
190 }
191 #[doc = "Pull down on pin"]
192 #[inline(always)]
193 pub fn pulldown(self) -> &'a mut W {
194 self.variant(PULL_A::PULLDOWN)
195 }
196 #[doc = "Pull up on pin"]
197 #[inline(always)]
198 pub fn pullup(self) -> &'a mut W {
199 self.variant(PULL_A::PULLUP)
200 }
201}
202#[doc = "Field `DRIVE` reader - Drive configuration"]
203pub type DRIVE_R = crate::FieldReader<u8, DRIVE_A>;
204#[doc = "Drive configuration\n\nValue on reset: 0"]
205#[derive(Clone, Copy, Debug, PartialEq)]
206#[repr(u8)]
207pub enum DRIVE_A {
208 #[doc = "0: Standard '0', standard '1'"]
209 S0S1 = 0,
210 #[doc = "1: High drive '0', standard '1'"]
211 H0S1 = 1,
212 #[doc = "2: Standard '0', high drive '1'"]
213 S0H1 = 2,
214 #[doc = "3: High drive '0', high 'drive '1''"]
215 H0H1 = 3,
216 #[doc = "4: Disconnect '0' standard '1' (normally used for wired-or connections)"]
217 D0S1 = 4,
218 #[doc = "5: Disconnect '0', high drive '1' (normally used for wired-or connections)"]
219 D0H1 = 5,
220 #[doc = "6: Standard '0'. disconnect '1' (normally used for wired-and connections)"]
221 S0D1 = 6,
222 #[doc = "7: High drive '0', disconnect '1' (normally used for wired-and connections)"]
223 H0D1 = 7,
224}
225impl From<DRIVE_A> for u8 {
226 #[inline(always)]
227 fn from(variant: DRIVE_A) -> Self {
228 variant as _
229 }
230}
231impl DRIVE_R {
232 #[doc = "Get enumerated values variant"]
233 #[inline(always)]
234 pub fn variant(&self) -> DRIVE_A {
235 match self.bits {
236 0 => DRIVE_A::S0S1,
237 1 => DRIVE_A::H0S1,
238 2 => DRIVE_A::S0H1,
239 3 => DRIVE_A::H0H1,
240 4 => DRIVE_A::D0S1,
241 5 => DRIVE_A::D0H1,
242 6 => DRIVE_A::S0D1,
243 7 => DRIVE_A::H0D1,
244 _ => unreachable!(),
245 }
246 }
247 #[doc = "Checks if the value of the field is `S0S1`"]
248 #[inline(always)]
249 pub fn is_s0s1(&self) -> bool {
250 *self == DRIVE_A::S0S1
251 }
252 #[doc = "Checks if the value of the field is `H0S1`"]
253 #[inline(always)]
254 pub fn is_h0s1(&self) -> bool {
255 *self == DRIVE_A::H0S1
256 }
257 #[doc = "Checks if the value of the field is `S0H1`"]
258 #[inline(always)]
259 pub fn is_s0h1(&self) -> bool {
260 *self == DRIVE_A::S0H1
261 }
262 #[doc = "Checks if the value of the field is `H0H1`"]
263 #[inline(always)]
264 pub fn is_h0h1(&self) -> bool {
265 *self == DRIVE_A::H0H1
266 }
267 #[doc = "Checks if the value of the field is `D0S1`"]
268 #[inline(always)]
269 pub fn is_d0s1(&self) -> bool {
270 *self == DRIVE_A::D0S1
271 }
272 #[doc = "Checks if the value of the field is `D0H1`"]
273 #[inline(always)]
274 pub fn is_d0h1(&self) -> bool {
275 *self == DRIVE_A::D0H1
276 }
277 #[doc = "Checks if the value of the field is `S0D1`"]
278 #[inline(always)]
279 pub fn is_s0d1(&self) -> bool {
280 *self == DRIVE_A::S0D1
281 }
282 #[doc = "Checks if the value of the field is `H0D1`"]
283 #[inline(always)]
284 pub fn is_h0d1(&self) -> bool {
285 *self == DRIVE_A::H0D1
286 }
287}
288#[doc = "Field `DRIVE` writer - Drive configuration"]
289pub type DRIVE_W<'a, const O: u8> =
290 crate::FieldWriterSafe<'a, u32, PIN_CNF_SPEC, u8, DRIVE_A, 3, O>;
291impl<'a, const O: u8> DRIVE_W<'a, O> {
292 #[doc = "Standard '0', standard '1'"]
293 #[inline(always)]
294 pub fn s0s1(self) -> &'a mut W {
295 self.variant(DRIVE_A::S0S1)
296 }
297 #[doc = "High drive '0', standard '1'"]
298 #[inline(always)]
299 pub fn h0s1(self) -> &'a mut W {
300 self.variant(DRIVE_A::H0S1)
301 }
302 #[doc = "Standard '0', high drive '1'"]
303 #[inline(always)]
304 pub fn s0h1(self) -> &'a mut W {
305 self.variant(DRIVE_A::S0H1)
306 }
307 #[doc = "High drive '0', high 'drive '1''"]
308 #[inline(always)]
309 pub fn h0h1(self) -> &'a mut W {
310 self.variant(DRIVE_A::H0H1)
311 }
312 #[doc = "Disconnect '0' standard '1' (normally used for wired-or connections)"]
313 #[inline(always)]
314 pub fn d0s1(self) -> &'a mut W {
315 self.variant(DRIVE_A::D0S1)
316 }
317 #[doc = "Disconnect '0', high drive '1' (normally used for wired-or connections)"]
318 #[inline(always)]
319 pub fn d0h1(self) -> &'a mut W {
320 self.variant(DRIVE_A::D0H1)
321 }
322 #[doc = "Standard '0'. disconnect '1' (normally used for wired-and connections)"]
323 #[inline(always)]
324 pub fn s0d1(self) -> &'a mut W {
325 self.variant(DRIVE_A::S0D1)
326 }
327 #[doc = "High drive '0', disconnect '1' (normally used for wired-and connections)"]
328 #[inline(always)]
329 pub fn h0d1(self) -> &'a mut W {
330 self.variant(DRIVE_A::H0D1)
331 }
332}
333#[doc = "Field `SENSE` reader - Pin sensing mechanism"]
334pub type SENSE_R = crate::FieldReader<u8, SENSE_A>;
335#[doc = "Pin sensing mechanism\n\nValue on reset: 0"]
336#[derive(Clone, Copy, Debug, PartialEq)]
337#[repr(u8)]
338pub enum SENSE_A {
339 #[doc = "0: Disabled"]
340 DISABLED = 0,
341 #[doc = "2: Sense for high level"]
342 HIGH = 2,
343 #[doc = "3: Sense for low level"]
344 LOW = 3,
345}
346impl From<SENSE_A> for u8 {
347 #[inline(always)]
348 fn from(variant: SENSE_A) -> Self {
349 variant as _
350 }
351}
352impl SENSE_R {
353 #[doc = "Get enumerated values variant"]
354 #[inline(always)]
355 pub fn variant(&self) -> Option<SENSE_A> {
356 match self.bits {
357 0 => Some(SENSE_A::DISABLED),
358 2 => Some(SENSE_A::HIGH),
359 3 => Some(SENSE_A::LOW),
360 _ => None,
361 }
362 }
363 #[doc = "Checks if the value of the field is `DISABLED`"]
364 #[inline(always)]
365 pub fn is_disabled(&self) -> bool {
366 *self == SENSE_A::DISABLED
367 }
368 #[doc = "Checks if the value of the field is `HIGH`"]
369 #[inline(always)]
370 pub fn is_high(&self) -> bool {
371 *self == SENSE_A::HIGH
372 }
373 #[doc = "Checks if the value of the field is `LOW`"]
374 #[inline(always)]
375 pub fn is_low(&self) -> bool {
376 *self == SENSE_A::LOW
377 }
378}
379#[doc = "Field `SENSE` writer - Pin sensing mechanism"]
380pub type SENSE_W<'a, const O: u8> = crate::FieldWriter<'a, u32, PIN_CNF_SPEC, u8, SENSE_A, 2, O>;
381impl<'a, const O: u8> SENSE_W<'a, O> {
382 #[doc = "Disabled"]
383 #[inline(always)]
384 pub fn disabled(self) -> &'a mut W {
385 self.variant(SENSE_A::DISABLED)
386 }
387 #[doc = "Sense for high level"]
388 #[inline(always)]
389 pub fn high(self) -> &'a mut W {
390 self.variant(SENSE_A::HIGH)
391 }
392 #[doc = "Sense for low level"]
393 #[inline(always)]
394 pub fn low(self) -> &'a mut W {
395 self.variant(SENSE_A::LOW)
396 }
397}
398impl R {
399 #[doc = "Bit 0 - Pin direction. Same physical register as DIR register"]
400 #[inline(always)]
401 pub fn dir(&self) -> DIR_R {
402 DIR_R::new((self.bits & 1) != 0)
403 }
404 #[doc = "Bit 1 - Connect or disconnect input buffer"]
405 #[inline(always)]
406 pub fn input(&self) -> INPUT_R {
407 INPUT_R::new(((self.bits >> 1) & 1) != 0)
408 }
409 #[doc = "Bits 2:3 - Pull configuration"]
410 #[inline(always)]
411 pub fn pull(&self) -> PULL_R {
412 PULL_R::new(((self.bits >> 2) & 3) as u8)
413 }
414 #[doc = "Bits 8:10 - Drive configuration"]
415 #[inline(always)]
416 pub fn drive(&self) -> DRIVE_R {
417 DRIVE_R::new(((self.bits >> 8) & 7) as u8)
418 }
419 #[doc = "Bits 16:17 - Pin sensing mechanism"]
420 #[inline(always)]
421 pub fn sense(&self) -> SENSE_R {
422 SENSE_R::new(((self.bits >> 16) & 3) as u8)
423 }
424}
425impl W {
426 #[doc = "Bit 0 - Pin direction. Same physical register as DIR register"]
427 #[inline(always)]
428 pub fn dir(&mut self) -> DIR_W<0> {
429 DIR_W::new(self)
430 }
431 #[doc = "Bit 1 - Connect or disconnect input buffer"]
432 #[inline(always)]
433 pub fn input(&mut self) -> INPUT_W<1> {
434 INPUT_W::new(self)
435 }
436 #[doc = "Bits 2:3 - Pull configuration"]
437 #[inline(always)]
438 pub fn pull(&mut self) -> PULL_W<2> {
439 PULL_W::new(self)
440 }
441 #[doc = "Bits 8:10 - Drive configuration"]
442 #[inline(always)]
443 pub fn drive(&mut self) -> DRIVE_W<8> {
444 DRIVE_W::new(self)
445 }
446 #[doc = "Bits 16:17 - Pin sensing mechanism"]
447 #[inline(always)]
448 pub fn sense(&mut self) -> SENSE_W<16> {
449 SENSE_W::new(self)
450 }
451 #[doc = "Writes raw bits to the register."]
452 #[inline(always)]
453 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
454 self.0.bits(bits);
455 self
456 }
457}
458#[doc = "Description collection\\[n\\]: Configuration of GPIO pins\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 [pin_cnf](index.html) module"]
459pub struct PIN_CNF_SPEC;
460impl crate::RegisterSpec for PIN_CNF_SPEC {
461 type Ux = u32;
462}
463#[doc = "`read()` method returns [pin_cnf::R](R) reader structure"]
464impl crate::Readable for PIN_CNF_SPEC {
465 type Reader = R;
466}
467#[doc = "`write(|w| ..)` method takes [pin_cnf::W](W) writer structure"]
468impl crate::Writable for PIN_CNF_SPEC {
469 type Writer = W;
470}
471#[doc = "`reset()` method sets PIN_CNF[%s]
472to value 0x02"]
473impl crate::Resettable for PIN_CNF_SPEC {
474 #[inline(always)]
475 fn reset_value() -> Self::Ux {
476 0x02
477 }
478}