stm32l4x2_pac/i2c1/
oar2.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::OAR2 {
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 OA2R {
47    bits: u8,
48}
49impl OA2R {
50    #[doc = r" Value of the field as raw bits"]
51    #[inline]
52    pub fn bits(&self) -> u8 {
53        self.bits
54    }
55}
56#[doc = "Possible values of the field `OA2MSK`"]
57#[derive(Clone, Copy, Debug, PartialEq)]
58pub enum OA2MSKR {
59    #[doc = "No mask"]
60    NOMASK,
61    #[doc = "OA2\\[1\\] is masked and don\u{2019}t care. Only OA2\\[7:2\\] are compared"]
62    MASK1,
63    #[doc = "OA2\\[2:1\\] are masked and don\u{2019}t care. Only OA2\\[7:3\\] are compared"]
64    MASK2,
65    #[doc = "OA2\\[3:1\\] are masked and don\u{2019}t care. Only OA2\\[7:4\\] are compared"]
66    MASK3,
67    #[doc = "OA2\\[4:1\\] are masked and don\u{2019}t care. Only OA2\\[7:5\\] are compared"]
68    MASK4,
69    #[doc = "OA2\\[5:1\\] are masked and don\u{2019}t care. Only OA2\\[7:6\\] are compared"]
70    MASK5,
71    #[doc = "OA2\\[6:1\\] are masked and don\u{2019}t care. Only OA2\\[7\\] is compared."]
72    MASK6,
73    #[doc = "OA2\\[7:1\\] are masked and don\u{2019}t care. No comparison is done, and all (except reserved) 7-bit received addresses are acknowledged"]
74    MASK7,
75}
76impl OA2MSKR {
77    #[doc = r" Value of the field as raw bits"]
78    #[inline]
79    pub fn bits(&self) -> u8 {
80        match *self {
81            OA2MSKR::NOMASK => 0,
82            OA2MSKR::MASK1 => 1,
83            OA2MSKR::MASK2 => 2,
84            OA2MSKR::MASK3 => 3,
85            OA2MSKR::MASK4 => 4,
86            OA2MSKR::MASK5 => 5,
87            OA2MSKR::MASK6 => 6,
88            OA2MSKR::MASK7 => 7,
89        }
90    }
91    #[allow(missing_docs)]
92    #[doc(hidden)]
93    #[inline]
94    pub fn _from(value: u8) -> OA2MSKR {
95        match value {
96            0 => OA2MSKR::NOMASK,
97            1 => OA2MSKR::MASK1,
98            2 => OA2MSKR::MASK2,
99            3 => OA2MSKR::MASK3,
100            4 => OA2MSKR::MASK4,
101            5 => OA2MSKR::MASK5,
102            6 => OA2MSKR::MASK6,
103            7 => OA2MSKR::MASK7,
104            _ => unreachable!(),
105        }
106    }
107    #[doc = "Checks if the value of the field is `NOMASK`"]
108    #[inline]
109    pub fn is_no_mask(&self) -> bool {
110        *self == OA2MSKR::NOMASK
111    }
112    #[doc = "Checks if the value of the field is `MASK1`"]
113    #[inline]
114    pub fn is_mask1(&self) -> bool {
115        *self == OA2MSKR::MASK1
116    }
117    #[doc = "Checks if the value of the field is `MASK2`"]
118    #[inline]
119    pub fn is_mask2(&self) -> bool {
120        *self == OA2MSKR::MASK2
121    }
122    #[doc = "Checks if the value of the field is `MASK3`"]
123    #[inline]
124    pub fn is_mask3(&self) -> bool {
125        *self == OA2MSKR::MASK3
126    }
127    #[doc = "Checks if the value of the field is `MASK4`"]
128    #[inline]
129    pub fn is_mask4(&self) -> bool {
130        *self == OA2MSKR::MASK4
131    }
132    #[doc = "Checks if the value of the field is `MASK5`"]
133    #[inline]
134    pub fn is_mask5(&self) -> bool {
135        *self == OA2MSKR::MASK5
136    }
137    #[doc = "Checks if the value of the field is `MASK6`"]
138    #[inline]
139    pub fn is_mask6(&self) -> bool {
140        *self == OA2MSKR::MASK6
141    }
142    #[doc = "Checks if the value of the field is `MASK7`"]
143    #[inline]
144    pub fn is_mask7(&self) -> bool {
145        *self == OA2MSKR::MASK7
146    }
147}
148#[doc = "Possible values of the field `OA2EN`"]
149#[derive(Clone, Copy, Debug, PartialEq)]
150pub enum OA2ENR {
151    #[doc = "Own address 2 disabled. The received slave address OA2 is NACKed"]
152    DISABLED,
153    #[doc = "Own address 2 enabled. The received slave address OA2 is ACKed"]
154    ENABLED,
155}
156impl OA2ENR {
157    #[doc = r" Returns `true` if the bit is clear (0)"]
158    #[inline]
159    pub fn bit_is_clear(&self) -> bool {
160        !self.bit()
161    }
162    #[doc = r" Returns `true` if the bit is set (1)"]
163    #[inline]
164    pub fn bit_is_set(&self) -> bool {
165        self.bit()
166    }
167    #[doc = r" Value of the field as raw bits"]
168    #[inline]
169    pub fn bit(&self) -> bool {
170        match *self {
171            OA2ENR::DISABLED => false,
172            OA2ENR::ENABLED => true,
173        }
174    }
175    #[allow(missing_docs)]
176    #[doc(hidden)]
177    #[inline]
178    pub fn _from(value: bool) -> OA2ENR {
179        match value {
180            false => OA2ENR::DISABLED,
181            true => OA2ENR::ENABLED,
182        }
183    }
184    #[doc = "Checks if the value of the field is `DISABLED`"]
185    #[inline]
186    pub fn is_disabled(&self) -> bool {
187        *self == OA2ENR::DISABLED
188    }
189    #[doc = "Checks if the value of the field is `ENABLED`"]
190    #[inline]
191    pub fn is_enabled(&self) -> bool {
192        *self == OA2ENR::ENABLED
193    }
194}
195#[doc = r" Proxy"]
196pub struct _OA2W<'a> {
197    w: &'a mut W,
198}
199impl<'a> _OA2W<'a> {
200    #[doc = r" Writes raw bits to the field"]
201    #[inline]
202    pub fn bits(self, value: u8) -> &'a mut W {
203        const MASK: u8 = 127;
204        const OFFSET: u8 = 1;
205        self.w.bits &= !((MASK as u32) << OFFSET);
206        self.w.bits |= ((value & MASK) as u32) << OFFSET;
207        self.w
208    }
209}
210#[doc = "Values that can be written to the field `OA2MSK`"]
211pub enum OA2MSKW {
212    #[doc = "No mask"]
213    NOMASK,
214    #[doc = "OA2\\[1\\] is masked and don\u{2019}t care. Only OA2\\[7:2\\] are compared"]
215    MASK1,
216    #[doc = "OA2\\[2:1\\] are masked and don\u{2019}t care. Only OA2\\[7:3\\] are compared"]
217    MASK2,
218    #[doc = "OA2\\[3:1\\] are masked and don\u{2019}t care. Only OA2\\[7:4\\] are compared"]
219    MASK3,
220    #[doc = "OA2\\[4:1\\] are masked and don\u{2019}t care. Only OA2\\[7:5\\] are compared"]
221    MASK4,
222    #[doc = "OA2\\[5:1\\] are masked and don\u{2019}t care. Only OA2\\[7:6\\] are compared"]
223    MASK5,
224    #[doc = "OA2\\[6:1\\] are masked and don\u{2019}t care. Only OA2\\[7\\] is compared."]
225    MASK6,
226    #[doc = "OA2\\[7:1\\] are masked and don\u{2019}t care. No comparison is done, and all (except reserved) 7-bit received addresses are acknowledged"]
227    MASK7,
228}
229impl OA2MSKW {
230    #[allow(missing_docs)]
231    #[doc(hidden)]
232    #[inline]
233    pub fn _bits(&self) -> u8 {
234        match *self {
235            OA2MSKW::NOMASK => 0,
236            OA2MSKW::MASK1 => 1,
237            OA2MSKW::MASK2 => 2,
238            OA2MSKW::MASK3 => 3,
239            OA2MSKW::MASK4 => 4,
240            OA2MSKW::MASK5 => 5,
241            OA2MSKW::MASK6 => 6,
242            OA2MSKW::MASK7 => 7,
243        }
244    }
245}
246#[doc = r" Proxy"]
247pub struct _OA2MSKW<'a> {
248    w: &'a mut W,
249}
250impl<'a> _OA2MSKW<'a> {
251    #[doc = r" Writes `variant` to the field"]
252    #[inline]
253    pub fn variant(self, variant: OA2MSKW) -> &'a mut W {
254        {
255            self.bits(variant._bits())
256        }
257    }
258    #[doc = "No mask"]
259    #[inline]
260    pub fn no_mask(self) -> &'a mut W {
261        self.variant(OA2MSKW::NOMASK)
262    }
263    #[doc = "OA2\\[1\\] is masked and don\u{2019}t care. Only OA2\\[7:2\\] are compared"]
264    #[inline]
265    pub fn mask1(self) -> &'a mut W {
266        self.variant(OA2MSKW::MASK1)
267    }
268    #[doc = "OA2\\[2:1\\] are masked and don\u{2019}t care. Only OA2\\[7:3\\] are compared"]
269    #[inline]
270    pub fn mask2(self) -> &'a mut W {
271        self.variant(OA2MSKW::MASK2)
272    }
273    #[doc = "OA2\\[3:1\\] are masked and don\u{2019}t care. Only OA2\\[7:4\\] are compared"]
274    #[inline]
275    pub fn mask3(self) -> &'a mut W {
276        self.variant(OA2MSKW::MASK3)
277    }
278    #[doc = "OA2\\[4:1\\] are masked and don\u{2019}t care. Only OA2\\[7:5\\] are compared"]
279    #[inline]
280    pub fn mask4(self) -> &'a mut W {
281        self.variant(OA2MSKW::MASK4)
282    }
283    #[doc = "OA2\\[5:1\\] are masked and don\u{2019}t care. Only OA2\\[7:6\\] are compared"]
284    #[inline]
285    pub fn mask5(self) -> &'a mut W {
286        self.variant(OA2MSKW::MASK5)
287    }
288    #[doc = "OA2\\[6:1\\] are masked and don\u{2019}t care. Only OA2\\[7\\] is compared."]
289    #[inline]
290    pub fn mask6(self) -> &'a mut W {
291        self.variant(OA2MSKW::MASK6)
292    }
293    #[doc = "OA2\\[7:1\\] are masked and don\u{2019}t care. No comparison is done, and all (except reserved) 7-bit received addresses are acknowledged"]
294    #[inline]
295    pub fn mask7(self) -> &'a mut W {
296        self.variant(OA2MSKW::MASK7)
297    }
298    #[doc = r" Writes raw bits to the field"]
299    #[inline]
300    pub fn bits(self, value: u8) -> &'a mut W {
301        const MASK: u8 = 7;
302        const OFFSET: u8 = 8;
303        self.w.bits &= !((MASK as u32) << OFFSET);
304        self.w.bits |= ((value & MASK) as u32) << OFFSET;
305        self.w
306    }
307}
308#[doc = "Values that can be written to the field `OA2EN`"]
309pub enum OA2ENW {
310    #[doc = "Own address 2 disabled. The received slave address OA2 is NACKed"]
311    DISABLED,
312    #[doc = "Own address 2 enabled. The received slave address OA2 is ACKed"]
313    ENABLED,
314}
315impl OA2ENW {
316    #[allow(missing_docs)]
317    #[doc(hidden)]
318    #[inline]
319    pub fn _bits(&self) -> bool {
320        match *self {
321            OA2ENW::DISABLED => false,
322            OA2ENW::ENABLED => true,
323        }
324    }
325}
326#[doc = r" Proxy"]
327pub struct _OA2ENW<'a> {
328    w: &'a mut W,
329}
330impl<'a> _OA2ENW<'a> {
331    #[doc = r" Writes `variant` to the field"]
332    #[inline]
333    pub fn variant(self, variant: OA2ENW) -> &'a mut W {
334        {
335            self.bit(variant._bits())
336        }
337    }
338    #[doc = "Own address 2 disabled. The received slave address OA2 is NACKed"]
339    #[inline]
340    pub fn disabled(self) -> &'a mut W {
341        self.variant(OA2ENW::DISABLED)
342    }
343    #[doc = "Own address 2 enabled. The received slave address OA2 is ACKed"]
344    #[inline]
345    pub fn enabled(self) -> &'a mut W {
346        self.variant(OA2ENW::ENABLED)
347    }
348    #[doc = r" Sets the field bit"]
349    pub fn set_bit(self) -> &'a mut W {
350        self.bit(true)
351    }
352    #[doc = r" Clears the field bit"]
353    pub fn clear_bit(self) -> &'a mut W {
354        self.bit(false)
355    }
356    #[doc = r" Writes raw bits to the field"]
357    #[inline]
358    pub fn bit(self, value: bool) -> &'a mut W {
359        const MASK: bool = true;
360        const OFFSET: u8 = 15;
361        self.w.bits &= !((MASK as u32) << OFFSET);
362        self.w.bits |= ((value & MASK) as u32) << OFFSET;
363        self.w
364    }
365}
366impl R {
367    #[doc = r" Value of the register as raw bits"]
368    #[inline]
369    pub fn bits(&self) -> u32 {
370        self.bits
371    }
372    #[doc = "Bits 1:7 - Interface address"]
373    #[inline]
374    pub fn oa2(&self) -> OA2R {
375        let bits = {
376            const MASK: u8 = 127;
377            const OFFSET: u8 = 1;
378            ((self.bits >> OFFSET) & MASK as u32) as u8
379        };
380        OA2R { bits }
381    }
382    #[doc = "Bits 8:10 - Own Address 2 masks"]
383    #[inline]
384    pub fn oa2msk(&self) -> OA2MSKR {
385        OA2MSKR::_from({
386            const MASK: u8 = 7;
387            const OFFSET: u8 = 8;
388            ((self.bits >> OFFSET) & MASK as u32) as u8
389        })
390    }
391    #[doc = "Bit 15 - Own Address 2 enable"]
392    #[inline]
393    pub fn oa2en(&self) -> OA2ENR {
394        OA2ENR::_from({
395            const MASK: bool = true;
396            const OFFSET: u8 = 15;
397            ((self.bits >> OFFSET) & MASK as u32) != 0
398        })
399    }
400}
401impl W {
402    #[doc = r" Reset value of the register"]
403    #[inline]
404    pub fn reset_value() -> W {
405        W { bits: 0 }
406    }
407    #[doc = r" Writes raw bits to the register"]
408    #[inline]
409    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
410        self.bits = bits;
411        self
412    }
413    #[doc = "Bits 1:7 - Interface address"]
414    #[inline]
415    pub fn oa2(&mut self) -> _OA2W {
416        _OA2W { w: self }
417    }
418    #[doc = "Bits 8:10 - Own Address 2 masks"]
419    #[inline]
420    pub fn oa2msk(&mut self) -> _OA2MSKW {
421        _OA2MSKW { w: self }
422    }
423    #[doc = "Bit 15 - Own Address 2 enable"]
424    #[inline]
425    pub fn oa2en(&mut self) -> _OA2ENW {
426        _OA2ENW { w: self }
427    }
428}