hk32f005-pac 0.1.0

HK32F005 PAC, Generate by Chiptool
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
#[doc = "CFGR"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cfgr(pub u32);
impl Cfgr {
    #[doc = "Comparator power mode selection bit"]
    #[must_use]
    #[inline(always)]
    pub const fn iop(&self) -> bool {
        let val = (self.0 >> 0usize) & 0x01;
        val != 0
    }
    #[doc = "Comparator power mode selection bit"]
    #[inline(always)]
    pub const fn set_iop(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
    }
    #[doc = "Built-in voltage divider circuit output range selection configuration bit"]
    #[must_use]
    #[inline(always)]
    pub const fn os(&self) -> u8 {
        let val = (self.0 >> 11usize) & 0x07;
        val as u8
    }
    #[doc = "Built-in voltage divider circuit output range selection configuration bit"]
    #[inline(always)]
    pub const fn set_os(&mut self, val: u8) {
        self.0 = (self.0 & !(0x07 << 11usize)) | (((val as u32) & 0x07) << 11usize);
    }
    #[doc = "Built-in voltage divider circuit voltage selection configuration bit"]
    #[must_use]
    #[inline(always)]
    pub const fn ps(&self) -> bool {
        let val = (self.0 >> 14usize) & 0x01;
        val != 0
    }
    #[doc = "Built-in voltage divider circuit voltage selection configuration bit"]
    #[inline(always)]
    pub const fn set_ps(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
    }
    #[doc = "Resistance partial voltage enable bit"]
    #[must_use]
    #[inline(always)]
    pub const fn div_en(&self) -> bool {
        let val = (self.0 >> 15usize) & 0x01;
        val != 0
    }
    #[doc = "Resistance partial voltage enable bit"]
    #[inline(always)]
    pub const fn set_div_en(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
    }
    #[doc = "Window function enable bit"]
    #[must_use]
    #[inline(always)]
    pub const fn winen(&self) -> bool {
        let val = (self.0 >> 16usize) & 0x01;
        val != 0
    }
    #[doc = "Window function enable bit"]
    #[inline(always)]
    pub const fn set_winen(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
    }
    #[doc = "Window function output status bit"]
    #[must_use]
    #[inline(always)]
    pub const fn winout(&self) -> bool {
        let val = (self.0 >> 17usize) & 0x01;
        val != 0
    }
    #[doc = "Window function output status bit"]
    #[inline(always)]
    pub const fn set_winout(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
    }
}
impl Default for Cfgr {
    #[inline(always)]
    fn default() -> Cfgr {
        Cfgr(0)
    }
}
impl core::fmt::Debug for Cfgr {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("Cfgr")
            .field("iop", &self.iop())
            .field("os", &self.os())
            .field("ps", &self.ps())
            .field("div_en", &self.div_en())
            .field("winen", &self.winen())
            .field("winout", &self.winout())
            .finish()
    }
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cfgr {
    fn format(&self, f: defmt::Formatter) {
        defmt :: write ! (f , "Cfgr {{ iop: {=bool:?}, os: {=u8:?}, ps: {=bool:?}, div_en: {=bool:?}, winen: {=bool:?}, winout: {=bool:?} }}" , self . iop () , self . os () , self . ps () , self . div_en () , self . winen () , self . winout ())
    }
}
#[doc = "CSR1"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Csr1(pub u32);
impl Csr1 {
    #[doc = "Comparator 1 enable bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp1en(&self) -> bool {
        let val = (self.0 >> 0usize) & 0x01;
        val != 0
    }
    #[doc = "Comparator 1 enable bit"]
    #[inline(always)]
    pub const fn set_comp1en(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
    }
    #[doc = "Comparator 1 hysteresis voltage selection bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp1hys(&self) -> bool {
        let val = (self.0 >> 1usize) & 0x01;
        val != 0
    }
    #[doc = "Comparator 1 hysteresis voltage selection bit"]
    #[inline(always)]
    pub const fn set_comp1hys(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
    }
    #[doc = "Comparator 1 negative input connection configuration bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp1innsel(&self) -> u8 {
        let val = (self.0 >> 4usize) & 0x0f;
        val as u8
    }
    #[doc = "Comparator 1 negative input connection configuration bit"]
    #[inline(always)]
    pub const fn set_comp1innsel(&mut self, val: u8) {
        self.0 = (self.0 & !(0x0f << 4usize)) | (((val as u32) & 0x0f) << 4usize);
    }
    #[doc = "Comparator 1 positive input connection configuration bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp1inpsel(&self) -> u8 {
        let val = (self.0 >> 8usize) & 0x07;
        val as u8
    }
    #[doc = "Comparator 1 positive input connection configuration bit"]
    #[inline(always)]
    pub const fn set_comp1inpsel(&mut self, val: u8) {
        self.0 = (self.0 & !(0x07 << 8usize)) | (((val as u32) & 0x07) << 8usize);
    }
    #[doc = "Comparator 1 polarity selection bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp1polarity(&self) -> bool {
        let val = (self.0 >> 15usize) & 0x01;
        val != 0
    }
    #[doc = "Comparator 1 polarity selection bit"]
    #[inline(always)]
    pub const fn set_comp1polarity(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
    }
    #[doc = "Comparator 1 dead time selection bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp1dt_sel(&self) -> u8 {
        let val = (self.0 >> 16usize) & 0x03;
        val as u8
    }
    #[doc = "Comparator 1 dead time selection bit"]
    #[inline(always)]
    pub const fn set_comp1dt_sel(&mut self, val: u8) {
        self.0 = (self.0 & !(0x03 << 16usize)) | (((val as u32) & 0x03) << 16usize);
    }
    #[doc = "Comparator 1 filter enable bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp1flten(&self) -> bool {
        let val = (self.0 >> 20usize) & 0x01;
        val != 0
    }
    #[doc = "Comparator 1 filter enable bit"]
    #[inline(always)]
    pub const fn set_comp1flten(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 20usize)) | (((val as u32) & 0x01) << 20usize);
    }
    #[doc = "Comparator 1 filter clock selection bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp1fltcksel(&self) -> bool {
        let val = (self.0 >> 21usize) & 0x01;
        val != 0
    }
    #[doc = "Comparator 1 filter clock selection bit"]
    #[inline(always)]
    pub const fn set_comp1fltcksel(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 21usize)) | (((val as u32) & 0x01) << 21usize);
    }
    #[doc = "Comparator 1 filter sampling clock division configuration bits"]
    #[must_use]
    #[inline(always)]
    pub const fn comp1fltclkdiv(&self) -> u8 {
        let val = (self.0 >> 22usize) & 0x07;
        val as u8
    }
    #[doc = "Comparator 1 filter sampling clock division configuration bits"]
    #[inline(always)]
    pub const fn set_comp1fltclkdiv(&mut self, val: u8) {
        self.0 = (self.0 & !(0x07 << 22usize)) | (((val as u32) & 0x07) << 22usize);
    }
    #[doc = "Comparator 1 filter time configuration bits"]
    #[must_use]
    #[inline(always)]
    pub const fn comp1flttime(&self) -> u8 {
        let val = (self.0 >> 25usize) & 0x03;
        val as u8
    }
    #[doc = "Comparator 1 filter time configuration bits"]
    #[inline(always)]
    pub const fn set_comp1flttime(&mut self, val: u8) {
        self.0 = (self.0 & !(0x03 << 25usize)) | (((val as u32) & 0x03) << 25usize);
    }
    #[doc = "Comparator 1 output status bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp1value(&self) -> bool {
        let val = (self.0 >> 30usize) & 0x01;
        val != 0
    }
    #[doc = "Comparator 1 output status bit"]
    #[inline(always)]
    pub const fn set_comp1value(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 30usize)) | (((val as u32) & 0x01) << 30usize);
    }
    #[doc = "COMP1_CSR register lock bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp1lock(&self) -> bool {
        let val = (self.0 >> 31usize) & 0x01;
        val != 0
    }
    #[doc = "COMP1_CSR register lock bit"]
    #[inline(always)]
    pub const fn set_comp1lock(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize);
    }
}
impl Default for Csr1 {
    #[inline(always)]
    fn default() -> Csr1 {
        Csr1(0)
    }
}
impl core::fmt::Debug for Csr1 {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("Csr1")
            .field("comp1en", &self.comp1en())
            .field("comp1hys", &self.comp1hys())
            .field("comp1innsel", &self.comp1innsel())
            .field("comp1inpsel", &self.comp1inpsel())
            .field("comp1polarity", &self.comp1polarity())
            .field("comp1dt_sel", &self.comp1dt_sel())
            .field("comp1flten", &self.comp1flten())
            .field("comp1fltcksel", &self.comp1fltcksel())
            .field("comp1fltclkdiv", &self.comp1fltclkdiv())
            .field("comp1flttime", &self.comp1flttime())
            .field("comp1value", &self.comp1value())
            .field("comp1lock", &self.comp1lock())
            .finish()
    }
}
#[cfg(feature = "defmt")]
impl defmt::Format for Csr1 {
    fn format(&self, f: defmt::Formatter) {
        defmt :: write ! (f , "Csr1 {{ comp1en: {=bool:?}, comp1hys: {=bool:?}, comp1innsel: {=u8:?}, comp1inpsel: {=u8:?}, comp1polarity: {=bool:?}, comp1dt_sel: {=u8:?}, comp1flten: {=bool:?}, comp1fltcksel: {=bool:?}, comp1fltclkdiv: {=u8:?}, comp1flttime: {=u8:?}, comp1value: {=bool:?}, comp1lock: {=bool:?} }}" , self . comp1en () , self . comp1hys () , self . comp1innsel () , self . comp1inpsel () , self . comp1polarity () , self . comp1dt_sel () , self . comp1flten () , self . comp1fltcksel () , self . comp1fltclkdiv () , self . comp1flttime () , self . comp1value () , self . comp1lock ())
    }
}
#[doc = "CSR2"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Csr2(pub u32);
impl Csr2 {
    #[doc = "Comparator 2 enable bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp2en(&self) -> bool {
        let val = (self.0 >> 0usize) & 0x01;
        val != 0
    }
    #[doc = "Comparator 2 enable bit"]
    #[inline(always)]
    pub const fn set_comp2en(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
    }
    #[doc = "Comparator 2 hysteresis voltage selector bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp2hys(&self) -> bool {
        let val = (self.0 >> 1usize) & 0x01;
        val != 0
    }
    #[doc = "Comparator 2 hysteresis voltage selector bit"]
    #[inline(always)]
    pub const fn set_comp2hys(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
    }
    #[doc = "Comparator 2 negative input connection configuration bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp2innsel(&self) -> u8 {
        let val = (self.0 >> 4usize) & 0x0f;
        val as u8
    }
    #[doc = "Comparator 2 negative input connection configuration bit"]
    #[inline(always)]
    pub const fn set_comp2innsel(&mut self, val: u8) {
        self.0 = (self.0 & !(0x0f << 4usize)) | (((val as u32) & 0x0f) << 4usize);
    }
    #[doc = "Comparator 2 positive input connection configuration bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp2inpsel(&self) -> u8 {
        let val = (self.0 >> 8usize) & 0x07;
        val as u8
    }
    #[doc = "Comparator 2 positive input connection configuration bit"]
    #[inline(always)]
    pub const fn set_comp2inpsel(&mut self, val: u8) {
        self.0 = (self.0 & !(0x07 << 8usize)) | (((val as u32) & 0x07) << 8usize);
    }
    #[doc = "Comparator 2 polarity selection bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp2polarity(&self) -> bool {
        let val = (self.0 >> 15usize) & 0x01;
        val != 0
    }
    #[doc = "Comparator 2 polarity selection bit"]
    #[inline(always)]
    pub const fn set_comp2polarity(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
    }
    #[doc = "Comparator 2 dead time selection bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp2dt_sel(&self) -> u8 {
        let val = (self.0 >> 16usize) & 0x03;
        val as u8
    }
    #[doc = "Comparator 2 dead time selection bit"]
    #[inline(always)]
    pub const fn set_comp2dt_sel(&mut self, val: u8) {
        self.0 = (self.0 & !(0x03 << 16usize)) | (((val as u32) & 0x03) << 16usize);
    }
    #[doc = "Comparator 2 filter enable bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp2flten(&self) -> bool {
        let val = (self.0 >> 20usize) & 0x01;
        val != 0
    }
    #[doc = "Comparator 2 filter enable bit"]
    #[inline(always)]
    pub const fn set_comp2flten(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 20usize)) | (((val as u32) & 0x01) << 20usize);
    }
    #[doc = "Comparator 2 filter clock selection bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp2fltcksel(&self) -> bool {
        let val = (self.0 >> 21usize) & 0x01;
        val != 0
    }
    #[doc = "Comparator 2 filter clock selection bit"]
    #[inline(always)]
    pub const fn set_comp2fltcksel(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 21usize)) | (((val as u32) & 0x01) << 21usize);
    }
    #[doc = "Comparator 2 filter sampling clock division configuration bits"]
    #[must_use]
    #[inline(always)]
    pub const fn comp2fltclkdiv(&self) -> u8 {
        let val = (self.0 >> 22usize) & 0x07;
        val as u8
    }
    #[doc = "Comparator 2 filter sampling clock division configuration bits"]
    #[inline(always)]
    pub const fn set_comp2fltclkdiv(&mut self, val: u8) {
        self.0 = (self.0 & !(0x07 << 22usize)) | (((val as u32) & 0x07) << 22usize);
    }
    #[doc = "Comparator 2 filter time configuration bits"]
    #[must_use]
    #[inline(always)]
    pub const fn comp2flttime(&self) -> u8 {
        let val = (self.0 >> 25usize) & 0x03;
        val as u8
    }
    #[doc = "Comparator 2 filter time configuration bits"]
    #[inline(always)]
    pub const fn set_comp2flttime(&mut self, val: u8) {
        self.0 = (self.0 & !(0x03 << 25usize)) | (((val as u32) & 0x03) << 25usize);
    }
    #[doc = "Comparator 2 output status bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp2value(&self) -> bool {
        let val = (self.0 >> 30usize) & 0x01;
        val != 0
    }
    #[doc = "Comparator 2 output status bit"]
    #[inline(always)]
    pub const fn set_comp2value(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 30usize)) | (((val as u32) & 0x01) << 30usize);
    }
    #[doc = "COMP2_CSR register lock bit"]
    #[must_use]
    #[inline(always)]
    pub const fn comp2lock(&self) -> bool {
        let val = (self.0 >> 31usize) & 0x01;
        val != 0
    }
    #[doc = "COMP2_CSR register lock bit"]
    #[inline(always)]
    pub const fn set_comp2lock(&mut self, val: bool) {
        self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize);
    }
}
impl Default for Csr2 {
    #[inline(always)]
    fn default() -> Csr2 {
        Csr2(0)
    }
}
impl core::fmt::Debug for Csr2 {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("Csr2")
            .field("comp2en", &self.comp2en())
            .field("comp2hys", &self.comp2hys())
            .field("comp2innsel", &self.comp2innsel())
            .field("comp2inpsel", &self.comp2inpsel())
            .field("comp2polarity", &self.comp2polarity())
            .field("comp2dt_sel", &self.comp2dt_sel())
            .field("comp2flten", &self.comp2flten())
            .field("comp2fltcksel", &self.comp2fltcksel())
            .field("comp2fltclkdiv", &self.comp2fltclkdiv())
            .field("comp2flttime", &self.comp2flttime())
            .field("comp2value", &self.comp2value())
            .field("comp2lock", &self.comp2lock())
            .finish()
    }
}
#[cfg(feature = "defmt")]
impl defmt::Format for Csr2 {
    fn format(&self, f: defmt::Formatter) {
        defmt :: write ! (f , "Csr2 {{ comp2en: {=bool:?}, comp2hys: {=bool:?}, comp2innsel: {=u8:?}, comp2inpsel: {=u8:?}, comp2polarity: {=bool:?}, comp2dt_sel: {=u8:?}, comp2flten: {=bool:?}, comp2fltcksel: {=bool:?}, comp2fltclkdiv: {=u8:?}, comp2flttime: {=u8:?}, comp2value: {=bool:?}, comp2lock: {=bool:?} }}" , self . comp2en () , self . comp2hys () , self . comp2innsel () , self . comp2inpsel () , self . comp2polarity () , self . comp2dt_sel () , self . comp2flten () , self . comp2fltcksel () , self . comp2fltclkdiv () , self . comp2flttime () , self . comp2value () , self . comp2lock ())
    }
}