mk66f18/usbphy/
usb1_vbus_detect_set.rs

1#[doc = "Reader of register USB1_VBUS_DETECT_SET"]
2pub type R = crate::R<u32, super::USB1_VBUS_DETECT_SET>;
3#[doc = "Writer for register USB1_VBUS_DETECT_SET"]
4pub type W = crate::W<u32, super::USB1_VBUS_DETECT_SET>;
5#[doc = "Register USB1_VBUS_DETECT_SET `reset()`'s with value 0x0070_0004"]
6impl crate::ResetValue for super::USB1_VBUS_DETECT_SET {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0x0070_0004
11    }
12}
13#[doc = "Sets the threshold for the VBUSVALID comparator\n\nValue on reset: 4"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum VBUSVALID_THRESH_A {
16    #[doc = "0: 4.0 V"]
17    _000,
18    #[doc = "1: 4.1 V"]
19    _001,
20    #[doc = "2: 4.2 V"]
21    _010,
22    #[doc = "3: 4.3 V"]
23    _011,
24    #[doc = "4: 4.4 V (Default)"]
25    _100,
26    #[doc = "5: 4.5 V"]
27    _101,
28    #[doc = "6: 4.6 V"]
29    _110,
30    #[doc = "7: 4.7 V"]
31    _111,
32}
33impl From<VBUSVALID_THRESH_A> for u8 {
34    #[inline(always)]
35    fn from(variant: VBUSVALID_THRESH_A) -> Self {
36        match variant {
37            VBUSVALID_THRESH_A::_000 => 0,
38            VBUSVALID_THRESH_A::_001 => 1,
39            VBUSVALID_THRESH_A::_010 => 2,
40            VBUSVALID_THRESH_A::_011 => 3,
41            VBUSVALID_THRESH_A::_100 => 4,
42            VBUSVALID_THRESH_A::_101 => 5,
43            VBUSVALID_THRESH_A::_110 => 6,
44            VBUSVALID_THRESH_A::_111 => 7,
45        }
46    }
47}
48#[doc = "Reader of field `VBUSVALID_THRESH`"]
49pub type VBUSVALID_THRESH_R = crate::R<u8, VBUSVALID_THRESH_A>;
50impl VBUSVALID_THRESH_R {
51    #[doc = r"Get enumerated values variant"]
52    #[inline(always)]
53    pub fn variant(&self) -> VBUSVALID_THRESH_A {
54        match self.bits {
55            0 => VBUSVALID_THRESH_A::_000,
56            1 => VBUSVALID_THRESH_A::_001,
57            2 => VBUSVALID_THRESH_A::_010,
58            3 => VBUSVALID_THRESH_A::_011,
59            4 => VBUSVALID_THRESH_A::_100,
60            5 => VBUSVALID_THRESH_A::_101,
61            6 => VBUSVALID_THRESH_A::_110,
62            7 => VBUSVALID_THRESH_A::_111,
63            _ => unreachable!(),
64        }
65    }
66    #[doc = "Checks if the value of the field is `_000`"]
67    #[inline(always)]
68    pub fn is_000(&self) -> bool {
69        *self == VBUSVALID_THRESH_A::_000
70    }
71    #[doc = "Checks if the value of the field is `_001`"]
72    #[inline(always)]
73    pub fn is_001(&self) -> bool {
74        *self == VBUSVALID_THRESH_A::_001
75    }
76    #[doc = "Checks if the value of the field is `_010`"]
77    #[inline(always)]
78    pub fn is_010(&self) -> bool {
79        *self == VBUSVALID_THRESH_A::_010
80    }
81    #[doc = "Checks if the value of the field is `_011`"]
82    #[inline(always)]
83    pub fn is_011(&self) -> bool {
84        *self == VBUSVALID_THRESH_A::_011
85    }
86    #[doc = "Checks if the value of the field is `_100`"]
87    #[inline(always)]
88    pub fn is_100(&self) -> bool {
89        *self == VBUSVALID_THRESH_A::_100
90    }
91    #[doc = "Checks if the value of the field is `_101`"]
92    #[inline(always)]
93    pub fn is_101(&self) -> bool {
94        *self == VBUSVALID_THRESH_A::_101
95    }
96    #[doc = "Checks if the value of the field is `_110`"]
97    #[inline(always)]
98    pub fn is_110(&self) -> bool {
99        *self == VBUSVALID_THRESH_A::_110
100    }
101    #[doc = "Checks if the value of the field is `_111`"]
102    #[inline(always)]
103    pub fn is_111(&self) -> bool {
104        *self == VBUSVALID_THRESH_A::_111
105    }
106}
107#[doc = "Write proxy for field `VBUSVALID_THRESH`"]
108pub struct VBUSVALID_THRESH_W<'a> {
109    w: &'a mut W,
110}
111impl<'a> VBUSVALID_THRESH_W<'a> {
112    #[doc = r"Writes `variant` to the field"]
113    #[inline(always)]
114    pub fn variant(self, variant: VBUSVALID_THRESH_A) -> &'a mut W {
115        {
116            self.bits(variant.into())
117        }
118    }
119    #[doc = "4.0 V"]
120    #[inline(always)]
121    pub fn _000(self) -> &'a mut W {
122        self.variant(VBUSVALID_THRESH_A::_000)
123    }
124    #[doc = "4.1 V"]
125    #[inline(always)]
126    pub fn _001(self) -> &'a mut W {
127        self.variant(VBUSVALID_THRESH_A::_001)
128    }
129    #[doc = "4.2 V"]
130    #[inline(always)]
131    pub fn _010(self) -> &'a mut W {
132        self.variant(VBUSVALID_THRESH_A::_010)
133    }
134    #[doc = "4.3 V"]
135    #[inline(always)]
136    pub fn _011(self) -> &'a mut W {
137        self.variant(VBUSVALID_THRESH_A::_011)
138    }
139    #[doc = "4.4 V (Default)"]
140    #[inline(always)]
141    pub fn _100(self) -> &'a mut W {
142        self.variant(VBUSVALID_THRESH_A::_100)
143    }
144    #[doc = "4.5 V"]
145    #[inline(always)]
146    pub fn _101(self) -> &'a mut W {
147        self.variant(VBUSVALID_THRESH_A::_101)
148    }
149    #[doc = "4.6 V"]
150    #[inline(always)]
151    pub fn _110(self) -> &'a mut W {
152        self.variant(VBUSVALID_THRESH_A::_110)
153    }
154    #[doc = "4.7 V"]
155    #[inline(always)]
156    pub fn _111(self) -> &'a mut W {
157        self.variant(VBUSVALID_THRESH_A::_111)
158    }
159    #[doc = r"Writes raw bits to the field"]
160    #[inline(always)]
161    pub fn bits(self, value: u8) -> &'a mut W {
162        self.w.bits = (self.w.bits & !0x07) | ((value as u32) & 0x07);
163        self.w
164    }
165}
166#[doc = "VBUS detect signal override enable\n\nValue on reset: 0"]
167#[derive(Clone, Copy, Debug, PartialEq)]
168pub enum VBUS_OVERRIDE_EN_A {
169    #[doc = "0: Use the results of the internal VBUS_VALID and Session Valid comparators for VBUS_VALID, AVALID, BVALID, and SESSEND (Default)"]
170    _0,
171    #[doc = "1: Use the override values for VBUS_VALID, AVALID, BVALID, and SESSEND"]
172    _1,
173}
174impl From<VBUS_OVERRIDE_EN_A> for bool {
175    #[inline(always)]
176    fn from(variant: VBUS_OVERRIDE_EN_A) -> Self {
177        match variant {
178            VBUS_OVERRIDE_EN_A::_0 => false,
179            VBUS_OVERRIDE_EN_A::_1 => true,
180        }
181    }
182}
183#[doc = "Reader of field `VBUS_OVERRIDE_EN`"]
184pub type VBUS_OVERRIDE_EN_R = crate::R<bool, VBUS_OVERRIDE_EN_A>;
185impl VBUS_OVERRIDE_EN_R {
186    #[doc = r"Get enumerated values variant"]
187    #[inline(always)]
188    pub fn variant(&self) -> VBUS_OVERRIDE_EN_A {
189        match self.bits {
190            false => VBUS_OVERRIDE_EN_A::_0,
191            true => VBUS_OVERRIDE_EN_A::_1,
192        }
193    }
194    #[doc = "Checks if the value of the field is `_0`"]
195    #[inline(always)]
196    pub fn is_0(&self) -> bool {
197        *self == VBUS_OVERRIDE_EN_A::_0
198    }
199    #[doc = "Checks if the value of the field is `_1`"]
200    #[inline(always)]
201    pub fn is_1(&self) -> bool {
202        *self == VBUS_OVERRIDE_EN_A::_1
203    }
204}
205#[doc = "Write proxy for field `VBUS_OVERRIDE_EN`"]
206pub struct VBUS_OVERRIDE_EN_W<'a> {
207    w: &'a mut W,
208}
209impl<'a> VBUS_OVERRIDE_EN_W<'a> {
210    #[doc = r"Writes `variant` to the field"]
211    #[inline(always)]
212    pub fn variant(self, variant: VBUS_OVERRIDE_EN_A) -> &'a mut W {
213        {
214            self.bit(variant.into())
215        }
216    }
217    #[doc = "Use the results of the internal VBUS_VALID and Session Valid comparators for VBUS_VALID, AVALID, BVALID, and SESSEND (Default)"]
218    #[inline(always)]
219    pub fn _0(self) -> &'a mut W {
220        self.variant(VBUS_OVERRIDE_EN_A::_0)
221    }
222    #[doc = "Use the override values for VBUS_VALID, AVALID, BVALID, and SESSEND"]
223    #[inline(always)]
224    pub fn _1(self) -> &'a mut W {
225        self.variant(VBUS_OVERRIDE_EN_A::_1)
226    }
227    #[doc = r"Sets the field bit"]
228    #[inline(always)]
229    pub fn set_bit(self) -> &'a mut W {
230        self.bit(true)
231    }
232    #[doc = r"Clears the field bit"]
233    #[inline(always)]
234    pub fn clear_bit(self) -> &'a mut W {
235        self.bit(false)
236    }
237    #[doc = r"Writes raw bits to the field"]
238    #[inline(always)]
239    pub fn bit(self, value: bool) -> &'a mut W {
240        self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3);
241        self.w
242    }
243}
244#[doc = "Reader of field `SESSEND_OVERRIDE`"]
245pub type SESSEND_OVERRIDE_R = crate::R<bool, bool>;
246#[doc = "Write proxy for field `SESSEND_OVERRIDE`"]
247pub struct SESSEND_OVERRIDE_W<'a> {
248    w: &'a mut W,
249}
250impl<'a> SESSEND_OVERRIDE_W<'a> {
251    #[doc = r"Sets the field bit"]
252    #[inline(always)]
253    pub fn set_bit(self) -> &'a mut W {
254        self.bit(true)
255    }
256    #[doc = r"Clears the field bit"]
257    #[inline(always)]
258    pub fn clear_bit(self) -> &'a mut W {
259        self.bit(false)
260    }
261    #[doc = r"Writes raw bits to the field"]
262    #[inline(always)]
263    pub fn bit(self, value: bool) -> &'a mut W {
264        self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4);
265        self.w
266    }
267}
268#[doc = "Reader of field `BVALID_OVERRIDE`"]
269pub type BVALID_OVERRIDE_R = crate::R<bool, bool>;
270#[doc = "Write proxy for field `BVALID_OVERRIDE`"]
271pub struct BVALID_OVERRIDE_W<'a> {
272    w: &'a mut W,
273}
274impl<'a> BVALID_OVERRIDE_W<'a> {
275    #[doc = r"Sets the field bit"]
276    #[inline(always)]
277    pub fn set_bit(self) -> &'a mut W {
278        self.bit(true)
279    }
280    #[doc = r"Clears the field bit"]
281    #[inline(always)]
282    pub fn clear_bit(self) -> &'a mut W {
283        self.bit(false)
284    }
285    #[doc = r"Writes raw bits to the field"]
286    #[inline(always)]
287    pub fn bit(self, value: bool) -> &'a mut W {
288        self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5);
289        self.w
290    }
291}
292#[doc = "Reader of field `AVALID_OVERRIDE`"]
293pub type AVALID_OVERRIDE_R = crate::R<bool, bool>;
294#[doc = "Write proxy for field `AVALID_OVERRIDE`"]
295pub struct AVALID_OVERRIDE_W<'a> {
296    w: &'a mut W,
297}
298impl<'a> AVALID_OVERRIDE_W<'a> {
299    #[doc = r"Sets the field bit"]
300    #[inline(always)]
301    pub fn set_bit(self) -> &'a mut W {
302        self.bit(true)
303    }
304    #[doc = r"Clears the field bit"]
305    #[inline(always)]
306    pub fn clear_bit(self) -> &'a mut W {
307        self.bit(false)
308    }
309    #[doc = r"Writes raw bits to the field"]
310    #[inline(always)]
311    pub fn bit(self, value: bool) -> &'a mut W {
312        self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6);
313        self.w
314    }
315}
316#[doc = "Reader of field `VBUSVALID_OVERRIDE`"]
317pub type VBUSVALID_OVERRIDE_R = crate::R<bool, bool>;
318#[doc = "Write proxy for field `VBUSVALID_OVERRIDE`"]
319pub struct VBUSVALID_OVERRIDE_W<'a> {
320    w: &'a mut W,
321}
322impl<'a> VBUSVALID_OVERRIDE_W<'a> {
323    #[doc = r"Sets the field bit"]
324    #[inline(always)]
325    pub fn set_bit(self) -> &'a mut W {
326        self.bit(true)
327    }
328    #[doc = r"Clears the field bit"]
329    #[inline(always)]
330    pub fn clear_bit(self) -> &'a mut W {
331        self.bit(false)
332    }
333    #[doc = r"Writes raw bits to the field"]
334    #[inline(always)]
335    pub fn bit(self, value: bool) -> &'a mut W {
336        self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7);
337        self.w
338    }
339}
340#[doc = "Selects the source of the VBUS_VALID signal reported to the USB controller\n\nValue on reset: 0"]
341#[derive(Clone, Copy, Debug, PartialEq)]
342pub enum VBUSVALID_SEL_A {
343    #[doc = "0: Use the VBUS_VALID comparator results for signal reported to the USB controller (Default)"]
344    _0,
345    #[doc = "1: Use the VBUS_VALID_3V detector results for signal reported to the USB controller"]
346    _1,
347}
348impl From<VBUSVALID_SEL_A> for bool {
349    #[inline(always)]
350    fn from(variant: VBUSVALID_SEL_A) -> Self {
351        match variant {
352            VBUSVALID_SEL_A::_0 => false,
353            VBUSVALID_SEL_A::_1 => true,
354        }
355    }
356}
357#[doc = "Reader of field `VBUSVALID_SEL`"]
358pub type VBUSVALID_SEL_R = crate::R<bool, VBUSVALID_SEL_A>;
359impl VBUSVALID_SEL_R {
360    #[doc = r"Get enumerated values variant"]
361    #[inline(always)]
362    pub fn variant(&self) -> VBUSVALID_SEL_A {
363        match self.bits {
364            false => VBUSVALID_SEL_A::_0,
365            true => VBUSVALID_SEL_A::_1,
366        }
367    }
368    #[doc = "Checks if the value of the field is `_0`"]
369    #[inline(always)]
370    pub fn is_0(&self) -> bool {
371        *self == VBUSVALID_SEL_A::_0
372    }
373    #[doc = "Checks if the value of the field is `_1`"]
374    #[inline(always)]
375    pub fn is_1(&self) -> bool {
376        *self == VBUSVALID_SEL_A::_1
377    }
378}
379#[doc = "Write proxy for field `VBUSVALID_SEL`"]
380pub struct VBUSVALID_SEL_W<'a> {
381    w: &'a mut W,
382}
383impl<'a> VBUSVALID_SEL_W<'a> {
384    #[doc = r"Writes `variant` to the field"]
385    #[inline(always)]
386    pub fn variant(self, variant: VBUSVALID_SEL_A) -> &'a mut W {
387        {
388            self.bit(variant.into())
389        }
390    }
391    #[doc = "Use the VBUS_VALID comparator results for signal reported to the USB controller (Default)"]
392    #[inline(always)]
393    pub fn _0(self) -> &'a mut W {
394        self.variant(VBUSVALID_SEL_A::_0)
395    }
396    #[doc = "Use the VBUS_VALID_3V detector results for signal reported to the USB controller"]
397    #[inline(always)]
398    pub fn _1(self) -> &'a mut W {
399        self.variant(VBUSVALID_SEL_A::_1)
400    }
401    #[doc = r"Sets the field bit"]
402    #[inline(always)]
403    pub fn set_bit(self) -> &'a mut W {
404        self.bit(true)
405    }
406    #[doc = r"Clears the field bit"]
407    #[inline(always)]
408    pub fn clear_bit(self) -> &'a mut W {
409        self.bit(false)
410    }
411    #[doc = r"Writes raw bits to the field"]
412    #[inline(always)]
413    pub fn bit(self, value: bool) -> &'a mut W {
414        self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8);
415        self.w
416    }
417}
418#[doc = "Selects the source of the VBUS_VALID signal reported to the USB controller\n\nValue on reset: 0"]
419#[derive(Clone, Copy, Debug, PartialEq)]
420pub enum VBUS_SOURCE_SEL_A {
421    #[doc = "0: Use the VBUS_VALID comparator results for signal reported to the USB controller (Default)"]
422    _00,
423    #[doc = "1: Use the Session Valid comparator results for signal reported to the USB controller"]
424    _01,
425    #[doc = "2: Use the Session Valid comparator results for signal reported to the USB controller"]
426    _10,
427    #[doc = "3: Reserved, do not use"]
428    _11,
429}
430impl From<VBUS_SOURCE_SEL_A> for u8 {
431    #[inline(always)]
432    fn from(variant: VBUS_SOURCE_SEL_A) -> Self {
433        match variant {
434            VBUS_SOURCE_SEL_A::_00 => 0,
435            VBUS_SOURCE_SEL_A::_01 => 1,
436            VBUS_SOURCE_SEL_A::_10 => 2,
437            VBUS_SOURCE_SEL_A::_11 => 3,
438        }
439    }
440}
441#[doc = "Reader of field `VBUS_SOURCE_SEL`"]
442pub type VBUS_SOURCE_SEL_R = crate::R<u8, VBUS_SOURCE_SEL_A>;
443impl VBUS_SOURCE_SEL_R {
444    #[doc = r"Get enumerated values variant"]
445    #[inline(always)]
446    pub fn variant(&self) -> VBUS_SOURCE_SEL_A {
447        match self.bits {
448            0 => VBUS_SOURCE_SEL_A::_00,
449            1 => VBUS_SOURCE_SEL_A::_01,
450            2 => VBUS_SOURCE_SEL_A::_10,
451            3 => VBUS_SOURCE_SEL_A::_11,
452            _ => unreachable!(),
453        }
454    }
455    #[doc = "Checks if the value of the field is `_00`"]
456    #[inline(always)]
457    pub fn is_00(&self) -> bool {
458        *self == VBUS_SOURCE_SEL_A::_00
459    }
460    #[doc = "Checks if the value of the field is `_01`"]
461    #[inline(always)]
462    pub fn is_01(&self) -> bool {
463        *self == VBUS_SOURCE_SEL_A::_01
464    }
465    #[doc = "Checks if the value of the field is `_10`"]
466    #[inline(always)]
467    pub fn is_10(&self) -> bool {
468        *self == VBUS_SOURCE_SEL_A::_10
469    }
470    #[doc = "Checks if the value of the field is `_11`"]
471    #[inline(always)]
472    pub fn is_11(&self) -> bool {
473        *self == VBUS_SOURCE_SEL_A::_11
474    }
475}
476#[doc = "Write proxy for field `VBUS_SOURCE_SEL`"]
477pub struct VBUS_SOURCE_SEL_W<'a> {
478    w: &'a mut W,
479}
480impl<'a> VBUS_SOURCE_SEL_W<'a> {
481    #[doc = r"Writes `variant` to the field"]
482    #[inline(always)]
483    pub fn variant(self, variant: VBUS_SOURCE_SEL_A) -> &'a mut W {
484        {
485            self.bits(variant.into())
486        }
487    }
488    #[doc = "Use the VBUS_VALID comparator results for signal reported to the USB controller (Default)"]
489    #[inline(always)]
490    pub fn _00(self) -> &'a mut W {
491        self.variant(VBUS_SOURCE_SEL_A::_00)
492    }
493    #[doc = "Use the Session Valid comparator results for signal reported to the USB controller"]
494    #[inline(always)]
495    pub fn _01(self) -> &'a mut W {
496        self.variant(VBUS_SOURCE_SEL_A::_01)
497    }
498    #[doc = "Use the Session Valid comparator results for signal reported to the USB controller"]
499    #[inline(always)]
500    pub fn _10(self) -> &'a mut W {
501        self.variant(VBUS_SOURCE_SEL_A::_10)
502    }
503    #[doc = "Reserved, do not use"]
504    #[inline(always)]
505    pub fn _11(self) -> &'a mut W {
506        self.variant(VBUS_SOURCE_SEL_A::_11)
507    }
508    #[doc = r"Writes raw bits to the field"]
509    #[inline(always)]
510    pub fn bits(self, value: u8) -> &'a mut W {
511        self.w.bits = (self.w.bits & !(0x03 << 9)) | (((value as u32) & 0x03) << 9);
512        self.w
513    }
514}
515#[doc = "Selects the comparator used for VBUS_VALID\n\nValue on reset: 0"]
516#[derive(Clone, Copy, Debug, PartialEq)]
517pub enum VBUSVALID_TO_SESSVALID_A {
518    #[doc = "0: Use the VBUS_VALID comparator for VBUS_VALID results"]
519    _0,
520    #[doc = "1: Use the Session End comparator for VBUS_VALID results. The Session End threshold is >0.8V and <4.0V."]
521    _1,
522}
523impl From<VBUSVALID_TO_SESSVALID_A> for bool {
524    #[inline(always)]
525    fn from(variant: VBUSVALID_TO_SESSVALID_A) -> Self {
526        match variant {
527            VBUSVALID_TO_SESSVALID_A::_0 => false,
528            VBUSVALID_TO_SESSVALID_A::_1 => true,
529        }
530    }
531}
532#[doc = "Reader of field `VBUSVALID_TO_SESSVALID`"]
533pub type VBUSVALID_TO_SESSVALID_R = crate::R<bool, VBUSVALID_TO_SESSVALID_A>;
534impl VBUSVALID_TO_SESSVALID_R {
535    #[doc = r"Get enumerated values variant"]
536    #[inline(always)]
537    pub fn variant(&self) -> VBUSVALID_TO_SESSVALID_A {
538        match self.bits {
539            false => VBUSVALID_TO_SESSVALID_A::_0,
540            true => VBUSVALID_TO_SESSVALID_A::_1,
541        }
542    }
543    #[doc = "Checks if the value of the field is `_0`"]
544    #[inline(always)]
545    pub fn is_0(&self) -> bool {
546        *self == VBUSVALID_TO_SESSVALID_A::_0
547    }
548    #[doc = "Checks if the value of the field is `_1`"]
549    #[inline(always)]
550    pub fn is_1(&self) -> bool {
551        *self == VBUSVALID_TO_SESSVALID_A::_1
552    }
553}
554#[doc = "Write proxy for field `VBUSVALID_TO_SESSVALID`"]
555pub struct VBUSVALID_TO_SESSVALID_W<'a> {
556    w: &'a mut W,
557}
558impl<'a> VBUSVALID_TO_SESSVALID_W<'a> {
559    #[doc = r"Writes `variant` to the field"]
560    #[inline(always)]
561    pub fn variant(self, variant: VBUSVALID_TO_SESSVALID_A) -> &'a mut W {
562        {
563            self.bit(variant.into())
564        }
565    }
566    #[doc = "Use the VBUS_VALID comparator for VBUS_VALID results"]
567    #[inline(always)]
568    pub fn _0(self) -> &'a mut W {
569        self.variant(VBUSVALID_TO_SESSVALID_A::_0)
570    }
571    #[doc = "Use the Session End comparator for VBUS_VALID results. The Session End threshold is >0.8V and <4.0V."]
572    #[inline(always)]
573    pub fn _1(self) -> &'a mut W {
574        self.variant(VBUSVALID_TO_SESSVALID_A::_1)
575    }
576    #[doc = r"Sets the field bit"]
577    #[inline(always)]
578    pub fn set_bit(self) -> &'a mut W {
579        self.bit(true)
580    }
581    #[doc = r"Clears the field bit"]
582    #[inline(always)]
583    pub fn clear_bit(self) -> &'a mut W {
584        self.bit(false)
585    }
586    #[doc = r"Writes raw bits to the field"]
587    #[inline(always)]
588    pub fn bit(self, value: bool) -> &'a mut W {
589        self.w.bits = (self.w.bits & !(0x01 << 18)) | (((value as u32) & 0x01) << 18);
590        self.w
591    }
592}
593#[doc = "Enables the VBUS_VALID comparator\n\nValue on reset: 1"]
594#[derive(Clone, Copy, Debug, PartialEq)]
595pub enum PWRUP_CMPS_A {
596    #[doc = "0: Powers down the VBUS_VALID comparator"]
597    _0,
598    #[doc = "1: Enables the VBUS_VALID comparator (default)"]
599    _1,
600}
601impl From<PWRUP_CMPS_A> for bool {
602    #[inline(always)]
603    fn from(variant: PWRUP_CMPS_A) -> Self {
604        match variant {
605            PWRUP_CMPS_A::_0 => false,
606            PWRUP_CMPS_A::_1 => true,
607        }
608    }
609}
610#[doc = "Reader of field `PWRUP_CMPS`"]
611pub type PWRUP_CMPS_R = crate::R<bool, PWRUP_CMPS_A>;
612impl PWRUP_CMPS_R {
613    #[doc = r"Get enumerated values variant"]
614    #[inline(always)]
615    pub fn variant(&self) -> PWRUP_CMPS_A {
616        match self.bits {
617            false => PWRUP_CMPS_A::_0,
618            true => PWRUP_CMPS_A::_1,
619        }
620    }
621    #[doc = "Checks if the value of the field is `_0`"]
622    #[inline(always)]
623    pub fn is_0(&self) -> bool {
624        *self == PWRUP_CMPS_A::_0
625    }
626    #[doc = "Checks if the value of the field is `_1`"]
627    #[inline(always)]
628    pub fn is_1(&self) -> bool {
629        *self == PWRUP_CMPS_A::_1
630    }
631}
632#[doc = "Write proxy for field `PWRUP_CMPS`"]
633pub struct PWRUP_CMPS_W<'a> {
634    w: &'a mut W,
635}
636impl<'a> PWRUP_CMPS_W<'a> {
637    #[doc = r"Writes `variant` to the field"]
638    #[inline(always)]
639    pub fn variant(self, variant: PWRUP_CMPS_A) -> &'a mut W {
640        {
641            self.bit(variant.into())
642        }
643    }
644    #[doc = "Powers down the VBUS_VALID comparator"]
645    #[inline(always)]
646    pub fn _0(self) -> &'a mut W {
647        self.variant(PWRUP_CMPS_A::_0)
648    }
649    #[doc = "Enables the VBUS_VALID comparator (default)"]
650    #[inline(always)]
651    pub fn _1(self) -> &'a mut W {
652        self.variant(PWRUP_CMPS_A::_1)
653    }
654    #[doc = r"Sets the field bit"]
655    #[inline(always)]
656    pub fn set_bit(self) -> &'a mut W {
657        self.bit(true)
658    }
659    #[doc = r"Clears the field bit"]
660    #[inline(always)]
661    pub fn clear_bit(self) -> &'a mut W {
662        self.bit(false)
663    }
664    #[doc = r"Writes raw bits to the field"]
665    #[inline(always)]
666    pub fn bit(self, value: bool) -> &'a mut W {
667        self.w.bits = (self.w.bits & !(0x01 << 20)) | (((value as u32) & 0x01) << 20);
668        self.w
669    }
670}
671#[doc = "Controls VBUS discharge resistor\n\nValue on reset: 0"]
672#[derive(Clone, Copy, Debug, PartialEq)]
673pub enum DISCHARGE_VBUS_A {
674    #[doc = "0: VBUS discharge resistor is disabled (Default)"]
675    _0,
676    #[doc = "1: VBUS discharge resistor is enabled"]
677    _1,
678}
679impl From<DISCHARGE_VBUS_A> for bool {
680    #[inline(always)]
681    fn from(variant: DISCHARGE_VBUS_A) -> Self {
682        match variant {
683            DISCHARGE_VBUS_A::_0 => false,
684            DISCHARGE_VBUS_A::_1 => true,
685        }
686    }
687}
688#[doc = "Reader of field `DISCHARGE_VBUS`"]
689pub type DISCHARGE_VBUS_R = crate::R<bool, DISCHARGE_VBUS_A>;
690impl DISCHARGE_VBUS_R {
691    #[doc = r"Get enumerated values variant"]
692    #[inline(always)]
693    pub fn variant(&self) -> DISCHARGE_VBUS_A {
694        match self.bits {
695            false => DISCHARGE_VBUS_A::_0,
696            true => DISCHARGE_VBUS_A::_1,
697        }
698    }
699    #[doc = "Checks if the value of the field is `_0`"]
700    #[inline(always)]
701    pub fn is_0(&self) -> bool {
702        *self == DISCHARGE_VBUS_A::_0
703    }
704    #[doc = "Checks if the value of the field is `_1`"]
705    #[inline(always)]
706    pub fn is_1(&self) -> bool {
707        *self == DISCHARGE_VBUS_A::_1
708    }
709}
710#[doc = "Write proxy for field `DISCHARGE_VBUS`"]
711pub struct DISCHARGE_VBUS_W<'a> {
712    w: &'a mut W,
713}
714impl<'a> DISCHARGE_VBUS_W<'a> {
715    #[doc = r"Writes `variant` to the field"]
716    #[inline(always)]
717    pub fn variant(self, variant: DISCHARGE_VBUS_A) -> &'a mut W {
718        {
719            self.bit(variant.into())
720        }
721    }
722    #[doc = "VBUS discharge resistor is disabled (Default)"]
723    #[inline(always)]
724    pub fn _0(self) -> &'a mut W {
725        self.variant(DISCHARGE_VBUS_A::_0)
726    }
727    #[doc = "VBUS discharge resistor is enabled"]
728    #[inline(always)]
729    pub fn _1(self) -> &'a mut W {
730        self.variant(DISCHARGE_VBUS_A::_1)
731    }
732    #[doc = r"Sets the field bit"]
733    #[inline(always)]
734    pub fn set_bit(self) -> &'a mut W {
735        self.bit(true)
736    }
737    #[doc = r"Clears the field bit"]
738    #[inline(always)]
739    pub fn clear_bit(self) -> &'a mut W {
740        self.bit(false)
741    }
742    #[doc = r"Writes raw bits to the field"]
743    #[inline(always)]
744    pub fn bit(self, value: bool) -> &'a mut W {
745        self.w.bits = (self.w.bits & !(0x01 << 26)) | (((value as u32) & 0x01) << 26);
746        self.w
747    }
748}
749#[doc = "Enables resistors used for an older method of resistive battery charger detection\n\nValue on reset: 0"]
750#[derive(Clone, Copy, Debug, PartialEq)]
751pub enum EN_CHARGER_RESISTOR_A {
752    #[doc = "0: Disable resistive charger detection resistors on USB_DP and USB_DP"]
753    _0,
754    #[doc = "1: Enable resistive charger detection resistors on USB_DP and USB_DP"]
755    _1,
756}
757impl From<EN_CHARGER_RESISTOR_A> for bool {
758    #[inline(always)]
759    fn from(variant: EN_CHARGER_RESISTOR_A) -> Self {
760        match variant {
761            EN_CHARGER_RESISTOR_A::_0 => false,
762            EN_CHARGER_RESISTOR_A::_1 => true,
763        }
764    }
765}
766#[doc = "Reader of field `EN_CHARGER_RESISTOR`"]
767pub type EN_CHARGER_RESISTOR_R = crate::R<bool, EN_CHARGER_RESISTOR_A>;
768impl EN_CHARGER_RESISTOR_R {
769    #[doc = r"Get enumerated values variant"]
770    #[inline(always)]
771    pub fn variant(&self) -> EN_CHARGER_RESISTOR_A {
772        match self.bits {
773            false => EN_CHARGER_RESISTOR_A::_0,
774            true => EN_CHARGER_RESISTOR_A::_1,
775        }
776    }
777    #[doc = "Checks if the value of the field is `_0`"]
778    #[inline(always)]
779    pub fn is_0(&self) -> bool {
780        *self == EN_CHARGER_RESISTOR_A::_0
781    }
782    #[doc = "Checks if the value of the field is `_1`"]
783    #[inline(always)]
784    pub fn is_1(&self) -> bool {
785        *self == EN_CHARGER_RESISTOR_A::_1
786    }
787}
788#[doc = "Write proxy for field `EN_CHARGER_RESISTOR`"]
789pub struct EN_CHARGER_RESISTOR_W<'a> {
790    w: &'a mut W,
791}
792impl<'a> EN_CHARGER_RESISTOR_W<'a> {
793    #[doc = r"Writes `variant` to the field"]
794    #[inline(always)]
795    pub fn variant(self, variant: EN_CHARGER_RESISTOR_A) -> &'a mut W {
796        {
797            self.bit(variant.into())
798        }
799    }
800    #[doc = "Disable resistive charger detection resistors on USB_DP and USB_DP"]
801    #[inline(always)]
802    pub fn _0(self) -> &'a mut W {
803        self.variant(EN_CHARGER_RESISTOR_A::_0)
804    }
805    #[doc = "Enable resistive charger detection resistors on USB_DP and USB_DP"]
806    #[inline(always)]
807    pub fn _1(self) -> &'a mut W {
808        self.variant(EN_CHARGER_RESISTOR_A::_1)
809    }
810    #[doc = r"Sets the field bit"]
811    #[inline(always)]
812    pub fn set_bit(self) -> &'a mut W {
813        self.bit(true)
814    }
815    #[doc = r"Clears the field bit"]
816    #[inline(always)]
817    pub fn clear_bit(self) -> &'a mut W {
818        self.bit(false)
819    }
820    #[doc = r"Writes raw bits to the field"]
821    #[inline(always)]
822    pub fn bit(self, value: bool) -> &'a mut W {
823        self.w.bits = (self.w.bits & !(0x01 << 31)) | (((value as u32) & 0x01) << 31);
824        self.w
825    }
826}
827impl R {
828    #[doc = "Bits 0:2 - Sets the threshold for the VBUSVALID comparator"]
829    #[inline(always)]
830    pub fn vbusvalid_thresh(&self) -> VBUSVALID_THRESH_R {
831        VBUSVALID_THRESH_R::new((self.bits & 0x07) as u8)
832    }
833    #[doc = "Bit 3 - VBUS detect signal override enable"]
834    #[inline(always)]
835    pub fn vbus_override_en(&self) -> VBUS_OVERRIDE_EN_R {
836        VBUS_OVERRIDE_EN_R::new(((self.bits >> 3) & 0x01) != 0)
837    }
838    #[doc = "Bit 4 - Override value for SESSEND"]
839    #[inline(always)]
840    pub fn sessend_override(&self) -> SESSEND_OVERRIDE_R {
841        SESSEND_OVERRIDE_R::new(((self.bits >> 4) & 0x01) != 0)
842    }
843    #[doc = "Bit 5 - Override value for B-Device Session Valid"]
844    #[inline(always)]
845    pub fn bvalid_override(&self) -> BVALID_OVERRIDE_R {
846        BVALID_OVERRIDE_R::new(((self.bits >> 5) & 0x01) != 0)
847    }
848    #[doc = "Bit 6 - Override value for A-Device Session Valid"]
849    #[inline(always)]
850    pub fn avalid_override(&self) -> AVALID_OVERRIDE_R {
851        AVALID_OVERRIDE_R::new(((self.bits >> 6) & 0x01) != 0)
852    }
853    #[doc = "Bit 7 - Override value for VBUS_VALID signal sent to USB controller"]
854    #[inline(always)]
855    pub fn vbusvalid_override(&self) -> VBUSVALID_OVERRIDE_R {
856        VBUSVALID_OVERRIDE_R::new(((self.bits >> 7) & 0x01) != 0)
857    }
858    #[doc = "Bit 8 - Selects the source of the VBUS_VALID signal reported to the USB controller"]
859    #[inline(always)]
860    pub fn vbusvalid_sel(&self) -> VBUSVALID_SEL_R {
861        VBUSVALID_SEL_R::new(((self.bits >> 8) & 0x01) != 0)
862    }
863    #[doc = "Bits 9:10 - Selects the source of the VBUS_VALID signal reported to the USB controller"]
864    #[inline(always)]
865    pub fn vbus_source_sel(&self) -> VBUS_SOURCE_SEL_R {
866        VBUS_SOURCE_SEL_R::new(((self.bits >> 9) & 0x03) as u8)
867    }
868    #[doc = "Bit 18 - Selects the comparator used for VBUS_VALID"]
869    #[inline(always)]
870    pub fn vbusvalid_to_sessvalid(&self) -> VBUSVALID_TO_SESSVALID_R {
871        VBUSVALID_TO_SESSVALID_R::new(((self.bits >> 18) & 0x01) != 0)
872    }
873    #[doc = "Bit 20 - Enables the VBUS_VALID comparator"]
874    #[inline(always)]
875    pub fn pwrup_cmps(&self) -> PWRUP_CMPS_R {
876        PWRUP_CMPS_R::new(((self.bits >> 20) & 0x01) != 0)
877    }
878    #[doc = "Bit 26 - Controls VBUS discharge resistor"]
879    #[inline(always)]
880    pub fn discharge_vbus(&self) -> DISCHARGE_VBUS_R {
881        DISCHARGE_VBUS_R::new(((self.bits >> 26) & 0x01) != 0)
882    }
883    #[doc = "Bit 31 - Enables resistors used for an older method of resistive battery charger detection"]
884    #[inline(always)]
885    pub fn en_charger_resistor(&self) -> EN_CHARGER_RESISTOR_R {
886        EN_CHARGER_RESISTOR_R::new(((self.bits >> 31) & 0x01) != 0)
887    }
888}
889impl W {
890    #[doc = "Bits 0:2 - Sets the threshold for the VBUSVALID comparator"]
891    #[inline(always)]
892    pub fn vbusvalid_thresh(&mut self) -> VBUSVALID_THRESH_W {
893        VBUSVALID_THRESH_W { w: self }
894    }
895    #[doc = "Bit 3 - VBUS detect signal override enable"]
896    #[inline(always)]
897    pub fn vbus_override_en(&mut self) -> VBUS_OVERRIDE_EN_W {
898        VBUS_OVERRIDE_EN_W { w: self }
899    }
900    #[doc = "Bit 4 - Override value for SESSEND"]
901    #[inline(always)]
902    pub fn sessend_override(&mut self) -> SESSEND_OVERRIDE_W {
903        SESSEND_OVERRIDE_W { w: self }
904    }
905    #[doc = "Bit 5 - Override value for B-Device Session Valid"]
906    #[inline(always)]
907    pub fn bvalid_override(&mut self) -> BVALID_OVERRIDE_W {
908        BVALID_OVERRIDE_W { w: self }
909    }
910    #[doc = "Bit 6 - Override value for A-Device Session Valid"]
911    #[inline(always)]
912    pub fn avalid_override(&mut self) -> AVALID_OVERRIDE_W {
913        AVALID_OVERRIDE_W { w: self }
914    }
915    #[doc = "Bit 7 - Override value for VBUS_VALID signal sent to USB controller"]
916    #[inline(always)]
917    pub fn vbusvalid_override(&mut self) -> VBUSVALID_OVERRIDE_W {
918        VBUSVALID_OVERRIDE_W { w: self }
919    }
920    #[doc = "Bit 8 - Selects the source of the VBUS_VALID signal reported to the USB controller"]
921    #[inline(always)]
922    pub fn vbusvalid_sel(&mut self) -> VBUSVALID_SEL_W {
923        VBUSVALID_SEL_W { w: self }
924    }
925    #[doc = "Bits 9:10 - Selects the source of the VBUS_VALID signal reported to the USB controller"]
926    #[inline(always)]
927    pub fn vbus_source_sel(&mut self) -> VBUS_SOURCE_SEL_W {
928        VBUS_SOURCE_SEL_W { w: self }
929    }
930    #[doc = "Bit 18 - Selects the comparator used for VBUS_VALID"]
931    #[inline(always)]
932    pub fn vbusvalid_to_sessvalid(&mut self) -> VBUSVALID_TO_SESSVALID_W {
933        VBUSVALID_TO_SESSVALID_W { w: self }
934    }
935    #[doc = "Bit 20 - Enables the VBUS_VALID comparator"]
936    #[inline(always)]
937    pub fn pwrup_cmps(&mut self) -> PWRUP_CMPS_W {
938        PWRUP_CMPS_W { w: self }
939    }
940    #[doc = "Bit 26 - Controls VBUS discharge resistor"]
941    #[inline(always)]
942    pub fn discharge_vbus(&mut self) -> DISCHARGE_VBUS_W {
943        DISCHARGE_VBUS_W { w: self }
944    }
945    #[doc = "Bit 31 - Enables resistors used for an older method of resistive battery charger detection"]
946    #[inline(always)]
947    pub fn en_charger_resistor(&mut self) -> EN_CHARGER_RESISTOR_W {
948        EN_CHARGER_RESISTOR_W { w: self }
949    }
950}