Skip to main content

k22f/usb0/
usbctrl.rs

1#[doc = "Reader of register USBCTRL"]
2pub type R = crate::R<u8, super::USBCTRL>;
3#[doc = "Writer for register USBCTRL"]
4pub type W = crate::W<u8, super::USBCTRL>;
5#[doc = "Register USBCTRL `reset()`'s with value 0xc0"]
6impl crate::ResetValue for super::USBCTRL {
7    type Type = u8;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0xc0
11    }
12}
13#[doc = "Enables the weak pulldowns on the USB transceiver.\n\nValue on reset: 1"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum PDE_A {
16    #[doc = "0: Weak pulldowns are disabled on D+ and D-."]
17    _0 = 0,
18    #[doc = "1: Weak pulldowns are enabled on D+ and D-."]
19    _1 = 1,
20}
21impl From<PDE_A> for bool {
22    #[inline(always)]
23    fn from(variant: PDE_A) -> Self {
24        variant as u8 != 0
25    }
26}
27#[doc = "Reader of field `PDE`"]
28pub type PDE_R = crate::R<bool, PDE_A>;
29impl PDE_R {
30    #[doc = r"Get enumerated values variant"]
31    #[inline(always)]
32    pub fn variant(&self) -> PDE_A {
33        match self.bits {
34            false => PDE_A::_0,
35            true => PDE_A::_1,
36        }
37    }
38    #[doc = "Checks if the value of the field is `_0`"]
39    #[inline(always)]
40    pub fn is_0(&self) -> bool {
41        *self == PDE_A::_0
42    }
43    #[doc = "Checks if the value of the field is `_1`"]
44    #[inline(always)]
45    pub fn is_1(&self) -> bool {
46        *self == PDE_A::_1
47    }
48}
49#[doc = "Write proxy for field `PDE`"]
50pub struct PDE_W<'a> {
51    w: &'a mut W,
52}
53impl<'a> PDE_W<'a> {
54    #[doc = r"Writes `variant` to the field"]
55    #[inline(always)]
56    pub fn variant(self, variant: PDE_A) -> &'a mut W {
57        {
58            self.bit(variant.into())
59        }
60    }
61    #[doc = "Weak pulldowns are disabled on D+ and D-."]
62    #[inline(always)]
63    pub fn _0(self) -> &'a mut W {
64        self.variant(PDE_A::_0)
65    }
66    #[doc = "Weak pulldowns are enabled on D+ and D-."]
67    #[inline(always)]
68    pub fn _1(self) -> &'a mut W {
69        self.variant(PDE_A::_1)
70    }
71    #[doc = r"Sets the field bit"]
72    #[inline(always)]
73    pub fn set_bit(self) -> &'a mut W {
74        self.bit(true)
75    }
76    #[doc = r"Clears the field bit"]
77    #[inline(always)]
78    pub fn clear_bit(self) -> &'a mut W {
79        self.bit(false)
80    }
81    #[doc = r"Writes raw bits to the field"]
82    #[inline(always)]
83    pub fn bit(self, value: bool) -> &'a mut W {
84        self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u8) & 0x01) << 6);
85        self.w
86    }
87}
88#[doc = "Places the USB transceiver into the suspend state.\n\nValue on reset: 1"]
89#[derive(Clone, Copy, Debug, PartialEq)]
90pub enum SUSP_A {
91    #[doc = "0: USB transceiver is not in suspend state."]
92    _0 = 0,
93    #[doc = "1: USB transceiver is in suspend state."]
94    _1 = 1,
95}
96impl From<SUSP_A> for bool {
97    #[inline(always)]
98    fn from(variant: SUSP_A) -> Self {
99        variant as u8 != 0
100    }
101}
102#[doc = "Reader of field `SUSP`"]
103pub type SUSP_R = crate::R<bool, SUSP_A>;
104impl SUSP_R {
105    #[doc = r"Get enumerated values variant"]
106    #[inline(always)]
107    pub fn variant(&self) -> SUSP_A {
108        match self.bits {
109            false => SUSP_A::_0,
110            true => SUSP_A::_1,
111        }
112    }
113    #[doc = "Checks if the value of the field is `_0`"]
114    #[inline(always)]
115    pub fn is_0(&self) -> bool {
116        *self == SUSP_A::_0
117    }
118    #[doc = "Checks if the value of the field is `_1`"]
119    #[inline(always)]
120    pub fn is_1(&self) -> bool {
121        *self == SUSP_A::_1
122    }
123}
124#[doc = "Write proxy for field `SUSP`"]
125pub struct SUSP_W<'a> {
126    w: &'a mut W,
127}
128impl<'a> SUSP_W<'a> {
129    #[doc = r"Writes `variant` to the field"]
130    #[inline(always)]
131    pub fn variant(self, variant: SUSP_A) -> &'a mut W {
132        {
133            self.bit(variant.into())
134        }
135    }
136    #[doc = "USB transceiver is not in suspend state."]
137    #[inline(always)]
138    pub fn _0(self) -> &'a mut W {
139        self.variant(SUSP_A::_0)
140    }
141    #[doc = "USB transceiver is in suspend state."]
142    #[inline(always)]
143    pub fn _1(self) -> &'a mut W {
144        self.variant(SUSP_A::_1)
145    }
146    #[doc = r"Sets the field bit"]
147    #[inline(always)]
148    pub fn set_bit(self) -> &'a mut W {
149        self.bit(true)
150    }
151    #[doc = r"Clears the field bit"]
152    #[inline(always)]
153    pub fn clear_bit(self) -> &'a mut W {
154        self.bit(false)
155    }
156    #[doc = r"Writes raw bits to the field"]
157    #[inline(always)]
158    pub fn bit(self, value: bool) -> &'a mut W {
159        self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u8) & 0x01) << 7);
160        self.w
161    }
162}
163impl R {
164    #[doc = "Bit 6 - Enables the weak pulldowns on the USB transceiver."]
165    #[inline(always)]
166    pub fn pde(&self) -> PDE_R {
167        PDE_R::new(((self.bits >> 6) & 0x01) != 0)
168    }
169    #[doc = "Bit 7 - Places the USB transceiver into the suspend state."]
170    #[inline(always)]
171    pub fn susp(&self) -> SUSP_R {
172        SUSP_R::new(((self.bits >> 7) & 0x01) != 0)
173    }
174}
175impl W {
176    #[doc = "Bit 6 - Enables the weak pulldowns on the USB transceiver."]
177    #[inline(always)]
178    pub fn pde(&mut self) -> PDE_W {
179        PDE_W { w: self }
180    }
181    #[doc = "Bit 7 - Places the USB transceiver into the suspend state."]
182    #[inline(always)]
183    pub fn susp(&mut self) -> SUSP_W {
184        SUSP_W { w: self }
185    }
186}