stm32l4x2_pac/can1/
fmr.rs

1#[doc = r" Value read from the register"]
2pub struct R {
3    bits: u32,
4}
5#[doc = r" Value to write to the register"]
6pub struct W {
7    bits: u32,
8}
9impl super::FMR {
10    #[doc = r" Modifies the contents of the register"]
11    #[inline]
12    pub fn modify<F>(&self, f: F)
13    where
14        for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
15    {
16        let bits = self.register.get();
17        let r = R { bits: bits };
18        let mut w = W { bits: bits };
19        f(&r, &mut w);
20        self.register.set(w.bits);
21    }
22    #[doc = r" Reads the contents of the register"]
23    #[inline]
24    pub fn read(&self) -> R {
25        R {
26            bits: self.register.get(),
27        }
28    }
29    #[doc = r" Writes to the register"]
30    #[inline]
31    pub fn write<F>(&self, f: F)
32    where
33        F: FnOnce(&mut W) -> &mut W,
34    {
35        let mut w = W::reset_value();
36        f(&mut w);
37        self.register.set(w.bits);
38    }
39    #[doc = r" Writes the reset value to the register"]
40    #[inline]
41    pub fn reset(&self) {
42        self.write(|w| w)
43    }
44}
45#[doc = r" Value of the field"]
46pub struct FINITR {
47    bits: bool,
48}
49impl FINITR {
50    #[doc = r" Value of the field as raw bits"]
51    #[inline]
52    pub fn bit(&self) -> bool {
53        self.bits
54    }
55    #[doc = r" Returns `true` if the bit is clear (0)"]
56    #[inline]
57    pub fn bit_is_clear(&self) -> bool {
58        !self.bit()
59    }
60    #[doc = r" Returns `true` if the bit is set (1)"]
61    #[inline]
62    pub fn bit_is_set(&self) -> bool {
63        self.bit()
64    }
65}
66#[doc = r" Proxy"]
67pub struct _FINITW<'a> {
68    w: &'a mut W,
69}
70impl<'a> _FINITW<'a> {
71    #[doc = r" Sets the field bit"]
72    pub fn set_bit(self) -> &'a mut W {
73        self.bit(true)
74    }
75    #[doc = r" Clears the field bit"]
76    pub fn clear_bit(self) -> &'a mut W {
77        self.bit(false)
78    }
79    #[doc = r" Writes raw bits to the field"]
80    #[inline]
81    pub fn bit(self, value: bool) -> &'a mut W {
82        const MASK: bool = true;
83        const OFFSET: u8 = 0;
84        self.w.bits &= !((MASK as u32) << OFFSET);
85        self.w.bits |= ((value & MASK) as u32) << OFFSET;
86        self.w
87    }
88}
89impl R {
90    #[doc = r" Value of the register as raw bits"]
91    #[inline]
92    pub fn bits(&self) -> u32 {
93        self.bits
94    }
95    #[doc = "Bit 0 - Filter initialization mode"]
96    #[inline]
97    pub fn finit(&self) -> FINITR {
98        let bits = {
99            const MASK: bool = true;
100            const OFFSET: u8 = 0;
101            ((self.bits >> OFFSET) & MASK as u32) != 0
102        };
103        FINITR { bits }
104    }
105}
106impl W {
107    #[doc = r" Reset value of the register"]
108    #[inline]
109    pub fn reset_value() -> W {
110        W { bits: 706481665 }
111    }
112    #[doc = r" Writes raw bits to the register"]
113    #[inline]
114    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
115        self.bits = bits;
116        self
117    }
118    #[doc = "Bit 0 - Filter initialization mode"]
119    #[inline]
120    pub fn finit(&mut self) -> _FINITW {
121        _FINITW { w: self }
122    }
123}