mk20d7/cmt/oc/
mod.rs

1#[doc = r" Value read from the register"]
2pub struct R {
3    bits: u8,
4}
5#[doc = r" Value to write to the register"]
6pub struct W {
7    bits: u8,
8}
9impl super::OC {
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 `IROPEN`"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47pub enum IROPENR {
48    #[doc = "CMT_IRO signal disabled"]
49    _0,
50    #[doc = "CMT_IRO signal enabled as output"]
51    _1,
52}
53impl IROPENR {
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            IROPENR::_0 => false,
69            IROPENR::_1 => true,
70        }
71    }
72    #[allow(missing_docs)]
73    #[doc(hidden)]
74    #[inline]
75    pub fn _from(value: bool) -> IROPENR {
76        match value {
77            false => IROPENR::_0,
78            true => IROPENR::_1,
79        }
80    }
81    #[doc = "Checks if the value of the field is `_0`"]
82    #[inline]
83    pub fn is_0(&self) -> bool {
84        *self == IROPENR::_0
85    }
86    #[doc = "Checks if the value of the field is `_1`"]
87    #[inline]
88    pub fn is_1(&self) -> bool {
89        *self == IROPENR::_1
90    }
91}
92#[doc = "Possible values of the field `CMTPOL`"]
93#[derive(Clone, Copy, Debug, PartialEq)]
94pub enum CMTPOLR {
95    #[doc = "CMT_IRO signal is active low"]
96    _0,
97    #[doc = "CMT_IRO signal is active high"]
98    _1,
99}
100impl CMTPOLR {
101    #[doc = r" Returns `true` if the bit is clear (0)"]
102    #[inline]
103    pub fn bit_is_clear(&self) -> bool {
104        !self.bit()
105    }
106    #[doc = r" Returns `true` if the bit is set (1)"]
107    #[inline]
108    pub fn bit_is_set(&self) -> bool {
109        self.bit()
110    }
111    #[doc = r" Value of the field as raw bits"]
112    #[inline]
113    pub fn bit(&self) -> bool {
114        match *self {
115            CMTPOLR::_0 => false,
116            CMTPOLR::_1 => true,
117        }
118    }
119    #[allow(missing_docs)]
120    #[doc(hidden)]
121    #[inline]
122    pub fn _from(value: bool) -> CMTPOLR {
123        match value {
124            false => CMTPOLR::_0,
125            true => CMTPOLR::_1,
126        }
127    }
128    #[doc = "Checks if the value of the field is `_0`"]
129    #[inline]
130    pub fn is_0(&self) -> bool {
131        *self == CMTPOLR::_0
132    }
133    #[doc = "Checks if the value of the field is `_1`"]
134    #[inline]
135    pub fn is_1(&self) -> bool {
136        *self == CMTPOLR::_1
137    }
138}
139#[doc = r" Value of the field"]
140pub struct IROLR {
141    bits: bool,
142}
143impl IROLR {
144    #[doc = r" Value of the field as raw bits"]
145    #[inline]
146    pub fn bit(&self) -> bool {
147        self.bits
148    }
149    #[doc = r" Returns `true` if the bit is clear (0)"]
150    #[inline]
151    pub fn bit_is_clear(&self) -> bool {
152        !self.bit()
153    }
154    #[doc = r" Returns `true` if the bit is set (1)"]
155    #[inline]
156    pub fn bit_is_set(&self) -> bool {
157        self.bit()
158    }
159}
160#[doc = "Values that can be written to the field `IROPEN`"]
161pub enum IROPENW {
162    #[doc = "CMT_IRO signal disabled"]
163    _0,
164    #[doc = "CMT_IRO signal enabled as output"]
165    _1,
166}
167impl IROPENW {
168    #[allow(missing_docs)]
169    #[doc(hidden)]
170    #[inline]
171    pub fn _bits(&self) -> bool {
172        match *self {
173            IROPENW::_0 => false,
174            IROPENW::_1 => true,
175        }
176    }
177}
178#[doc = r" Proxy"]
179pub struct _IROPENW<'a> {
180    w: &'a mut W,
181}
182impl<'a> _IROPENW<'a> {
183    #[doc = r" Writes `variant` to the field"]
184    #[inline]
185    pub fn variant(self, variant: IROPENW) -> &'a mut W {
186        {
187            self.bit(variant._bits())
188        }
189    }
190    #[doc = "CMT_IRO signal disabled"]
191    #[inline]
192    pub fn _0(self) -> &'a mut W {
193        self.variant(IROPENW::_0)
194    }
195    #[doc = "CMT_IRO signal enabled as output"]
196    #[inline]
197    pub fn _1(self) -> &'a mut W {
198        self.variant(IROPENW::_1)
199    }
200    #[doc = r" Sets the field bit"]
201    pub fn set_bit(self) -> &'a mut W {
202        self.bit(true)
203    }
204    #[doc = r" Clears the field bit"]
205    pub fn clear_bit(self) -> &'a mut W {
206        self.bit(false)
207    }
208    #[doc = r" Writes raw bits to the field"]
209    #[inline]
210    pub fn bit(self, value: bool) -> &'a mut W {
211        const MASK: bool = true;
212        const OFFSET: u8 = 5;
213        self.w.bits &= !((MASK as u8) << OFFSET);
214        self.w.bits |= ((value & MASK) as u8) << OFFSET;
215        self.w
216    }
217}
218#[doc = "Values that can be written to the field `CMTPOL`"]
219pub enum CMTPOLW {
220    #[doc = "CMT_IRO signal is active low"]
221    _0,
222    #[doc = "CMT_IRO signal is active high"]
223    _1,
224}
225impl CMTPOLW {
226    #[allow(missing_docs)]
227    #[doc(hidden)]
228    #[inline]
229    pub fn _bits(&self) -> bool {
230        match *self {
231            CMTPOLW::_0 => false,
232            CMTPOLW::_1 => true,
233        }
234    }
235}
236#[doc = r" Proxy"]
237pub struct _CMTPOLW<'a> {
238    w: &'a mut W,
239}
240impl<'a> _CMTPOLW<'a> {
241    #[doc = r" Writes `variant` to the field"]
242    #[inline]
243    pub fn variant(self, variant: CMTPOLW) -> &'a mut W {
244        {
245            self.bit(variant._bits())
246        }
247    }
248    #[doc = "CMT_IRO signal is active low"]
249    #[inline]
250    pub fn _0(self) -> &'a mut W {
251        self.variant(CMTPOLW::_0)
252    }
253    #[doc = "CMT_IRO signal is active high"]
254    #[inline]
255    pub fn _1(self) -> &'a mut W {
256        self.variant(CMTPOLW::_1)
257    }
258    #[doc = r" Sets the field bit"]
259    pub fn set_bit(self) -> &'a mut W {
260        self.bit(true)
261    }
262    #[doc = r" Clears the field bit"]
263    pub fn clear_bit(self) -> &'a mut W {
264        self.bit(false)
265    }
266    #[doc = r" Writes raw bits to the field"]
267    #[inline]
268    pub fn bit(self, value: bool) -> &'a mut W {
269        const MASK: bool = true;
270        const OFFSET: u8 = 6;
271        self.w.bits &= !((MASK as u8) << OFFSET);
272        self.w.bits |= ((value & MASK) as u8) << OFFSET;
273        self.w
274    }
275}
276#[doc = r" Proxy"]
277pub struct _IROLW<'a> {
278    w: &'a mut W,
279}
280impl<'a> _IROLW<'a> {
281    #[doc = r" Sets the field bit"]
282    pub fn set_bit(self) -> &'a mut W {
283        self.bit(true)
284    }
285    #[doc = r" Clears the field bit"]
286    pub fn clear_bit(self) -> &'a mut W {
287        self.bit(false)
288    }
289    #[doc = r" Writes raw bits to the field"]
290    #[inline]
291    pub fn bit(self, value: bool) -> &'a mut W {
292        const MASK: bool = true;
293        const OFFSET: u8 = 7;
294        self.w.bits &= !((MASK as u8) << OFFSET);
295        self.w.bits |= ((value & MASK) as u8) << OFFSET;
296        self.w
297    }
298}
299impl R {
300    #[doc = r" Value of the register as raw bits"]
301    #[inline]
302    pub fn bits(&self) -> u8 {
303        self.bits
304    }
305    #[doc = "Bit 5 - IRO Pin Enable"]
306    #[inline]
307    pub fn iropen(&self) -> IROPENR {
308        IROPENR::_from({
309            const MASK: bool = true;
310            const OFFSET: u8 = 5;
311            ((self.bits >> OFFSET) & MASK as u8) != 0
312        })
313    }
314    #[doc = "Bit 6 - CMT Output Polarity"]
315    #[inline]
316    pub fn cmtpol(&self) -> CMTPOLR {
317        CMTPOLR::_from({
318            const MASK: bool = true;
319            const OFFSET: u8 = 6;
320            ((self.bits >> OFFSET) & MASK as u8) != 0
321        })
322    }
323    #[doc = "Bit 7 - IRO Latch Control"]
324    #[inline]
325    pub fn irol(&self) -> IROLR {
326        let bits = {
327            const MASK: bool = true;
328            const OFFSET: u8 = 7;
329            ((self.bits >> OFFSET) & MASK as u8) != 0
330        };
331        IROLR { bits }
332    }
333}
334impl W {
335    #[doc = r" Reset value of the register"]
336    #[inline]
337    pub fn reset_value() -> W {
338        W { bits: 0 }
339    }
340    #[doc = r" Writes raw bits to the register"]
341    #[inline]
342    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
343        self.bits = bits;
344        self
345    }
346    #[doc = "Bit 5 - IRO Pin Enable"]
347    #[inline]
348    pub fn iropen(&mut self) -> _IROPENW {
349        _IROPENW { w: self }
350    }
351    #[doc = "Bit 6 - CMT Output Polarity"]
352    #[inline]
353    pub fn cmtpol(&mut self) -> _CMTPOLW {
354        _CMTPOLW { w: self }
355    }
356    #[doc = "Bit 7 - IRO Latch Control"]
357    #[inline]
358    pub fn irol(&mut self) -> _IROLW {
359        _IROLW { w: self }
360    }
361}