nrf52840_pac/comp/
mode.rs
1#[doc = "Register `MODE` reader"]
2pub struct R(crate::R<MODE_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<MODE_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<MODE_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<MODE_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `MODE` writer"]
17pub struct W(crate::W<MODE_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<MODE_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<MODE_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<MODE_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `SP` reader - Speed and power modes"]
38pub type SP_R = crate::FieldReader<u8, SP_A>;
39#[doc = "Speed and power modes\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u8)]
42pub enum SP_A {
43 #[doc = "0: Low-power mode"]
44 LOW = 0,
45 #[doc = "1: Normal mode"]
46 NORMAL = 1,
47 #[doc = "2: High-speed mode"]
48 HIGH = 2,
49}
50impl From<SP_A> for u8 {
51 #[inline(always)]
52 fn from(variant: SP_A) -> Self {
53 variant as _
54 }
55}
56impl SP_R {
57 #[doc = "Get enumerated values variant"]
58 #[inline(always)]
59 pub fn variant(&self) -> Option<SP_A> {
60 match self.bits {
61 0 => Some(SP_A::LOW),
62 1 => Some(SP_A::NORMAL),
63 2 => Some(SP_A::HIGH),
64 _ => None,
65 }
66 }
67 #[doc = "Checks if the value of the field is `LOW`"]
68 #[inline(always)]
69 pub fn is_low(&self) -> bool {
70 *self == SP_A::LOW
71 }
72 #[doc = "Checks if the value of the field is `NORMAL`"]
73 #[inline(always)]
74 pub fn is_normal(&self) -> bool {
75 *self == SP_A::NORMAL
76 }
77 #[doc = "Checks if the value of the field is `HIGH`"]
78 #[inline(always)]
79 pub fn is_high(&self) -> bool {
80 *self == SP_A::HIGH
81 }
82}
83#[doc = "Field `SP` writer - Speed and power modes"]
84pub type SP_W<'a, const O: u8> = crate::FieldWriter<'a, u32, MODE_SPEC, u8, SP_A, 2, O>;
85impl<'a, const O: u8> SP_W<'a, O> {
86 #[doc = "Low-power mode"]
87 #[inline(always)]
88 pub fn low(self) -> &'a mut W {
89 self.variant(SP_A::LOW)
90 }
91 #[doc = "Normal mode"]
92 #[inline(always)]
93 pub fn normal(self) -> &'a mut W {
94 self.variant(SP_A::NORMAL)
95 }
96 #[doc = "High-speed mode"]
97 #[inline(always)]
98 pub fn high(self) -> &'a mut W {
99 self.variant(SP_A::HIGH)
100 }
101}
102#[doc = "Field `MAIN` reader - Main operation modes"]
103pub type MAIN_R = crate::BitReader<MAIN_A>;
104#[doc = "Main operation modes\n\nValue on reset: 0"]
105#[derive(Clone, Copy, Debug, PartialEq)]
106pub enum MAIN_A {
107 #[doc = "0: Single-ended mode"]
108 SE = 0,
109 #[doc = "1: Differential mode"]
110 DIFF = 1,
111}
112impl From<MAIN_A> for bool {
113 #[inline(always)]
114 fn from(variant: MAIN_A) -> Self {
115 variant as u8 != 0
116 }
117}
118impl MAIN_R {
119 #[doc = "Get enumerated values variant"]
120 #[inline(always)]
121 pub fn variant(&self) -> MAIN_A {
122 match self.bits {
123 false => MAIN_A::SE,
124 true => MAIN_A::DIFF,
125 }
126 }
127 #[doc = "Checks if the value of the field is `SE`"]
128 #[inline(always)]
129 pub fn is_se(&self) -> bool {
130 *self == MAIN_A::SE
131 }
132 #[doc = "Checks if the value of the field is `DIFF`"]
133 #[inline(always)]
134 pub fn is_diff(&self) -> bool {
135 *self == MAIN_A::DIFF
136 }
137}
138#[doc = "Field `MAIN` writer - Main operation modes"]
139pub type MAIN_W<'a, const O: u8> = crate::BitWriter<'a, u32, MODE_SPEC, MAIN_A, O>;
140impl<'a, const O: u8> MAIN_W<'a, O> {
141 #[doc = "Single-ended mode"]
142 #[inline(always)]
143 pub fn se(self) -> &'a mut W {
144 self.variant(MAIN_A::SE)
145 }
146 #[doc = "Differential mode"]
147 #[inline(always)]
148 pub fn diff(self) -> &'a mut W {
149 self.variant(MAIN_A::DIFF)
150 }
151}
152impl R {
153 #[doc = "Bits 0:1 - Speed and power modes"]
154 #[inline(always)]
155 pub fn sp(&self) -> SP_R {
156 SP_R::new((self.bits & 3) as u8)
157 }
158 #[doc = "Bit 8 - Main operation modes"]
159 #[inline(always)]
160 pub fn main(&self) -> MAIN_R {
161 MAIN_R::new(((self.bits >> 8) & 1) != 0)
162 }
163}
164impl W {
165 #[doc = "Bits 0:1 - Speed and power modes"]
166 #[inline(always)]
167 pub fn sp(&mut self) -> SP_W<0> {
168 SP_W::new(self)
169 }
170 #[doc = "Bit 8 - Main operation modes"]
171 #[inline(always)]
172 pub fn main(&mut self) -> MAIN_W<8> {
173 MAIN_W::new(self)
174 }
175 #[doc = "Writes raw bits to the register."]
176 #[inline(always)]
177 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
178 self.0.bits(bits);
179 self
180 }
181}
182#[doc = "Mode configuration\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 [mode](index.html) module"]
183pub struct MODE_SPEC;
184impl crate::RegisterSpec for MODE_SPEC {
185 type Ux = u32;
186}
187#[doc = "`read()` method returns [mode::R](R) reader structure"]
188impl crate::Readable for MODE_SPEC {
189 type Reader = R;
190}
191#[doc = "`write(|w| ..)` method takes [mode::W](W) writer structure"]
192impl crate::Writable for MODE_SPEC {
193 type Writer = W;
194}
195#[doc = "`reset()` method sets MODE to value 0"]
196impl crate::Resettable for MODE_SPEC {
197 #[inline(always)]
198 fn reset_value() -> Self::Ux {
199 0
200 }
201}