1#[doc = "Register `CONTROL` reader"]
2pub type R = crate::R<ControlSpec>;
3#[doc = "Register `CONTROL` writer"]
4pub type W = crate::W<ControlSpec>;
5#[doc = "Interrupt Acknowledge\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Iack {
9 #[doc = "0: Do not clear the interrupt."]
10 IntNoclear = 0,
11 #[doc = "1: Clear the IF bit (interrupt flag)."]
12 IntClear = 1,
13}
14impl From<Iack> for bool {
15 #[inline(always)]
16 fn from(variant: Iack) -> Self {
17 variant as u8 != 0
18 }
19}
20#[doc = "Field `IACK` reader - Interrupt Acknowledge"]
21pub type IackR = crate::BitReader<Iack>;
22impl IackR {
23 #[doc = "Get enumerated values variant"]
24 #[inline(always)]
25 pub const fn variant(&self) -> Iack {
26 match self.bits {
27 false => Iack::IntNoclear,
28 true => Iack::IntClear,
29 }
30 }
31 #[doc = "Do not clear the interrupt."]
32 #[inline(always)]
33 pub fn is_int_noclear(&self) -> bool {
34 *self == Iack::IntNoclear
35 }
36 #[doc = "Clear the IF bit (interrupt flag)."]
37 #[inline(always)]
38 pub fn is_int_clear(&self) -> bool {
39 *self == Iack::IntClear
40 }
41}
42#[doc = "Field `IACK` writer - Interrupt Acknowledge"]
43pub type IackW<'a, REG> = crate::BitWriter<'a, REG, Iack>;
44impl<'a, REG> IackW<'a, REG>
45where
46 REG: crate::Writable + crate::RegisterSpec,
47{
48 #[doc = "Do not clear the interrupt."]
49 #[inline(always)]
50 pub fn int_noclear(self) -> &'a mut crate::W<REG> {
51 self.variant(Iack::IntNoclear)
52 }
53 #[doc = "Clear the IF bit (interrupt flag)."]
54 #[inline(always)]
55 pub fn int_clear(self) -> &'a mut crate::W<REG> {
56 self.variant(Iack::IntClear)
57 }
58}
59#[doc = "Interrupt Flag\n\nValue on reset: 0"]
60#[cfg_attr(feature = "defmt", derive(defmt::Format))]
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62pub enum If {
63 #[doc = "0: No interrupt is pending."]
64 IntPend = 0,
65 #[doc = "1: An interrupt is pending."]
66 IntNopend = 1,
67}
68impl From<If> for bool {
69 #[inline(always)]
70 fn from(variant: If) -> Self {
71 variant as u8 != 0
72 }
73}
74#[doc = "Field `IF` reader - Interrupt Flag"]
75pub type IfR = crate::BitReader<If>;
76impl IfR {
77 #[doc = "Get enumerated values variant"]
78 #[inline(always)]
79 pub const fn variant(&self) -> If {
80 match self.bits {
81 false => If::IntPend,
82 true => If::IntNopend,
83 }
84 }
85 #[doc = "No interrupt is pending."]
86 #[inline(always)]
87 pub fn is_int_pend(&self) -> bool {
88 *self == If::IntPend
89 }
90 #[doc = "An interrupt is pending."]
91 #[inline(always)]
92 pub fn is_int_nopend(&self) -> bool {
93 *self == If::IntNopend
94 }
95}
96#[doc = "Interrupt Enable\n\nValue on reset: 1"]
97#[cfg_attr(feature = "defmt", derive(defmt::Format))]
98#[derive(Clone, Copy, Debug, PartialEq, Eq)]
99pub enum Ie {
100 #[doc = "0: Disable interrupts to the system."]
101 DisInt = 0,
102 #[doc = "1: Enable interrupts to the system."]
103 EnInt = 1,
104}
105impl From<Ie> for bool {
106 #[inline(always)]
107 fn from(variant: Ie) -> Self {
108 variant as u8 != 0
109 }
110}
111#[doc = "Field `IE` reader - Interrupt Enable"]
112pub type IeR = crate::BitReader<Ie>;
113impl IeR {
114 #[doc = "Get enumerated values variant"]
115 #[inline(always)]
116 pub const fn variant(&self) -> Ie {
117 match self.bits {
118 false => Ie::DisInt,
119 true => Ie::EnInt,
120 }
121 }
122 #[doc = "Disable interrupts to the system."]
123 #[inline(always)]
124 pub fn is_dis_int(&self) -> bool {
125 *self == Ie::DisInt
126 }
127 #[doc = "Enable interrupts to the system."]
128 #[inline(always)]
129 pub fn is_en_int(&self) -> bool {
130 *self == Ie::EnInt
131 }
132}
133#[doc = "Field `IE` writer - Interrupt Enable"]
134pub type IeW<'a, REG> = crate::BitWriter<'a, REG, Ie>;
135impl<'a, REG> IeW<'a, REG>
136where
137 REG: crate::Writable + crate::RegisterSpec,
138{
139 #[doc = "Disable interrupts to the system."]
140 #[inline(always)]
141 pub fn dis_int(self) -> &'a mut crate::W<REG> {
142 self.variant(Ie::DisInt)
143 }
144 #[doc = "Enable interrupts to the system."]
145 #[inline(always)]
146 pub fn en_int(self) -> &'a mut crate::W<REG> {
147 self.variant(Ie::EnInt)
148 }
149}
150#[doc = "BC12\n\nValue on reset: 0"]
151#[cfg_attr(feature = "defmt", derive(defmt::Format))]
152#[derive(Clone, Copy, Debug, PartialEq, Eq)]
153pub enum Bc12 {
154 #[doc = "0: Compatible with BC1.1 (default)"]
155 Bc11 = 0,
156 #[doc = "1: Compatible with BC1.2"]
157 Bc12 = 1,
158}
159impl From<Bc12> for bool {
160 #[inline(always)]
161 fn from(variant: Bc12) -> Self {
162 variant as u8 != 0
163 }
164}
165#[doc = "Field `BC12` reader - BC12"]
166pub type Bc12R = crate::BitReader<Bc12>;
167impl Bc12R {
168 #[doc = "Get enumerated values variant"]
169 #[inline(always)]
170 pub const fn variant(&self) -> Bc12 {
171 match self.bits {
172 false => Bc12::Bc11,
173 true => Bc12::Bc12,
174 }
175 }
176 #[doc = "Compatible with BC1.1 (default)"]
177 #[inline(always)]
178 pub fn is_bc11(&self) -> bool {
179 *self == Bc12::Bc11
180 }
181 #[doc = "Compatible with BC1.2"]
182 #[inline(always)]
183 pub fn is_bc12(&self) -> bool {
184 *self == Bc12::Bc12
185 }
186}
187#[doc = "Field `BC12` writer - BC12"]
188pub type Bc12W<'a, REG> = crate::BitWriter<'a, REG, Bc12>;
189impl<'a, REG> Bc12W<'a, REG>
190where
191 REG: crate::Writable + crate::RegisterSpec,
192{
193 #[doc = "Compatible with BC1.1 (default)"]
194 #[inline(always)]
195 pub fn bc11(self) -> &'a mut crate::W<REG> {
196 self.variant(Bc12::Bc11)
197 }
198 #[doc = "Compatible with BC1.2"]
199 #[inline(always)]
200 pub fn bc12(self) -> &'a mut crate::W<REG> {
201 self.variant(Bc12::Bc12)
202 }
203}
204#[doc = "Start Change Detection Sequence\n\nValue on reset: 0"]
205#[cfg_attr(feature = "defmt", derive(defmt::Format))]
206#[derive(Clone, Copy, Debug, PartialEq, Eq)]
207pub enum Start {
208 #[doc = "0: Do not start the sequence. Writes of this value have no effect."]
209 NoStart = 0,
210 #[doc = "1: Initiate the charger detection sequence. If the sequence is already running, writes of this value have no effect."]
211 Start = 1,
212}
213impl From<Start> for bool {
214 #[inline(always)]
215 fn from(variant: Start) -> Self {
216 variant as u8 != 0
217 }
218}
219#[doc = "Field `START` reader - Start Change Detection Sequence"]
220pub type StartR = crate::BitReader<Start>;
221impl StartR {
222 #[doc = "Get enumerated values variant"]
223 #[inline(always)]
224 pub const fn variant(&self) -> Start {
225 match self.bits {
226 false => Start::NoStart,
227 true => Start::Start,
228 }
229 }
230 #[doc = "Do not start the sequence. Writes of this value have no effect."]
231 #[inline(always)]
232 pub fn is_no_start(&self) -> bool {
233 *self == Start::NoStart
234 }
235 #[doc = "Initiate the charger detection sequence. If the sequence is already running, writes of this value have no effect."]
236 #[inline(always)]
237 pub fn is_start(&self) -> bool {
238 *self == Start::Start
239 }
240}
241#[doc = "Field `START` writer - Start Change Detection Sequence"]
242pub type StartW<'a, REG> = crate::BitWriter<'a, REG, Start>;
243impl<'a, REG> StartW<'a, REG>
244where
245 REG: crate::Writable + crate::RegisterSpec,
246{
247 #[doc = "Do not start the sequence. Writes of this value have no effect."]
248 #[inline(always)]
249 pub fn no_start(self) -> &'a mut crate::W<REG> {
250 self.variant(Start::NoStart)
251 }
252 #[doc = "Initiate the charger detection sequence. If the sequence is already running, writes of this value have no effect."]
253 #[inline(always)]
254 pub fn start(self) -> &'a mut crate::W<REG> {
255 self.variant(Start::Start)
256 }
257}
258#[doc = "Software Reset\n\nValue on reset: 0"]
259#[cfg_attr(feature = "defmt", derive(defmt::Format))]
260#[derive(Clone, Copy, Debug, PartialEq, Eq)]
261pub enum Sr {
262 #[doc = "0: Do not perform a software reset."]
263 NoReset = 0,
264 #[doc = "1: Perform a software reset."]
265 SwReset = 1,
266}
267impl From<Sr> for bool {
268 #[inline(always)]
269 fn from(variant: Sr) -> Self {
270 variant as u8 != 0
271 }
272}
273#[doc = "Field `SR` reader - Software Reset"]
274pub type SrR = crate::BitReader<Sr>;
275impl SrR {
276 #[doc = "Get enumerated values variant"]
277 #[inline(always)]
278 pub const fn variant(&self) -> Sr {
279 match self.bits {
280 false => Sr::NoReset,
281 true => Sr::SwReset,
282 }
283 }
284 #[doc = "Do not perform a software reset."]
285 #[inline(always)]
286 pub fn is_no_reset(&self) -> bool {
287 *self == Sr::NoReset
288 }
289 #[doc = "Perform a software reset."]
290 #[inline(always)]
291 pub fn is_sw_reset(&self) -> bool {
292 *self == Sr::SwReset
293 }
294}
295#[doc = "Field `SR` writer - Software Reset"]
296pub type SrW<'a, REG> = crate::BitWriter<'a, REG, Sr>;
297impl<'a, REG> SrW<'a, REG>
298where
299 REG: crate::Writable + crate::RegisterSpec,
300{
301 #[doc = "Do not perform a software reset."]
302 #[inline(always)]
303 pub fn no_reset(self) -> &'a mut crate::W<REG> {
304 self.variant(Sr::NoReset)
305 }
306 #[doc = "Perform a software reset."]
307 #[inline(always)]
308 pub fn sw_reset(self) -> &'a mut crate::W<REG> {
309 self.variant(Sr::SwReset)
310 }
311}
312impl R {
313 #[doc = "Bit 0 - Interrupt Acknowledge"]
314 #[inline(always)]
315 pub fn iack(&self) -> IackR {
316 IackR::new((self.bits & 1) != 0)
317 }
318 #[doc = "Bit 8 - Interrupt Flag"]
319 #[inline(always)]
320 pub fn if_(&self) -> IfR {
321 IfR::new(((self.bits >> 8) & 1) != 0)
322 }
323 #[doc = "Bit 16 - Interrupt Enable"]
324 #[inline(always)]
325 pub fn ie(&self) -> IeR {
326 IeR::new(((self.bits >> 16) & 1) != 0)
327 }
328 #[doc = "Bit 17 - BC12"]
329 #[inline(always)]
330 pub fn bc12(&self) -> Bc12R {
331 Bc12R::new(((self.bits >> 17) & 1) != 0)
332 }
333 #[doc = "Bit 24 - Start Change Detection Sequence"]
334 #[inline(always)]
335 pub fn start(&self) -> StartR {
336 StartR::new(((self.bits >> 24) & 1) != 0)
337 }
338 #[doc = "Bit 25 - Software Reset"]
339 #[inline(always)]
340 pub fn sr(&self) -> SrR {
341 SrR::new(((self.bits >> 25) & 1) != 0)
342 }
343}
344#[cfg(feature = "debug")]
345impl core::fmt::Debug for R {
346 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
347 f.debug_struct("CONTROL")
348 .field("iack", &self.iack())
349 .field("if_", &self.if_())
350 .field("ie", &self.ie())
351 .field("bc12", &self.bc12())
352 .field("start", &self.start())
353 .field("sr", &self.sr())
354 .finish()
355 }
356}
357impl W {
358 #[doc = "Bit 0 - Interrupt Acknowledge"]
359 #[inline(always)]
360 pub fn iack(&mut self) -> IackW<ControlSpec> {
361 IackW::new(self, 0)
362 }
363 #[doc = "Bit 16 - Interrupt Enable"]
364 #[inline(always)]
365 pub fn ie(&mut self) -> IeW<ControlSpec> {
366 IeW::new(self, 16)
367 }
368 #[doc = "Bit 17 - BC12"]
369 #[inline(always)]
370 pub fn bc12(&mut self) -> Bc12W<ControlSpec> {
371 Bc12W::new(self, 17)
372 }
373 #[doc = "Bit 24 - Start Change Detection Sequence"]
374 #[inline(always)]
375 pub fn start(&mut self) -> StartW<ControlSpec> {
376 StartW::new(self, 24)
377 }
378 #[doc = "Bit 25 - Software Reset"]
379 #[inline(always)]
380 pub fn sr(&mut self) -> SrW<ControlSpec> {
381 SrW::new(self, 25)
382 }
383}
384#[doc = "Control register\n\nYou can [`read`](crate::Reg::read) this register and get [`control::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`control::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
385pub struct ControlSpec;
386impl crate::RegisterSpec for ControlSpec {
387 type Ux = u32;
388}
389#[doc = "`read()` method returns [`control::R`](R) reader structure"]
390impl crate::Readable for ControlSpec {}
391#[doc = "`write(|w| ..)` method takes [`control::W`](W) writer structure"]
392impl crate::Writable for ControlSpec {
393 type Safety = crate::Unsafe;
394 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
395 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
396}
397#[doc = "`reset()` method sets CONTROL to value 0x0001_0000"]
398impl crate::Resettable for ControlSpec {
399 const RESET_VALUE: u32 = 0x0001_0000;
400}