da1470x-pac 0.2.0

Peripheral Access Crate (PAC) for DA1470X.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
/*
DISCLAIMER
This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products.
No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all
applicable laws, including copyright laws.
THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED
OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NON-INFRINGEMENT.  ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY
LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT,
INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR
ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability
of this software. By using this software, you agree to the additional terms and conditions found by accessing the
following link:
http://www.renesas.com/disclaimer

*/
// Generated from SVD 1.2, with svd2pac 0.6.0 on Thu, 24 Jul 2025 04:45:52 +0000

#![allow(clippy::identity_op)]
#![allow(clippy::module_inception)]
#![allow(clippy::derivable_impls)]
#[allow(unused_imports)]
use crate::common::sealed;
#[allow(unused_imports)]
use crate::common::*;
#[doc = r"CHG_DET registers"]
unsafe impl ::core::marker::Send for super::ChgDet {}
unsafe impl ::core::marker::Sync for super::ChgDet {}
impl super::ChgDet {
    #[allow(unused)]
    #[inline(always)]
    pub(crate) const fn _svd2pac_as_ptr(&self) -> *mut u8 {
        self.ptr
    }

    #[doc = "Charge detection ADC control register"]
    #[inline(always)]
    pub const fn chg_det_adc_ctrl_reg(
        &self,
    ) -> &'static crate::common::Reg<self::ChgDetAdcCtrlReg_SPEC, crate::common::RW> {
        unsafe {
            crate::common::Reg::<self::ChgDetAdcCtrlReg_SPEC, crate::common::RW>::from_ptr(
                self._svd2pac_as_ptr().add(16usize),
            )
        }
    }

    #[doc = "Charge detection DCD time-out timer register (used in the FSM)"]
    #[inline(always)]
    pub const fn chg_det_dcd_timer_reg(
        &self,
    ) -> &'static crate::common::Reg<self::ChgDetDcdTimerReg_SPEC, crate::common::RW> {
        unsafe {
            crate::common::Reg::<self::ChgDetDcdTimerReg_SPEC, crate::common::RW>::from_ptr(
                self._svd2pac_as_ptr().add(24usize),
            )
        }
    }

    #[doc = "Charge detection FSM control register"]
    #[inline(always)]
    pub const fn chg_det_fsm_ctrl_reg(
        &self,
    ) -> &'static crate::common::Reg<self::ChgDetFsmCtrlReg_SPEC, crate::common::RW> {
        unsafe {
            crate::common::Reg::<self::ChgDetFsmCtrlReg_SPEC, crate::common::RW>::from_ptr(
                self._svd2pac_as_ptr().add(0usize),
            )
        }
    }

    #[doc = "Charge detection FSM status register"]
    #[inline(always)]
    pub const fn chg_det_fsm_status_reg(
        &self,
    ) -> &'static crate::common::Reg<self::ChgDetFsmStatusReg_SPEC, crate::common::RW> {
        unsafe {
            crate::common::Reg::<self::ChgDetFsmStatusReg_SPEC, crate::common::RW>::from_ptr(
                self._svd2pac_as_ptr().add(4usize),
            )
        }
    }

    #[doc = "Charge detection IRQ clear register"]
    #[inline(always)]
    pub const fn chg_det_irq_clear_reg(
        &self,
    ) -> &'static crate::common::Reg<self::ChgDetIrqClearReg_SPEC, crate::common::RW> {
        unsafe {
            crate::common::Reg::<self::ChgDetIrqClearReg_SPEC, crate::common::RW>::from_ptr(
                self._svd2pac_as_ptr().add(36usize),
            )
        }
    }

    #[doc = "Charge detection IRQ mask register"]
    #[inline(always)]
    pub const fn chg_det_irq_mask_reg(
        &self,
    ) -> &'static crate::common::Reg<self::ChgDetIrqMaskReg_SPEC, crate::common::RW> {
        unsafe {
            crate::common::Reg::<self::ChgDetIrqMaskReg_SPEC, crate::common::RW>::from_ptr(
                self._svd2pac_as_ptr().add(28usize),
            )
        }
    }

    #[doc = "Charge detection IRQ status register"]
    #[inline(always)]
    pub const fn chg_det_irq_status_reg(
        &self,
    ) -> &'static crate::common::Reg<self::ChgDetIrqStatusReg_SPEC, crate::common::RW> {
        unsafe {
            crate::common::Reg::<self::ChgDetIrqStatusReg_SPEC, crate::common::RW>::from_ptr(
                self._svd2pac_as_ptr().add(32usize),
            )
        }
    }

    #[doc = "Charge detection status register holding the comparator outputs"]
    #[inline(always)]
    pub const fn chg_det_status_reg(
        &self,
    ) -> &'static crate::common::Reg<self::ChgDetStatusReg_SPEC, crate::common::RW> {
        unsafe {
            crate::common::Reg::<self::ChgDetStatusReg_SPEC, crate::common::RW>::from_ptr(
                self._svd2pac_as_ptr().add(12usize),
            )
        }
    }

    #[doc = "Charge detection manual (SW-based) mode control register"]
    #[inline(always)]
    pub const fn chg_det_sw_ctrl_reg(
        &self,
    ) -> &'static crate::common::Reg<self::ChgDetSwCtrlReg_SPEC, crate::common::RW> {
        unsafe {
            crate::common::Reg::<self::ChgDetSwCtrlReg_SPEC, crate::common::RW>::from_ptr(
                self._svd2pac_as_ptr().add(8usize),
            )
        }
    }

    #[doc = "Charge detection timer register (used in the FSM)"]
    #[inline(always)]
    pub const fn chg_det_timer_reg(
        &self,
    ) -> &'static crate::common::Reg<self::ChgDetTimerReg_SPEC, crate::common::RW> {
        unsafe {
            crate::common::Reg::<self::ChgDetTimerReg_SPEC, crate::common::RW>::from_ptr(
                self._svd2pac_as_ptr().add(20usize),
            )
        }
    }
}
#[doc(hidden)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChgDetAdcCtrlReg_SPEC;
impl crate::sealed::RegSpec for ChgDetAdcCtrlReg_SPEC {
    type DataType = u32;
}

#[doc = "Charge detection ADC control register"]
pub type ChgDetAdcCtrlReg = crate::RegValueT<ChgDetAdcCtrlReg_SPEC>;

impl ChgDetAdcCtrlReg {
    #[doc = "This bit-field determines the mode to be used when the intention is to measure the USB Dp/Dm levels with the GP_ADC. In specific:\n0 = Should be used when the V30 rail is at 3.0V\n1 = Should be used when the V30 rail is at 3.3V"]
    #[inline(always)]
    pub fn adc_v30_sel(
        self,
    ) -> crate::common::RegisterFieldBool<2, 1, 0, ChgDetAdcCtrlReg_SPEC, crate::common::RW> {
        crate::common::RegisterFieldBool::<2,1,0,ChgDetAdcCtrlReg_SPEC,crate::common::RW>::from_register(self,0)
    }

    #[doc = "0 = Disables the connection of USBm to the GP_ADC\n1 = Enables the connection of USBm to the GP_ADC through a relative test switch"]
    #[inline(always)]
    pub fn usb_dm_to_adc_en(
        self,
    ) -> crate::common::RegisterFieldBool<1, 1, 0, ChgDetAdcCtrlReg_SPEC, crate::common::RW> {
        crate::common::RegisterFieldBool::<1,1,0,ChgDetAdcCtrlReg_SPEC,crate::common::RW>::from_register(self,0)
    }

    #[doc = "0 = Disables the connection of USBp to the GP_ADC\n1 = Enables the connection of USBp to the GP_ADC through a relative test switch"]
    #[inline(always)]
    pub fn usb_dp_to_adc_en(
        self,
    ) -> crate::common::RegisterFieldBool<0, 1, 0, ChgDetAdcCtrlReg_SPEC, crate::common::RW> {
        crate::common::RegisterFieldBool::<0,1,0,ChgDetAdcCtrlReg_SPEC,crate::common::RW>::from_register(self,0)
    }
}
impl ::core::default::Default for ChgDetAdcCtrlReg {
    #[inline(always)]
    fn default() -> ChgDetAdcCtrlReg {
        <crate::RegValueT<ChgDetAdcCtrlReg_SPEC> as RegisterValue<_>>::new(0)
    }
}

#[doc(hidden)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChgDetDcdTimerReg_SPEC;
impl crate::sealed::RegSpec for ChgDetDcdTimerReg_SPEC {
    type DataType = u32;
}

#[doc = "Charge detection DCD time-out timer register (used in the FSM)"]
pub type ChgDetDcdTimerReg = crate::RegValueT<ChgDetDcdTimerReg_SPEC>;

impl ChgDetDcdTimerReg {
    #[doc = "This bit-field returns the current value of the DCD time-out timer, also ticking with the 1KHz clock, same as the shared 8-bit timer.\nThe specific timer counts only in states NODE_ATTACHED, WAIT_FOR_DCD and CHECK_FOR_DCD, since these are the states where Data Contact Detection is evaluated.\nThe timer is automatically reloaded with the programmed threshold value (DCD_TIMEOUT_THRES) as soon as the FSM returns to its starting state (WAIT_FOR_ATTACH, 0x0)."]
    #[inline(always)]
    pub fn dcd_timer(
        self,
    ) -> crate::common::RegisterField<
        16,
        0x3ff,
        1,
        0,
        u16,
        u16,
        ChgDetDcdTimerReg_SPEC,
        crate::common::R,
    > {
        crate::common::RegisterField::<
            16,
            0x3ff,
            1,
            0,
            u16,
            u16,
            ChgDetDcdTimerReg_SPEC,
            crate::common::R,
        >::from_register(self, 0)
    }

    #[doc = "This bit-field determines the value from which the Data Contact Detection (DCD) time-out timer starts down-counting, until expiring to zero. Non-zero values are recommended."]
    #[inline(always)]
    pub fn dcd_timeout_thres(
        self,
    ) -> crate::common::RegisterField<
        0,
        0x3ff,
        1,
        0,
        u16,
        u16,
        ChgDetDcdTimerReg_SPEC,
        crate::common::RW,
    > {
        crate::common::RegisterField::<
            0,
            0x3ff,
            1,
            0,
            u16,
            u16,
            ChgDetDcdTimerReg_SPEC,
            crate::common::RW,
        >::from_register(self, 0)
    }
}
impl ::core::default::Default for ChgDetDcdTimerReg {
    #[inline(always)]
    fn default() -> ChgDetDcdTimerReg {
        <crate::RegValueT<ChgDetDcdTimerReg_SPEC> as RegisterValue<_>>::new(39322200)
    }
}

#[doc(hidden)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChgDetFsmCtrlReg_SPEC;
impl crate::sealed::RegSpec for ChgDetFsmCtrlReg_SPEC {
    type DataType = u32;
}

#[doc = "Charge detection FSM control register"]
pub type ChgDetFsmCtrlReg = crate::RegValueT<ChgDetFsmCtrlReg_SPEC>;

impl ChgDetFsmCtrlReg {
    #[doc = "0 = Charge detection FSM is disabled, analog part is controlled through the USB_CHARGER_CTRL_REG register\'s bit-fields.\n1 = Charge detection FSM is enabled and controls the analog part, overruling the content of USB_CHARGER_CTRL_REG."]
    #[inline(always)]
    pub fn chg_det_en(
        self,
    ) -> crate::common::RegisterFieldBool<0, 1, 0, ChgDetFsmCtrlReg_SPEC, crate::common::RW> {
        crate::common::RegisterFieldBool::<0,1,0,ChgDetFsmCtrlReg_SPEC,crate::common::RW>::from_register(self,0)
    }
}
impl ::core::default::Default for ChgDetFsmCtrlReg {
    #[inline(always)]
    fn default() -> ChgDetFsmCtrlReg {
        <crate::RegValueT<ChgDetFsmCtrlReg_SPEC> as RegisterValue<_>>::new(0)
    }
}

#[doc(hidden)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChgDetFsmStatusReg_SPEC;
impl crate::sealed::RegSpec for ChgDetFsmStatusReg_SPEC {
    type DataType = u32;
}

#[doc = "Charge detection FSM status register"]
pub type ChgDetFsmStatusReg = crate::RegValueT<ChgDetFsmStatusReg_SPEC>;

impl ChgDetFsmStatusReg {
    #[doc = "This bit-field returns the current state of the charge detection block\'s FSM. The supported states are:\n  - 0x0 : WAIT_FOR_ATTACH (starting state)\n  - 0x1 : NODE_ATTACHED (USB_DP_VAL first check)\n  - 0x2 : WAIT_FOR_DCD (Data Contact Detection - first state)\n  - 0x3 : CHECK_FOR_DCD (Data Contact Detection - second state)\n  - 0x4 : WAIT_FOR_PCD (Primary Contact Detection - first state)\n  - 0x5 : CHECK_FOR_PCD (Primary Contact Detection - second state)\n  - 0x6 : WAIT_FOR_SCD (Secondary Contact Detection - first state)\n  - 0x7 : CHECK_FOR_SCD (Secondary Contact Detection - second state)\n  - 0x8 : CHG_PORT_DETECTED (terminal state, indicating the port detection\'s completion).\nIt is noted that:\n  - The FSM returns to state WAIT_FOR_ATTACH either when VBUS_AVAILABLE goes to \'0\', or when it is disabled by the SW.\n  - The FSM may return to state WAIT_FOR_ATTACH from any of the other states when VBUS_AVAILABLE goes to \'0\', implying either a USB detach event or a VBUS voltage drop.\n  - The FSM implements a time-out mechanism during the Data Contact Detection phase (NODE_ATTACHED, WAIT_FOR_DCD and CHECK_FOR_DCD states). A dedicated 10-bit timer counts down in any of these states, until USB_DP_VAL is found to be \'0\' (so we have a contact detected) or until it expires.\n  - The time-out timer\'s expiration means that there is no D+/D- pins contact detected within the required time-out period, as defined through CHG_DET_DCD_TIMER_REG and as required by the spec. Even in this case though, the FSM does not abort, but proceeds normally to the next state, which is the first Primary Detection State, to comply with the Battery Charging specification."]
    #[inline(always)]
    pub fn chg_det_state(
        self,
    ) -> crate::common::RegisterField<9, 0xf, 1, 0, u8, u8, ChgDetFsmStatusReg_SPEC, crate::common::R>
    {
        crate::common::RegisterField::<
            9,
            0xf,
            1,
            0,
            u8,
            u8,
            ChgDetFsmStatusReg_SPEC,
            crate::common::R,
        >::from_register(self, 0)
    }

    #[doc = "0 = Contact is sensed on the Dp/Dm (data) pins by the FSM, during the Data Contact Detection (DCD) phase (USB_DP_VAL = 0)\n1 = No contact is sensed on the Dp/Dm pins during the DCD phase (USB_DP_VAL = 1)\nNote: Even in the case of no contact detected on the Dp/Dm pins, the FSM continues with the port detection procedure, moving to the Primary Contact Detection (PCD) states."]
    #[inline(always)]
    pub fn no_contact_detected(
        self,
    ) -> crate::common::RegisterFieldBool<8, 1, 0, ChgDetFsmStatusReg_SPEC, crate::common::R> {
        crate::common::RegisterFieldBool::<8,1,0,ChgDetFsmStatusReg_SPEC,crate::common::R>::from_register(self,0)
    }

    #[doc = "0 = Port detection either not yet finished or finished without detecting a 2.4 Amp charging port\n1 = Port detection has finished by detecting a 2.4 Amp charging port"]
    #[inline(always)]
    pub fn port_2p4amp_detected(
        self,
    ) -> crate::common::RegisterFieldBool<7, 1, 0, ChgDetFsmStatusReg_SPEC, crate::common::R> {
        crate::common::RegisterFieldBool::<7,1,0,ChgDetFsmStatusReg_SPEC,crate::common::R>::from_register(self,0)
    }

    #[doc = "0 = Port detection either not yet finished or finished without detecting a 2 Amp charging port\n1 = Port detection has finished by detecting a 2 Amp charging port"]
    #[inline(always)]
    pub fn port_2amp_detected(
        self,
    ) -> crate::common::RegisterFieldBool<6, 1, 0, ChgDetFsmStatusReg_SPEC, crate::common::R> {
        crate::common::RegisterFieldBool::<6,1,0,ChgDetFsmStatusReg_SPEC,crate::common::R>::from_register(self,0)
    }

    #[doc = "0 = Port detection either not yet finished or finished without detecting a 1 Amp charging port\n1 = Port detection has finished by detecting a 1 Amp charging port"]
    #[inline(always)]
    pub fn port_1amp_detected(
        self,
    ) -> crate::common::RegisterFieldBool<5, 1, 0, ChgDetFsmStatusReg_SPEC, crate::common::R> {
        crate::common::RegisterFieldBool::<5,1,0,ChgDetFsmStatusReg_SPEC,crate::common::R>::from_register(self,0)
    }

    #[doc = "0 = Port detection either not yet finished or finished without detecting a PS2 or a Proprietary charger port\n1 = Port detection has finished by detecting either a PS2 or a Proprietary charger port"]
    #[inline(always)]
    pub fn ps2_prop_port_detected(
        self,
    ) -> crate::common::RegisterFieldBool<4, 1, 0, ChgDetFsmStatusReg_SPEC, crate::common::R> {
        crate::common::RegisterFieldBool::<4,1,0,ChgDetFsmStatusReg_SPEC,crate::common::R>::from_register(self,0)
    }

    #[doc = "0 = Port detection either not yet finished or finished without detecting a DCP port (Dedicated Charging Port)\n1 = Port detection has finished by detecting a DCP port"]
    #[inline(always)]
    pub fn dcp_port_detected(
        self,
    ) -> crate::common::RegisterFieldBool<3, 1, 0, ChgDetFsmStatusReg_SPEC, crate::common::R> {
        crate::common::RegisterFieldBool::<3,1,0,ChgDetFsmStatusReg_SPEC,crate::common::R>::from_register(self,0)
    }

    #[doc = "0 = Port detection either not yet finished or finished without detecting a CDP port (Charging Downstream Port)\n1 = Port detection has finished by detecting a CDP port"]
    #[inline(always)]
    pub fn cdp_port_detected(
        self,
    ) -> crate::common::RegisterFieldBool<2, 1, 0, ChgDetFsmStatusReg_SPEC, crate::common::R> {
        crate::common::RegisterFieldBool::<2,1,0,ChgDetFsmStatusReg_SPEC,crate::common::R>::from_register(self,0)
    }

    #[doc = "0 = Port detection either not yet finished or finished without detecting an SDP port (Standard Downstream Port)\n1 = Port detection has finished by detecting an SDP port"]
    #[inline(always)]
    pub fn sdp_port_detected(
        self,
    ) -> crate::common::RegisterFieldBool<1, 1, 0, ChgDetFsmStatusReg_SPEC, crate::common::R> {
        crate::common::RegisterFieldBool::<1,1,0,ChgDetFsmStatusReg_SPEC,crate::common::R>::from_register(self,0)
    }

    #[doc = "0 = Port detection not yet finished, FSM still active\n1 = Port detection completed, FSM has reached its terminal state (CHG_PORT_DETECTED). The port type is accessible through the relevant bit-fields of this register."]
    #[inline(always)]
    pub fn detection_completed(
        self,
    ) -> crate::common::RegisterFieldBool<0, 1, 0, ChgDetFsmStatusReg_SPEC, crate::common::R> {
        crate::common::RegisterFieldBool::<0,1,0,ChgDetFsmStatusReg_SPEC,crate::common::R>::from_register(self,0)
    }
}
impl ::core::default::Default for ChgDetFsmStatusReg {
    #[inline(always)]
    fn default() -> ChgDetFsmStatusReg {
        <crate::RegValueT<ChgDetFsmStatusReg_SPEC> as RegisterValue<_>>::new(0)
    }
}

#[doc(hidden)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChgDetIrqClearReg_SPEC;
impl crate::sealed::RegSpec for ChgDetIrqClearReg_SPEC {
    type DataType = u32;
}

#[doc = "Charge detection IRQ clear register"]
pub type ChgDetIrqClearReg = crate::RegValueT<ChgDetIrqClearReg_SPEC>;

impl ChgDetIrqClearReg {
    #[doc = "Writing any value to this register clears the charge detection IRQ, reading always returns zero."]
    #[inline(always)]
    pub fn chg_det_irq_clr(
        self,
    ) -> crate::common::RegisterFieldBool<0, 1, 0, ChgDetIrqClearReg_SPEC, crate::common::W> {
        crate::common::RegisterFieldBool::<0,1,0,ChgDetIrqClearReg_SPEC,crate::common::W>::from_register(self,0)
    }
}
impl ::core::default::Default for ChgDetIrqClearReg {
    #[inline(always)]
    fn default() -> ChgDetIrqClearReg {
        <crate::RegValueT<ChgDetIrqClearReg_SPEC> as RegisterValue<_>>::new(0)
    }
}

#[doc(hidden)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChgDetIrqMaskReg_SPEC;
impl crate::sealed::RegSpec for ChgDetIrqMaskReg_SPEC {
    type DataType = u32;
}

#[doc = "Charge detection IRQ mask register"]
pub type ChgDetIrqMaskReg = crate::RegValueT<ChgDetIrqMaskReg_SPEC>;

impl ChgDetIrqMaskReg {
    #[doc = "0 = Charge detection block\'s IRQ generation is disabled, interrupts to Cortex-M33 are masked.\n1 = Charge detection block\'s IRQ generation is enabled."]
    #[inline(always)]
    pub fn chg_det_irq_en(
        self,
    ) -> crate::common::RegisterFieldBool<0, 1, 0, ChgDetIrqMaskReg_SPEC, crate::common::RW> {
        crate::common::RegisterFieldBool::<0,1,0,ChgDetIrqMaskReg_SPEC,crate::common::RW>::from_register(self,0)
    }
}
impl ::core::default::Default for ChgDetIrqMaskReg {
    #[inline(always)]
    fn default() -> ChgDetIrqMaskReg {
        <crate::RegValueT<ChgDetIrqMaskReg_SPEC> as RegisterValue<_>>::new(0)
    }
}

#[doc(hidden)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChgDetIrqStatusReg_SPEC;
impl crate::sealed::RegSpec for ChgDetIrqStatusReg_SPEC {
    type DataType = u32;
}

#[doc = "Charge detection IRQ status register"]
pub type ChgDetIrqStatusReg = crate::RegValueT<ChgDetIrqStatusReg_SPEC>;

impl ChgDetIrqStatusReg {
    #[doc = "0 = No new charge detection IRQ has been generated.\n1 = A new charge detection IRQ is generated and should be cleared by SW, by writing to CHG_DET_IRQ_CLEAR_REG (interrupt is level-sensitive)."]
    #[inline(always)]
    pub fn chg_det_irq(
        self,
    ) -> crate::common::RegisterFieldBool<0, 1, 0, ChgDetIrqStatusReg_SPEC, crate::common::R> {
        crate::common::RegisterFieldBool::<0,1,0,ChgDetIrqStatusReg_SPEC,crate::common::R>::from_register(self,0)
    }
}
impl ::core::default::Default for ChgDetIrqStatusReg {
    #[inline(always)]
    fn default() -> ChgDetIrqStatusReg {
        <crate::RegValueT<ChgDetIrqStatusReg_SPEC> as RegisterValue<_>>::new(0)
    }
}

#[doc(hidden)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChgDetStatusReg_SPEC;
impl crate::sealed::RegSpec for ChgDetStatusReg_SPEC {
    type DataType = u32;
}

#[doc = "Charge detection status register holding the comparator outputs"]
pub type ChgDetStatusReg = crate::RegValueT<ChgDetStatusReg_SPEC>;

impl ChgDetStatusReg {
    #[doc = "0: USBp < 2.3V\n1: USBp > 2.5V"]
    #[inline(always)]
    pub fn usb_dm_val2(
        self,
    ) -> crate::common::RegisterFieldBool<5, 1, 0, ChgDetStatusReg_SPEC, crate::common::R> {
        crate::common::RegisterFieldBool::<5,1,0,ChgDetStatusReg_SPEC,crate::common::R>::from_register(self,0)
    }

    #[doc = "0: USBp < 2.3V\n1: USBp > 2.5V"]
    #[inline(always)]
    pub fn usb_dp_val2(
        self,
    ) -> crate::common::RegisterFieldBool<4, 1, 0, ChgDetStatusReg_SPEC, crate::common::R> {
        crate::common::RegisterFieldBool::<4,1,0,ChgDetStatusReg_SPEC,crate::common::R>::from_register(self,0)
    }

    #[doc = "0 = USBm < 0.8V\n1 = USBm > 1.5V (PS2 or Proprietary Charger)"]
    #[inline(always)]
    pub fn usb_dm_val(
        self,
    ) -> crate::common::RegisterFieldBool<3, 1, 0, ChgDetStatusReg_SPEC, crate::common::R> {
        crate::common::RegisterFieldBool::<3,1,0,ChgDetStatusReg_SPEC,crate::common::R>::from_register(self,0)
    }

    #[doc = "0 = USBp < 0.8V\n1 = USBp > 1.5V (PS2 or Proprietary Charger)"]
    #[inline(always)]
    pub fn usb_dp_val(
        self,
    ) -> crate::common::RegisterFieldBool<2, 1, 0, ChgDetStatusReg_SPEC, crate::common::R> {
        crate::common::RegisterFieldBool::<2,1,0,ChgDetStatusReg_SPEC,crate::common::R>::from_register(self,0)
    }

    #[doc = "0 = Standard Downstream Port (SDP) or no Dp/Dm contact detected (nothing connected)\n1 = Charging Downstream Port (CDP) or Dedicated Charging Port (DCP)"]
    #[inline(always)]
    pub fn usb_chg_det(
        self,
    ) -> crate::common::RegisterFieldBool<1, 1, 0, ChgDetStatusReg_SPEC, crate::common::R> {
        crate::common::RegisterFieldBool::<1,1,0,ChgDetStatusReg_SPEC,crate::common::R>::from_register(self,0)
    }

    #[doc = "0 = Charging downstream port is detected\n1 = Dedicated charger is detected\nIt is noted that the control bit VDM_SRC_ON must be set to validate this status bit. \nNote: This register shows the actual status."]
    #[inline(always)]
    pub fn usb_dcp_det(
        self,
    ) -> crate::common::RegisterFieldBool<0, 1, 0, ChgDetStatusReg_SPEC, crate::common::R> {
        crate::common::RegisterFieldBool::<0,1,0,ChgDetStatusReg_SPEC,crate::common::R>::from_register(self,0)
    }
}
impl ::core::default::Default for ChgDetStatusReg {
    #[inline(always)]
    fn default() -> ChgDetStatusReg {
        <crate::RegValueT<ChgDetStatusReg_SPEC> as RegisterValue<_>>::new(0)
    }
}

#[doc(hidden)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChgDetSwCtrlReg_SPEC;
impl crate::sealed::RegSpec for ChgDetSwCtrlReg_SPEC {
    type DataType = u32;
}

#[doc = "Charge detection manual (SW-based) mode control register"]
pub type ChgDetSwCtrlReg = crate::RegValueT<ChgDetSwCtrlReg_SPEC>;

impl ChgDetSwCtrlReg {
    #[doc = "0 = Disables the Idm_sink to USBm\n1 = Enables the Idm_sink to USBm"]
    #[inline(always)]
    pub fn idm_sink_on(
        self,
    ) -> crate::common::RegisterFieldBool<5, 1, 0, ChgDetSwCtrlReg_SPEC, crate::common::RW> {
        crate::common::RegisterFieldBool::<5,1,0,ChgDetSwCtrlReg_SPEC,crate::common::RW>::from_register(self,0)
    }

    #[doc = "0 = Disables the Idp_sink to USBp\n1 = Enables the Idp_sink to USBp"]
    #[inline(always)]
    pub fn idp_sink_on(
        self,
    ) -> crate::common::RegisterFieldBool<4, 1, 0, ChgDetSwCtrlReg_SPEC, crate::common::RW> {
        crate::common::RegisterFieldBool::<4,1,0,ChgDetSwCtrlReg_SPEC,crate::common::RW>::from_register(self,0)
    }

    #[doc = "0 = Disables the Vdm_src\n1 = Enables the Vdm to USBm and also the USB_DCP_DET status bit"]
    #[inline(always)]
    pub fn vdm_src_on(
        self,
    ) -> crate::common::RegisterFieldBool<3, 1, 0, ChgDetSwCtrlReg_SPEC, crate::common::RW> {
        crate::common::RegisterFieldBool::<3,1,0,ChgDetSwCtrlReg_SPEC,crate::common::RW>::from_register(self,0)
    }

    #[doc = "0 = Disables the Vdp_src\n1 = Enables the Vdp_src and also the USB_CHG_DET status bit"]
    #[inline(always)]
    pub fn vdp_src_on(
        self,
    ) -> crate::common::RegisterFieldBool<2, 1, 0, ChgDetSwCtrlReg_SPEC, crate::common::RW> {
        crate::common::RegisterFieldBool::<2,1,0,ChgDetSwCtrlReg_SPEC,crate::common::RW>::from_register(self,0)
    }

    #[doc = "0 = Disables the Idp_src and the Rdm_dwn\n1 = Enables the Idp_src and the Rdm_dwn"]
    #[inline(always)]
    pub fn idp_src_on(
        self,
    ) -> crate::common::RegisterFieldBool<1, 1, 0, ChgDetSwCtrlReg_SPEC, crate::common::RW> {
        crate::common::RegisterFieldBool::<1,1,0,ChgDetSwCtrlReg_SPEC,crate::common::RW>::from_register(self,0)
    }

    #[doc = "0 = Disables the charge detection analog circuit\n1 = Enables the charge detection analog circuit"]
    #[inline(always)]
    pub fn usb_charge_on(
        self,
    ) -> crate::common::RegisterFieldBool<0, 1, 0, ChgDetSwCtrlReg_SPEC, crate::common::RW> {
        crate::common::RegisterFieldBool::<0,1,0,ChgDetSwCtrlReg_SPEC,crate::common::RW>::from_register(self,0)
    }
}
impl ::core::default::Default for ChgDetSwCtrlReg {
    #[inline(always)]
    fn default() -> ChgDetSwCtrlReg {
        <crate::RegValueT<ChgDetSwCtrlReg_SPEC> as RegisterValue<_>>::new(0)
    }
}

#[doc(hidden)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChgDetTimerReg_SPEC;
impl crate::sealed::RegSpec for ChgDetTimerReg_SPEC {
    type DataType = u32;
}

#[doc = "Charge detection timer register (used in the FSM)"]
pub type ChgDetTimerReg = crate::RegValueT<ChgDetTimerReg_SPEC>;

impl ChgDetTimerReg {
    #[doc = "This bit-field returns the current value of the charge detection timer, which is used by the FSM and which down-counts with a clock of 1KHz. The specific clock is enabled by setting the CLK_SYS_REG\\[CLK_CHG_EN\\] bit-field to \'1\' and it is the same clock used by the Charger\'s digital block.\nThe specific timer is automatically re-loaded with the programmed threshold value (CHG_DET_TIMER_THRES), upon expiring to zero or when the charge detection FSM moves to the state NODE_ATTACHED (0x1)."]
    #[inline(always)]
    pub fn chg_det_timer(
        self,
    ) -> crate::common::RegisterField<16, 0xff, 1, 0, u8, u8, ChgDetTimerReg_SPEC, crate::common::R>
    {
        crate::common::RegisterField::<16,0xff,1,0,u8,u8,ChgDetTimerReg_SPEC,crate::common::R>::from_register(self,0)
    }

    #[doc = "This bit-field determines the value from which the charge detection timer starts down-counting, until expiring to zero. Non-zero values are recommended."]
    #[inline(always)]
    pub fn chg_det_timer_thres(
        self,
    ) -> crate::common::RegisterField<0, 0xff, 1, 0, u8, u8, ChgDetTimerReg_SPEC, crate::common::RW>
    {
        crate::common::RegisterField::<0,0xff,1,0,u8,u8,ChgDetTimerReg_SPEC,crate::common::RW>::from_register(self,0)
    }
}
impl ::core::default::Default for ChgDetTimerReg {
    #[inline(always)]
    fn default() -> ChgDetTimerReg {
        <crate::RegValueT<ChgDetTimerReg_SPEC> as RegisterValue<_>>::new(3276850)
    }
}