lpc55_pac/usbphy/
tx_set.rs

1#[doc = "Register `TX_SET` reader"]
2pub struct R(crate::R<TX_SET_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<TX_SET_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<TX_SET_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<TX_SET_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `TX_SET` writer"]
17pub struct W(crate::W<TX_SET_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<TX_SET_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<TX_SET_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<TX_SET_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Decode to trim the nominal 17\n\nValue on reset: 2"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum D_CAL_A {
41    #[doc = "0: Maximum current, approximately 19% above nominal."]
42    VALUE0 = 0,
43    #[doc = "7: Nominal"]
44    VALUE7 = 7,
45    #[doc = "15: Minimum current, approximately 19% below nominal."]
46    VALUE15 = 15,
47}
48impl From<D_CAL_A> for u8 {
49    #[inline(always)]
50    fn from(variant: D_CAL_A) -> Self {
51        variant as _
52    }
53}
54#[doc = "Field `D_CAL` reader - Decode to trim the nominal 17"]
55pub struct D_CAL_R(crate::FieldReader<u8, D_CAL_A>);
56impl D_CAL_R {
57    #[inline(always)]
58    pub(crate) fn new(bits: u8) -> Self {
59        D_CAL_R(crate::FieldReader::new(bits))
60    }
61    #[doc = r"Get enumerated values variant"]
62    #[inline(always)]
63    pub fn variant(&self) -> Option<D_CAL_A> {
64        match self.bits {
65            0 => Some(D_CAL_A::VALUE0),
66            7 => Some(D_CAL_A::VALUE7),
67            15 => Some(D_CAL_A::VALUE15),
68            _ => None,
69        }
70    }
71    #[doc = "Checks if the value of the field is `VALUE0`"]
72    #[inline(always)]
73    pub fn is_value0(&self) -> bool {
74        **self == D_CAL_A::VALUE0
75    }
76    #[doc = "Checks if the value of the field is `VALUE7`"]
77    #[inline(always)]
78    pub fn is_value7(&self) -> bool {
79        **self == D_CAL_A::VALUE7
80    }
81    #[doc = "Checks if the value of the field is `VALUE15`"]
82    #[inline(always)]
83    pub fn is_value15(&self) -> bool {
84        **self == D_CAL_A::VALUE15
85    }
86}
87impl core::ops::Deref for D_CAL_R {
88    type Target = crate::FieldReader<u8, D_CAL_A>;
89    #[inline(always)]
90    fn deref(&self) -> &Self::Target {
91        &self.0
92    }
93}
94#[doc = "Field `D_CAL` writer - Decode to trim the nominal 17"]
95pub struct D_CAL_W<'a> {
96    w: &'a mut W,
97}
98impl<'a> D_CAL_W<'a> {
99    #[doc = r"Writes `variant` to the field"]
100    #[inline(always)]
101    pub fn variant(self, variant: D_CAL_A) -> &'a mut W {
102        unsafe { self.bits(variant.into()) }
103    }
104    #[doc = "Maximum current, approximately 19% above nominal."]
105    #[inline(always)]
106    pub fn value0(self) -> &'a mut W {
107        self.variant(D_CAL_A::VALUE0)
108    }
109    #[doc = "Nominal"]
110    #[inline(always)]
111    pub fn value7(self) -> &'a mut W {
112        self.variant(D_CAL_A::VALUE7)
113    }
114    #[doc = "Minimum current, approximately 19% below nominal."]
115    #[inline(always)]
116    pub fn value15(self) -> &'a mut W {
117        self.variant(D_CAL_A::VALUE15)
118    }
119    #[doc = r"Writes raw bits to the field"]
120    #[inline(always)]
121    pub unsafe fn bits(self, value: u8) -> &'a mut W {
122        self.w.bits = (self.w.bits & !0x0f) | (value as u32 & 0x0f);
123        self.w
124    }
125}
126#[doc = "Field `TXCAL45DM` reader - Decode to trim the nominal 45ohm series termination resistance to the USB_DM output pin"]
127pub struct TXCAL45DM_R(crate::FieldReader<u8, u8>);
128impl TXCAL45DM_R {
129    #[inline(always)]
130    pub(crate) fn new(bits: u8) -> Self {
131        TXCAL45DM_R(crate::FieldReader::new(bits))
132    }
133}
134impl core::ops::Deref for TXCAL45DM_R {
135    type Target = crate::FieldReader<u8, u8>;
136    #[inline(always)]
137    fn deref(&self) -> &Self::Target {
138        &self.0
139    }
140}
141#[doc = "Field `TXCAL45DM` writer - Decode to trim the nominal 45ohm series termination resistance to the USB_DM output pin"]
142pub struct TXCAL45DM_W<'a> {
143    w: &'a mut W,
144}
145impl<'a> TXCAL45DM_W<'a> {
146    #[doc = r"Writes raw bits to the field"]
147    #[inline(always)]
148    pub unsafe fn bits(self, value: u8) -> &'a mut W {
149        self.w.bits = (self.w.bits & !(0x0f << 8)) | ((value as u32 & 0x0f) << 8);
150        self.w
151    }
152}
153#[doc = "Field `TXENCAL45DN` reader - Enable resistance calibration on DN."]
154pub struct TXENCAL45DN_R(crate::FieldReader<bool, bool>);
155impl TXENCAL45DN_R {
156    #[inline(always)]
157    pub(crate) fn new(bits: bool) -> Self {
158        TXENCAL45DN_R(crate::FieldReader::new(bits))
159    }
160}
161impl core::ops::Deref for TXENCAL45DN_R {
162    type Target = crate::FieldReader<bool, bool>;
163    #[inline(always)]
164    fn deref(&self) -> &Self::Target {
165        &self.0
166    }
167}
168#[doc = "Field `TXENCAL45DN` writer - Enable resistance calibration on DN."]
169pub struct TXENCAL45DN_W<'a> {
170    w: &'a mut W,
171}
172impl<'a> TXENCAL45DN_W<'a> {
173    #[doc = r"Sets the field bit"]
174    #[inline(always)]
175    pub fn set_bit(self) -> &'a mut W {
176        self.bit(true)
177    }
178    #[doc = r"Clears the field bit"]
179    #[inline(always)]
180    pub fn clear_bit(self) -> &'a mut W {
181        self.bit(false)
182    }
183    #[doc = r"Writes raw bits to the field"]
184    #[inline(always)]
185    pub fn bit(self, value: bool) -> &'a mut W {
186        self.w.bits = (self.w.bits & !(0x01 << 13)) | ((value as u32 & 0x01) << 13);
187        self.w
188    }
189}
190#[doc = "Field `TXCAL45DP` reader - Decode to trim the nominal 45ohm series termination resistance to the USB_DP output pin"]
191pub struct TXCAL45DP_R(crate::FieldReader<u8, u8>);
192impl TXCAL45DP_R {
193    #[inline(always)]
194    pub(crate) fn new(bits: u8) -> Self {
195        TXCAL45DP_R(crate::FieldReader::new(bits))
196    }
197}
198impl core::ops::Deref for TXCAL45DP_R {
199    type Target = crate::FieldReader<u8, u8>;
200    #[inline(always)]
201    fn deref(&self) -> &Self::Target {
202        &self.0
203    }
204}
205#[doc = "Field `TXCAL45DP` writer - Decode to trim the nominal 45ohm series termination resistance to the USB_DP output pin"]
206pub struct TXCAL45DP_W<'a> {
207    w: &'a mut W,
208}
209impl<'a> TXCAL45DP_W<'a> {
210    #[doc = r"Writes raw bits to the field"]
211    #[inline(always)]
212    pub unsafe fn bits(self, value: u8) -> &'a mut W {
213        self.w.bits = (self.w.bits & !(0x0f << 16)) | ((value as u32 & 0x0f) << 16);
214        self.w
215    }
216}
217#[doc = "Field `TXENCAL45DP` reader - Enable resistance calibration on DP."]
218pub struct TXENCAL45DP_R(crate::FieldReader<bool, bool>);
219impl TXENCAL45DP_R {
220    #[inline(always)]
221    pub(crate) fn new(bits: bool) -> Self {
222        TXENCAL45DP_R(crate::FieldReader::new(bits))
223    }
224}
225impl core::ops::Deref for TXENCAL45DP_R {
226    type Target = crate::FieldReader<bool, bool>;
227    #[inline(always)]
228    fn deref(&self) -> &Self::Target {
229        &self.0
230    }
231}
232#[doc = "Field `TXENCAL45DP` writer - Enable resistance calibration on DP."]
233pub struct TXENCAL45DP_W<'a> {
234    w: &'a mut W,
235}
236impl<'a> TXENCAL45DP_W<'a> {
237    #[doc = r"Sets the field bit"]
238    #[inline(always)]
239    pub fn set_bit(self) -> &'a mut W {
240        self.bit(true)
241    }
242    #[doc = r"Clears the field bit"]
243    #[inline(always)]
244    pub fn clear_bit(self) -> &'a mut W {
245        self.bit(false)
246    }
247    #[doc = r"Writes raw bits to the field"]
248    #[inline(always)]
249    pub fn bit(self, value: bool) -> &'a mut W {
250        self.w.bits = (self.w.bits & !(0x01 << 21)) | ((value as u32 & 0x01) << 21);
251        self.w
252    }
253}
254impl R {
255    #[doc = "Bits 0:3 - Decode to trim the nominal 17"]
256    #[inline(always)]
257    pub fn d_cal(&self) -> D_CAL_R {
258        D_CAL_R::new((self.bits & 0x0f) as u8)
259    }
260    #[doc = "Bits 8:11 - Decode to trim the nominal 45ohm series termination resistance to the USB_DM output pin"]
261    #[inline(always)]
262    pub fn txcal45dm(&self) -> TXCAL45DM_R {
263        TXCAL45DM_R::new(((self.bits >> 8) & 0x0f) as u8)
264    }
265    #[doc = "Bit 13 - Enable resistance calibration on DN."]
266    #[inline(always)]
267    pub fn txencal45dn(&self) -> TXENCAL45DN_R {
268        TXENCAL45DN_R::new(((self.bits >> 13) & 0x01) != 0)
269    }
270    #[doc = "Bits 16:19 - Decode to trim the nominal 45ohm series termination resistance to the USB_DP output pin"]
271    #[inline(always)]
272    pub fn txcal45dp(&self) -> TXCAL45DP_R {
273        TXCAL45DP_R::new(((self.bits >> 16) & 0x0f) as u8)
274    }
275    #[doc = "Bit 21 - Enable resistance calibration on DP."]
276    #[inline(always)]
277    pub fn txencal45dp(&self) -> TXENCAL45DP_R {
278        TXENCAL45DP_R::new(((self.bits >> 21) & 0x01) != 0)
279    }
280}
281impl W {
282    #[doc = "Bits 0:3 - Decode to trim the nominal 17"]
283    #[inline(always)]
284    pub fn d_cal(&mut self) -> D_CAL_W {
285        D_CAL_W { w: self }
286    }
287    #[doc = "Bits 8:11 - Decode to trim the nominal 45ohm series termination resistance to the USB_DM output pin"]
288    #[inline(always)]
289    pub fn txcal45dm(&mut self) -> TXCAL45DM_W {
290        TXCAL45DM_W { w: self }
291    }
292    #[doc = "Bit 13 - Enable resistance calibration on DN."]
293    #[inline(always)]
294    pub fn txencal45dn(&mut self) -> TXENCAL45DN_W {
295        TXENCAL45DN_W { w: self }
296    }
297    #[doc = "Bits 16:19 - Decode to trim the nominal 45ohm series termination resistance to the USB_DP output pin"]
298    #[inline(always)]
299    pub fn txcal45dp(&mut self) -> TXCAL45DP_W {
300        TXCAL45DP_W { w: self }
301    }
302    #[doc = "Bit 21 - Enable resistance calibration on DP."]
303    #[inline(always)]
304    pub fn txencal45dp(&mut self) -> TXENCAL45DP_W {
305        TXENCAL45DP_W { w: self }
306    }
307    #[doc = "Writes raw bits to the register."]
308    #[inline(always)]
309    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
310        self.0.bits(bits);
311        self
312    }
313}
314#[doc = "USB PHY Transmitter Control Register\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 [tx_set](index.html) module"]
315pub struct TX_SET_SPEC;
316impl crate::RegisterSpec for TX_SET_SPEC {
317    type Ux = u32;
318}
319#[doc = "`read()` method returns [tx_set::R](R) reader structure"]
320impl crate::Readable for TX_SET_SPEC {
321    type Reader = R;
322}
323#[doc = "`write(|w| ..)` method takes [tx_set::W](W) writer structure"]
324impl crate::Writable for TX_SET_SPEC {
325    type Writer = W;
326}
327#[doc = "`reset()` method sets TX_SET to value 0x0a00_0402"]
328impl crate::Resettable for TX_SET_SPEC {
329    #[inline(always)]
330    fn reset_value() -> Self::Ux {
331        0x0a00_0402
332    }
333}