nrf91/twis0_ns/
events_write.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::EVENTS_WRITE {
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 = "Possible values of the field `EVENTS_WRITE`"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47pub enum EVENTS_WRITER {
48    #[doc = "Event not generated"]
49    NOTGENERATED,
50    #[doc = "Event generated"]
51    GENERATED,
52}
53impl EVENTS_WRITER {
54    #[doc = r" Returns `true` if the bit is clear (0)"]
55    #[inline]
56    pub fn bit_is_clear(&self) -> bool {
57        !self.bit()
58    }
59    #[doc = r" Returns `true` if the bit is set (1)"]
60    #[inline]
61    pub fn bit_is_set(&self) -> bool {
62        self.bit()
63    }
64    #[doc = r" Value of the field as raw bits"]
65    #[inline]
66    pub fn bit(&self) -> bool {
67        match *self {
68            EVENTS_WRITER::NOTGENERATED => false,
69            EVENTS_WRITER::GENERATED => true,
70        }
71    }
72    #[allow(missing_docs)]
73    #[doc(hidden)]
74    #[inline]
75    pub fn _from(value: bool) -> EVENTS_WRITER {
76        match value {
77            false => EVENTS_WRITER::NOTGENERATED,
78            true => EVENTS_WRITER::GENERATED,
79        }
80    }
81    #[doc = "Checks if the value of the field is `NOTGENERATED`"]
82    #[inline]
83    pub fn is_not_generated(&self) -> bool {
84        *self == EVENTS_WRITER::NOTGENERATED
85    }
86    #[doc = "Checks if the value of the field is `GENERATED`"]
87    #[inline]
88    pub fn is_generated(&self) -> bool {
89        *self == EVENTS_WRITER::GENERATED
90    }
91}
92#[doc = "Values that can be written to the field `EVENTS_WRITE`"]
93pub enum EVENTS_WRITEW {
94    #[doc = "Event not generated"]
95    NOTGENERATED,
96    #[doc = "Event generated"]
97    GENERATED,
98}
99impl EVENTS_WRITEW {
100    #[allow(missing_docs)]
101    #[doc(hidden)]
102    #[inline]
103    pub fn _bits(&self) -> bool {
104        match *self {
105            EVENTS_WRITEW::NOTGENERATED => false,
106            EVENTS_WRITEW::GENERATED => true,
107        }
108    }
109}
110#[doc = r" Proxy"]
111pub struct _EVENTS_WRITEW<'a> {
112    w: &'a mut W,
113}
114impl<'a> _EVENTS_WRITEW<'a> {
115    #[doc = r" Writes `variant` to the field"]
116    #[inline]
117    pub fn variant(self, variant: EVENTS_WRITEW) -> &'a mut W {
118        {
119            self.bit(variant._bits())
120        }
121    }
122    #[doc = "Event not generated"]
123    #[inline]
124    pub fn not_generated(self) -> &'a mut W {
125        self.variant(EVENTS_WRITEW::NOTGENERATED)
126    }
127    #[doc = "Event generated"]
128    #[inline]
129    pub fn generated(self) -> &'a mut W {
130        self.variant(EVENTS_WRITEW::GENERATED)
131    }
132    #[doc = r" Sets the field bit"]
133    pub fn set_bit(self) -> &'a mut W {
134        self.bit(true)
135    }
136    #[doc = r" Clears the field bit"]
137    pub fn clear_bit(self) -> &'a mut W {
138        self.bit(false)
139    }
140    #[doc = r" Writes raw bits to the field"]
141    #[inline]
142    pub fn bit(self, value: bool) -> &'a mut W {
143        const MASK: bool = true;
144        const OFFSET: u8 = 0;
145        self.w.bits &= !((MASK as u32) << OFFSET);
146        self.w.bits |= ((value & MASK) as u32) << OFFSET;
147        self.w
148    }
149}
150impl R {
151    #[doc = r" Value of the register as raw bits"]
152    #[inline]
153    pub fn bits(&self) -> u32 {
154        self.bits
155    }
156    #[doc = "Bit 0 - Write command received"]
157    #[inline]
158    pub fn events_write(&self) -> EVENTS_WRITER {
159        EVENTS_WRITER::_from({
160            const MASK: bool = true;
161            const OFFSET: u8 = 0;
162            ((self.bits >> OFFSET) & MASK as u32) != 0
163        })
164    }
165}
166impl W {
167    #[doc = r" Reset value of the register"]
168    #[inline]
169    pub fn reset_value() -> W {
170        W { bits: 0 }
171    }
172    #[doc = r" Writes raw bits to the register"]
173    #[inline]
174    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
175        self.bits = bits;
176        self
177    }
178    #[doc = "Bit 0 - Write command received"]
179    #[inline]
180    pub fn events_write(&mut self) -> _EVENTS_WRITEW {
181        _EVENTS_WRITEW { w: self }
182    }
183}