Skip to main content

mcxa_pac/usb0/
observe.rs

1#[doc = "Register `OBSERVE` reader"]
2pub type R = crate::R<ObserveSpec>;
3#[doc = "D- Pulldown\n\nValue on reset: 1"]
4#[cfg_attr(feature = "defmt", derive(defmt::Format))]
5#[derive(Clone, Copy, Debug, PartialEq, Eq)]
6pub enum Dmpd {
7    #[doc = "0: Disabled"]
8    DmPdDisStat = 0,
9    #[doc = "1: Enabled"]
10    DmPdEnStat = 1,
11}
12impl From<Dmpd> for bool {
13    #[inline(always)]
14    fn from(variant: Dmpd) -> Self {
15        variant as u8 != 0
16    }
17}
18#[doc = "Field `DMPD` reader - D- Pulldown"]
19pub type DmpdR = crate::BitReader<Dmpd>;
20impl DmpdR {
21    #[doc = "Get enumerated values variant"]
22    #[inline(always)]
23    pub const fn variant(&self) -> Dmpd {
24        match self.bits {
25            false => Dmpd::DmPdDisStat,
26            true => Dmpd::DmPdEnStat,
27        }
28    }
29    #[doc = "Disabled"]
30    #[inline(always)]
31    pub fn is_dm_pd_dis_stat(&self) -> bool {
32        *self == Dmpd::DmPdDisStat
33    }
34    #[doc = "Enabled"]
35    #[inline(always)]
36    pub fn is_dm_pd_en_stat(&self) -> bool {
37        *self == Dmpd::DmPdEnStat
38    }
39}
40#[doc = "D+ Pulldown\n\nValue on reset: 1"]
41#[cfg_attr(feature = "defmt", derive(defmt::Format))]
42#[derive(Clone, Copy, Debug, PartialEq, Eq)]
43pub enum Dppd {
44    #[doc = "0: Disabled"]
45    DpPdDisStat = 0,
46    #[doc = "1: Enabled"]
47    DpPdEnStat = 1,
48}
49impl From<Dppd> for bool {
50    #[inline(always)]
51    fn from(variant: Dppd) -> Self {
52        variant as u8 != 0
53    }
54}
55#[doc = "Field `DPPD` reader - D+ Pulldown"]
56pub type DppdR = crate::BitReader<Dppd>;
57impl DppdR {
58    #[doc = "Get enumerated values variant"]
59    #[inline(always)]
60    pub const fn variant(&self) -> Dppd {
61        match self.bits {
62            false => Dppd::DpPdDisStat,
63            true => Dppd::DpPdEnStat,
64        }
65    }
66    #[doc = "Disabled"]
67    #[inline(always)]
68    pub fn is_dp_pd_dis_stat(&self) -> bool {
69        *self == Dppd::DpPdDisStat
70    }
71    #[doc = "Enabled"]
72    #[inline(always)]
73    pub fn is_dp_pd_en_stat(&self) -> bool {
74        *self == Dppd::DpPdEnStat
75    }
76}
77#[doc = "D+ Pullup\n\nValue on reset: 0"]
78#[cfg_attr(feature = "defmt", derive(defmt::Format))]
79#[derive(Clone, Copy, Debug, PartialEq, Eq)]
80pub enum Dppu {
81    #[doc = "0: Disabled"]
82    DpPuDisStat = 0,
83    #[doc = "1: Enabled"]
84    DpPuEnStat = 1,
85}
86impl From<Dppu> for bool {
87    #[inline(always)]
88    fn from(variant: Dppu) -> Self {
89        variant as u8 != 0
90    }
91}
92#[doc = "Field `DPPU` reader - D+ Pullup"]
93pub type DppuR = crate::BitReader<Dppu>;
94impl DppuR {
95    #[doc = "Get enumerated values variant"]
96    #[inline(always)]
97    pub const fn variant(&self) -> Dppu {
98        match self.bits {
99            false => Dppu::DpPuDisStat,
100            true => Dppu::DpPuEnStat,
101        }
102    }
103    #[doc = "Disabled"]
104    #[inline(always)]
105    pub fn is_dp_pu_dis_stat(&self) -> bool {
106        *self == Dppu::DpPuDisStat
107    }
108    #[doc = "Enabled"]
109    #[inline(always)]
110    pub fn is_dp_pu_en_stat(&self) -> bool {
111        *self == Dppu::DpPuEnStat
112    }
113}
114impl R {
115    #[doc = "Bit 4 - D- Pulldown"]
116    #[inline(always)]
117    pub fn dmpd(&self) -> DmpdR {
118        DmpdR::new(((self.bits >> 4) & 1) != 0)
119    }
120    #[doc = "Bit 6 - D+ Pulldown"]
121    #[inline(always)]
122    pub fn dppd(&self) -> DppdR {
123        DppdR::new(((self.bits >> 6) & 1) != 0)
124    }
125    #[doc = "Bit 7 - D+ Pullup"]
126    #[inline(always)]
127    pub fn dppu(&self) -> DppuR {
128        DppuR::new(((self.bits >> 7) & 1) != 0)
129    }
130}
131#[cfg(feature = "debug")]
132impl core::fmt::Debug for R {
133    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
134        f.debug_struct("OBSERVE")
135            .field("dmpd", &self.dmpd())
136            .field("dppd", &self.dppd())
137            .field("dppu", &self.dppu())
138            .finish()
139    }
140}
141#[doc = "USB OTG Observe\n\nYou can [`read`](crate::Reg::read) this register and get [`observe::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
142pub struct ObserveSpec;
143impl crate::RegisterSpec for ObserveSpec {
144    type Ux = u8;
145}
146#[doc = "`read()` method returns [`observe::R`](R) reader structure"]
147impl crate::Readable for ObserveSpec {}
148#[doc = "`reset()` method sets OBSERVE to value 0x50"]
149impl crate::Resettable for ObserveSpec {
150    const RESET_VALUE: u8 = 0x50;
151}