lpc43xx/dac/ctrl/
mod.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::CTRL {
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 `INT_DMA_REQ`"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47pub enum INT_DMA_REQR {
48    #[doc = "This bit is cleared on any write to the DACR register."]
49    CLR,
50    #[doc = "This bit is set by hardware when the timer times out."]
51    SET,
52}
53impl INT_DMA_REQR {
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            INT_DMA_REQR::CLR => false,
69            INT_DMA_REQR::SET => true,
70        }
71    }
72    #[allow(missing_docs)]
73    #[doc(hidden)]
74    #[inline]
75    pub fn _from(value: bool) -> INT_DMA_REQR {
76        match value {
77            false => INT_DMA_REQR::CLR,
78            true => INT_DMA_REQR::SET,
79        }
80    }
81    #[doc = "Checks if the value of the field is `CLR`"]
82    #[inline]
83    pub fn is_clr(&self) -> bool {
84        *self == INT_DMA_REQR::CLR
85    }
86    #[doc = "Checks if the value of the field is `SET`"]
87    #[inline]
88    pub fn is_set(&self) -> bool {
89        *self == INT_DMA_REQR::SET
90    }
91}
92#[doc = "Possible values of the field `DBLBUF_ENA`"]
93#[derive(Clone, Copy, Debug, PartialEq)]
94pub enum DBLBUF_ENAR {
95    #[doc = "DACR double-buffering is disabled."]
96    DISABLED,
97    #[doc = "When this bit and the CNT_ENA bit are both set, the double-buffering feature in the DACR register will be enabled. Writes to the DACR register are written to a pre-buffer and then transferred to the DACR on the next time-out of the counter."]
98    ENABLED,
99}
100impl DBLBUF_ENAR {
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            DBLBUF_ENAR::DISABLED => false,
116            DBLBUF_ENAR::ENABLED => true,
117        }
118    }
119    #[allow(missing_docs)]
120    #[doc(hidden)]
121    #[inline]
122    pub fn _from(value: bool) -> DBLBUF_ENAR {
123        match value {
124            false => DBLBUF_ENAR::DISABLED,
125            true => DBLBUF_ENAR::ENABLED,
126        }
127    }
128    #[doc = "Checks if the value of the field is `DISABLED`"]
129    #[inline]
130    pub fn is_disabled(&self) -> bool {
131        *self == DBLBUF_ENAR::DISABLED
132    }
133    #[doc = "Checks if the value of the field is `ENABLED`"]
134    #[inline]
135    pub fn is_enabled(&self) -> bool {
136        *self == DBLBUF_ENAR::ENABLED
137    }
138}
139#[doc = "Possible values of the field `CNT_ENA`"]
140#[derive(Clone, Copy, Debug, PartialEq)]
141pub enum CNT_ENAR {
142    #[doc = "Time-out counter operation is disabled."]
143    DISABLED,
144    #[doc = "Time-out counter operation is enabled."]
145    ENABLED,
146}
147impl CNT_ENAR {
148    #[doc = r" Returns `true` if the bit is clear (0)"]
149    #[inline]
150    pub fn bit_is_clear(&self) -> bool {
151        !self.bit()
152    }
153    #[doc = r" Returns `true` if the bit is set (1)"]
154    #[inline]
155    pub fn bit_is_set(&self) -> bool {
156        self.bit()
157    }
158    #[doc = r" Value of the field as raw bits"]
159    #[inline]
160    pub fn bit(&self) -> bool {
161        match *self {
162            CNT_ENAR::DISABLED => false,
163            CNT_ENAR::ENABLED => true,
164        }
165    }
166    #[allow(missing_docs)]
167    #[doc(hidden)]
168    #[inline]
169    pub fn _from(value: bool) -> CNT_ENAR {
170        match value {
171            false => CNT_ENAR::DISABLED,
172            true => CNT_ENAR::ENABLED,
173        }
174    }
175    #[doc = "Checks if the value of the field is `DISABLED`"]
176    #[inline]
177    pub fn is_disabled(&self) -> bool {
178        *self == CNT_ENAR::DISABLED
179    }
180    #[doc = "Checks if the value of the field is `ENABLED`"]
181    #[inline]
182    pub fn is_enabled(&self) -> bool {
183        *self == CNT_ENAR::ENABLED
184    }
185}
186#[doc = "Possible values of the field `DMA_ENA`"]
187#[derive(Clone, Copy, Debug, PartialEq)]
188pub enum DMA_ENAR {
189    #[doc = "DMA access is disabled."]
190    DISABLED,
191    #[doc = "DMA Burst Request Input 15 is enabled for the DAC (see Table 136)."]
192    ENABLED,
193}
194impl DMA_ENAR {
195    #[doc = r" Returns `true` if the bit is clear (0)"]
196    #[inline]
197    pub fn bit_is_clear(&self) -> bool {
198        !self.bit()
199    }
200    #[doc = r" Returns `true` if the bit is set (1)"]
201    #[inline]
202    pub fn bit_is_set(&self) -> bool {
203        self.bit()
204    }
205    #[doc = r" Value of the field as raw bits"]
206    #[inline]
207    pub fn bit(&self) -> bool {
208        match *self {
209            DMA_ENAR::DISABLED => false,
210            DMA_ENAR::ENABLED => true,
211        }
212    }
213    #[allow(missing_docs)]
214    #[doc(hidden)]
215    #[inline]
216    pub fn _from(value: bool) -> DMA_ENAR {
217        match value {
218            false => DMA_ENAR::DISABLED,
219            true => DMA_ENAR::ENABLED,
220        }
221    }
222    #[doc = "Checks if the value of the field is `DISABLED`"]
223    #[inline]
224    pub fn is_disabled(&self) -> bool {
225        *self == DMA_ENAR::DISABLED
226    }
227    #[doc = "Checks if the value of the field is `ENABLED`"]
228    #[inline]
229    pub fn is_enabled(&self) -> bool {
230        *self == DMA_ENAR::ENABLED
231    }
232}
233#[doc = "Values that can be written to the field `INT_DMA_REQ`"]
234pub enum INT_DMA_REQW {
235    #[doc = "This bit is cleared on any write to the DACR register."]
236    CLR,
237    #[doc = "This bit is set by hardware when the timer times out."]
238    SET,
239}
240impl INT_DMA_REQW {
241    #[allow(missing_docs)]
242    #[doc(hidden)]
243    #[inline]
244    pub fn _bits(&self) -> bool {
245        match *self {
246            INT_DMA_REQW::CLR => false,
247            INT_DMA_REQW::SET => true,
248        }
249    }
250}
251#[doc = r" Proxy"]
252pub struct _INT_DMA_REQW<'a> {
253    w: &'a mut W,
254}
255impl<'a> _INT_DMA_REQW<'a> {
256    #[doc = r" Writes `variant` to the field"]
257    #[inline]
258    pub fn variant(self, variant: INT_DMA_REQW) -> &'a mut W {
259        {
260            self.bit(variant._bits())
261        }
262    }
263    #[doc = "This bit is cleared on any write to the DACR register."]
264    #[inline]
265    pub fn clr(self) -> &'a mut W {
266        self.variant(INT_DMA_REQW::CLR)
267    }
268    #[doc = "This bit is set by hardware when the timer times out."]
269    #[inline]
270    pub fn set(self) -> &'a mut W {
271        self.variant(INT_DMA_REQW::SET)
272    }
273    #[doc = r" Sets the field bit"]
274    pub fn set_bit(self) -> &'a mut W {
275        self.bit(true)
276    }
277    #[doc = r" Clears the field bit"]
278    pub fn clear_bit(self) -> &'a mut W {
279        self.bit(false)
280    }
281    #[doc = r" Writes raw bits to the field"]
282    #[inline]
283    pub fn bit(self, value: bool) -> &'a mut W {
284        const MASK: bool = true;
285        const OFFSET: u8 = 0;
286        self.w.bits &= !((MASK as u32) << OFFSET);
287        self.w.bits |= ((value & MASK) as u32) << OFFSET;
288        self.w
289    }
290}
291#[doc = "Values that can be written to the field `DBLBUF_ENA`"]
292pub enum DBLBUF_ENAW {
293    #[doc = "DACR double-buffering is disabled."]
294    DISABLED,
295    #[doc = "When this bit and the CNT_ENA bit are both set, the double-buffering feature in the DACR register will be enabled. Writes to the DACR register are written to a pre-buffer and then transferred to the DACR on the next time-out of the counter."]
296    ENABLED,
297}
298impl DBLBUF_ENAW {
299    #[allow(missing_docs)]
300    #[doc(hidden)]
301    #[inline]
302    pub fn _bits(&self) -> bool {
303        match *self {
304            DBLBUF_ENAW::DISABLED => false,
305            DBLBUF_ENAW::ENABLED => true,
306        }
307    }
308}
309#[doc = r" Proxy"]
310pub struct _DBLBUF_ENAW<'a> {
311    w: &'a mut W,
312}
313impl<'a> _DBLBUF_ENAW<'a> {
314    #[doc = r" Writes `variant` to the field"]
315    #[inline]
316    pub fn variant(self, variant: DBLBUF_ENAW) -> &'a mut W {
317        {
318            self.bit(variant._bits())
319        }
320    }
321    #[doc = "DACR double-buffering is disabled."]
322    #[inline]
323    pub fn disabled(self) -> &'a mut W {
324        self.variant(DBLBUF_ENAW::DISABLED)
325    }
326    #[doc = "When this bit and the CNT_ENA bit are both set, the double-buffering feature in the DACR register will be enabled. Writes to the DACR register are written to a pre-buffer and then transferred to the DACR on the next time-out of the counter."]
327    #[inline]
328    pub fn enabled(self) -> &'a mut W {
329        self.variant(DBLBUF_ENAW::ENABLED)
330    }
331    #[doc = r" Sets the field bit"]
332    pub fn set_bit(self) -> &'a mut W {
333        self.bit(true)
334    }
335    #[doc = r" Clears the field bit"]
336    pub fn clear_bit(self) -> &'a mut W {
337        self.bit(false)
338    }
339    #[doc = r" Writes raw bits to the field"]
340    #[inline]
341    pub fn bit(self, value: bool) -> &'a mut W {
342        const MASK: bool = true;
343        const OFFSET: u8 = 1;
344        self.w.bits &= !((MASK as u32) << OFFSET);
345        self.w.bits |= ((value & MASK) as u32) << OFFSET;
346        self.w
347    }
348}
349#[doc = "Values that can be written to the field `CNT_ENA`"]
350pub enum CNT_ENAW {
351    #[doc = "Time-out counter operation is disabled."]
352    DISABLED,
353    #[doc = "Time-out counter operation is enabled."]
354    ENABLED,
355}
356impl CNT_ENAW {
357    #[allow(missing_docs)]
358    #[doc(hidden)]
359    #[inline]
360    pub fn _bits(&self) -> bool {
361        match *self {
362            CNT_ENAW::DISABLED => false,
363            CNT_ENAW::ENABLED => true,
364        }
365    }
366}
367#[doc = r" Proxy"]
368pub struct _CNT_ENAW<'a> {
369    w: &'a mut W,
370}
371impl<'a> _CNT_ENAW<'a> {
372    #[doc = r" Writes `variant` to the field"]
373    #[inline]
374    pub fn variant(self, variant: CNT_ENAW) -> &'a mut W {
375        {
376            self.bit(variant._bits())
377        }
378    }
379    #[doc = "Time-out counter operation is disabled."]
380    #[inline]
381    pub fn disabled(self) -> &'a mut W {
382        self.variant(CNT_ENAW::DISABLED)
383    }
384    #[doc = "Time-out counter operation is enabled."]
385    #[inline]
386    pub fn enabled(self) -> &'a mut W {
387        self.variant(CNT_ENAW::ENABLED)
388    }
389    #[doc = r" Sets the field bit"]
390    pub fn set_bit(self) -> &'a mut W {
391        self.bit(true)
392    }
393    #[doc = r" Clears the field bit"]
394    pub fn clear_bit(self) -> &'a mut W {
395        self.bit(false)
396    }
397    #[doc = r" Writes raw bits to the field"]
398    #[inline]
399    pub fn bit(self, value: bool) -> &'a mut W {
400        const MASK: bool = true;
401        const OFFSET: u8 = 2;
402        self.w.bits &= !((MASK as u32) << OFFSET);
403        self.w.bits |= ((value & MASK) as u32) << OFFSET;
404        self.w
405    }
406}
407#[doc = "Values that can be written to the field `DMA_ENA`"]
408pub enum DMA_ENAW {
409    #[doc = "DMA access is disabled."]
410    DISABLED,
411    #[doc = "DMA Burst Request Input 15 is enabled for the DAC (see Table 136)."]
412    ENABLED,
413}
414impl DMA_ENAW {
415    #[allow(missing_docs)]
416    #[doc(hidden)]
417    #[inline]
418    pub fn _bits(&self) -> bool {
419        match *self {
420            DMA_ENAW::DISABLED => false,
421            DMA_ENAW::ENABLED => true,
422        }
423    }
424}
425#[doc = r" Proxy"]
426pub struct _DMA_ENAW<'a> {
427    w: &'a mut W,
428}
429impl<'a> _DMA_ENAW<'a> {
430    #[doc = r" Writes `variant` to the field"]
431    #[inline]
432    pub fn variant(self, variant: DMA_ENAW) -> &'a mut W {
433        {
434            self.bit(variant._bits())
435        }
436    }
437    #[doc = "DMA access is disabled."]
438    #[inline]
439    pub fn disabled(self) -> &'a mut W {
440        self.variant(DMA_ENAW::DISABLED)
441    }
442    #[doc = "DMA Burst Request Input 15 is enabled for the DAC (see Table 136)."]
443    #[inline]
444    pub fn enabled(self) -> &'a mut W {
445        self.variant(DMA_ENAW::ENABLED)
446    }
447    #[doc = r" Sets the field bit"]
448    pub fn set_bit(self) -> &'a mut W {
449        self.bit(true)
450    }
451    #[doc = r" Clears the field bit"]
452    pub fn clear_bit(self) -> &'a mut W {
453        self.bit(false)
454    }
455    #[doc = r" Writes raw bits to the field"]
456    #[inline]
457    pub fn bit(self, value: bool) -> &'a mut W {
458        const MASK: bool = true;
459        const OFFSET: u8 = 3;
460        self.w.bits &= !((MASK as u32) << OFFSET);
461        self.w.bits |= ((value & MASK) as u32) << OFFSET;
462        self.w
463    }
464}
465impl R {
466    #[doc = r" Value of the register as raw bits"]
467    #[inline]
468    pub fn bits(&self) -> u32 {
469        self.bits
470    }
471    #[doc = "Bit 0 - DMA request"]
472    #[inline]
473    pub fn int_dma_req(&self) -> INT_DMA_REQR {
474        INT_DMA_REQR::_from({
475            const MASK: bool = true;
476            const OFFSET: u8 = 0;
477            ((self.bits >> OFFSET) & MASK as u32) != 0
478        })
479    }
480    #[doc = "Bit 1 - DMA double-buffering"]
481    #[inline]
482    pub fn dblbuf_ena(&self) -> DBLBUF_ENAR {
483        DBLBUF_ENAR::_from({
484            const MASK: bool = true;
485            const OFFSET: u8 = 1;
486            ((self.bits >> OFFSET) & MASK as u32) != 0
487        })
488    }
489    #[doc = "Bit 2 - DMA time-out"]
490    #[inline]
491    pub fn cnt_ena(&self) -> CNT_ENAR {
492        CNT_ENAR::_from({
493            const MASK: bool = true;
494            const OFFSET: u8 = 2;
495            ((self.bits >> OFFSET) & MASK as u32) != 0
496        })
497    }
498    #[doc = "Bit 3 - DMA enable"]
499    #[inline]
500    pub fn dma_ena(&self) -> DMA_ENAR {
501        DMA_ENAR::_from({
502            const MASK: bool = true;
503            const OFFSET: u8 = 3;
504            ((self.bits >> OFFSET) & MASK as u32) != 0
505        })
506    }
507}
508impl W {
509    #[doc = r" Reset value of the register"]
510    #[inline]
511    pub fn reset_value() -> W {
512        W { bits: 0 }
513    }
514    #[doc = r" Writes raw bits to the register"]
515    #[inline]
516    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
517        self.bits = bits;
518        self
519    }
520    #[doc = "Bit 0 - DMA request"]
521    #[inline]
522    pub fn int_dma_req(&mut self) -> _INT_DMA_REQW {
523        _INT_DMA_REQW { w: self }
524    }
525    #[doc = "Bit 1 - DMA double-buffering"]
526    #[inline]
527    pub fn dblbuf_ena(&mut self) -> _DBLBUF_ENAW {
528        _DBLBUF_ENAW { w: self }
529    }
530    #[doc = "Bit 2 - DMA time-out"]
531    #[inline]
532    pub fn cnt_ena(&mut self) -> _CNT_ENAW {
533        _CNT_ENAW { w: self }
534    }
535    #[doc = "Bit 3 - DMA enable"]
536    #[inline]
537    pub fn dma_ena(&mut self) -> _DMA_ENAW {
538        _DMA_ENAW { w: self }
539    }
540}