๐Ÿ“ฆ samueltardieu / stm32-metapac-generated

๐Ÿ“„ comp_v2.rs ยท 77 lines
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#![allow(clippy::missing_safety_doc)]
                #![allow(clippy::identity_op)]
                #![allow(clippy::unnecessary_cast)]
                #![allow(clippy::erasing_op)]

# [doc = "Comparator v2. (RM0440 24)"]
# [derive (Copy , Clone , Eq , PartialEq)]
pub struct Comp { ptr : * mut u8 } unsafe impl Send for Comp { } unsafe impl Sync for Comp { } impl Comp { # [inline (always)]
pub const unsafe fn from_ptr (ptr : * mut ()) -> Self { Self { ptr : ptr as _ , } } # [inline (always)]
pub const fn as_ptr (& self) -> * mut () { self . ptr as _ } # [doc = "Comparator control and status register."]
# [inline (always)]
pub const fn csr (self) -> crate :: common :: Reg < regs :: Csr , crate :: common :: RW > { unsafe { crate :: common :: Reg :: from_ptr (self . ptr . add (0x0usize) as _) } } } pub mod regs { # [doc = "Comparator control and status register."]
# [repr (transparent)]
# [derive (Copy , Clone , Eq , PartialEq)]
pub struct Csr (pub u32) ; impl Csr { # [doc = "COMP enable bit."]
# [inline (always)]
pub const fn en (& self) -> bool { let val = (self . 0 >> 0usize) & 0x01 ; val != 0 } # [doc = "COMP enable bit."]
# [inline (always)]
pub fn set_en (& mut self , val : bool) { self . 0 = (self . 0 & ! (0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize) ; } # [doc = "Comparator signal selector for inverting input INM. (RM0440 24.3.2 Table 197)"]
# [inline (always)]
pub const fn inmsel (& self) -> u8 { let val = (self . 0 >> 4usize) & 0x07 ; val as u8 } # [doc = "Comparator signal selector for inverting input INM. (RM0440 24.3.2 Table 197)"]
# [inline (always)]
pub fn set_inmsel (& mut self , val : u8) { self . 0 = (self . 0 & ! (0x07 << 4usize)) | (((val as u32) & 0x07) << 4usize) ; } # [doc = "Comparator signal selector for non-inverting input INP. (RM0440 24.3.2 Table 196)"]
# [inline (always)]
pub const fn inpsel (& self) -> bool { let val = (self . 0 >> 8usize) & 0x01 ; val != 0 } # [doc = "Comparator signal selector for non-inverting input INP. (RM0440 24.3.2 Table 196)"]
# [inline (always)]
pub fn set_inpsel (& mut self , val : bool) { self . 0 = (self . 0 & ! (0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize) ; } # [doc = "Comparator polarity selector."]
# [inline (always)]
pub const fn polarity (& self) -> super :: vals :: Polarity { let val = (self . 0 >> 15usize) & 0x01 ; super :: vals :: Polarity :: from_bits (val as u8) } # [doc = "Comparator polarity selector."]
# [inline (always)]
pub fn set_polarity (& mut self , val : super :: vals :: Polarity) { self . 0 = (self . 0 & ! (0x01 << 15usize)) | (((val . to_bits () as u32) & 0x01) << 15usize) ; } # [doc = "Comparator hysteresis selector."]
# [inline (always)]
pub const fn hyst (& self) -> super :: vals :: Hyst { let val = (self . 0 >> 16usize) & 0x07 ; super :: vals :: Hyst :: from_bits (val as u8) } # [doc = "Comparator hysteresis selector."]
# [inline (always)]
pub fn set_hyst (& mut self , val : super :: vals :: Hyst) { self . 0 = (self . 0 & ! (0x07 << 16usize)) | (((val . to_bits () as u32) & 0x07) << 16usize) ; } # [doc = "Comparator blanking source selector. (RM0440 24.3.6 Table 198)"]
# [inline (always)]
pub const fn blanksel (& self) -> u8 { let val = (self . 0 >> 19usize) & 0x07 ; val as u8 } # [doc = "Comparator blanking source selector. (RM0440 24.3.6 Table 198)"]
# [inline (always)]
pub fn set_blanksel (& mut self , val : u8) { self . 0 = (self . 0 & ! (0x07 << 19usize)) | (((val as u32) & 0x07) << 19usize) ; } # [doc = "Vrefint resistor bridge enable. (RM0440 24.6)"]
# [inline (always)]
pub const fn brgen (& self) -> bool { let val = (self . 0 >> 22usize) & 0x01 ; val != 0 } # [doc = "Vrefint resistor bridge enable. (RM0440 24.6)"]
# [inline (always)]
pub fn set_brgen (& mut self , val : bool) { self . 0 = (self . 0 & ! (0x01 << 22usize)) | (((val as u32) & 0x01) << 22usize) ; } # [doc = "Vrefint scaled input enable. (RM0440 24.6)"]
# [inline (always)]
pub const fn scalen (& self) -> bool { let val = (self . 0 >> 23usize) & 0x01 ; val != 0 } # [doc = "Vrefint scaled input enable. (RM0440 24.6)"]
# [inline (always)]
pub fn set_scalen (& mut self , val : bool) { self . 0 = (self . 0 & ! (0x01 << 23usize)) | (((val as u32) & 0x01) << 23usize) ; } # [doc = "Comparator output status. (READ ONLY)"]
# [inline (always)]
pub const fn value_do_not_set (& self) -> bool { let val = (self . 0 >> 30usize) & 0x01 ; val != 0 } # [doc = "Comparator output status. (READ ONLY)"]
# [inline (always)]
pub fn set_value_do_not_set (& mut self , val : bool) { self . 0 = (self . 0 & ! (0x01 << 30usize)) | (((val as u32) & 0x01) << 30usize) ; } # [doc = "CSR register lock."]
# [inline (always)]
pub const fn lock (& self) -> bool { let val = (self . 0 >> 31usize) & 0x01 ; val != 0 } # [doc = "CSR register lock."]
# [inline (always)]
pub fn set_lock (& mut self , val : bool) { self . 0 = (self . 0 & ! (0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize) ; } } impl Default for Csr { # [inline (always)]
fn default () -> Csr { Csr (0) } } } pub mod vals { # [repr (u8)]
# [derive (Copy , Clone , Eq , PartialEq , Ord , PartialOrd)]
pub enum Hyst { NONE = 0x0 , # [doc = "10mV hysteresis"]
HYST10M = 0x01 , # [doc = "20mV hysteresis"]
HYST20M = 0x02 , # [doc = "30mV hysteresis"]
HYST30M = 0x03 , # [doc = "40mV hysteresis"]
HYST40M = 0x04 , # [doc = "50mV hysteresis"]
HYST50M = 0x05 , # [doc = "60mV hysteresis"]
HYST60M = 0x06 , # [doc = "70mV hysteresis"]
HYST70M = 0x07 , } impl Hyst { # [inline (always)]
pub const fn from_bits (val : u8) -> Hyst { unsafe { core :: mem :: transmute (val & 0x07) } } # [inline (always)]
pub const fn to_bits (self) -> u8 { unsafe { core :: mem :: transmute (self) } } } impl From < u8 > for Hyst { # [inline (always)]
fn from (val : u8) -> Hyst { Hyst :: from_bits (val) } } impl From < Hyst > for u8 { # [inline (always)]
fn from (val : Hyst) -> u8 { Hyst :: to_bits (val) } } # [repr (u8)]
# [derive (Copy , Clone , Eq , PartialEq , Ord , PartialOrd)]
pub enum Polarity { # [doc = "Non-inverted polarity"]
NONINVERTED = 0x0 , # [doc = "Inverted polarity"]
INVERTED = 0x01 , } impl Polarity { # [inline (always)]
pub const fn from_bits (val : u8) -> Polarity { unsafe { core :: mem :: transmute (val & 0x01) } } # [inline (always)]
pub const fn to_bits (self) -> u8 { unsafe { core :: mem :: transmute (self) } } } impl From < u8 > for Polarity { # [inline (always)]
fn from (val : u8) -> Polarity { Polarity :: from_bits (val) } } impl From < Polarity > for u8 { # [inline (always)]
fn from (val : Polarity) -> u8 { Polarity :: to_bits (val) } } }