saml10d16a/tc0/count8/
ctrlbclr.rs

1#[doc = "Reader of register CTRLBCLR"]
2pub type R = crate::R<u8, super::CTRLBCLR>;
3#[doc = "Writer for register CTRLBCLR"]
4pub type W = crate::W<u8, super::CTRLBCLR>;
5#[doc = "Register CTRLBCLR `reset()`'s with value 0"]
6impl crate::ResetValue for super::CTRLBCLR {
7    type Type = u8;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `DIR`"]
14pub type DIR_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `DIR`"]
16pub struct DIR_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> DIR_W<'a> {
20    #[doc = r"Sets the field bit"]
21    #[inline(always)]
22    pub fn set_bit(self) -> &'a mut W {
23        self.bit(true)
24    }
25    #[doc = r"Clears the field bit"]
26    #[inline(always)]
27    pub fn clear_bit(self) -> &'a mut W {
28        self.bit(false)
29    }
30    #[doc = r"Writes raw bits to the field"]
31    #[inline(always)]
32    pub fn bit(self, value: bool) -> &'a mut W {
33        self.w.bits = (self.w.bits & !0x01) | ((value as u8) & 0x01);
34        self.w
35    }
36}
37#[doc = "Reader of field `LUPD`"]
38pub type LUPD_R = crate::R<bool, bool>;
39#[doc = "Write proxy for field `LUPD`"]
40pub struct LUPD_W<'a> {
41    w: &'a mut W,
42}
43impl<'a> LUPD_W<'a> {
44    #[doc = r"Sets the field bit"]
45    #[inline(always)]
46    pub fn set_bit(self) -> &'a mut W {
47        self.bit(true)
48    }
49    #[doc = r"Clears the field bit"]
50    #[inline(always)]
51    pub fn clear_bit(self) -> &'a mut W {
52        self.bit(false)
53    }
54    #[doc = r"Writes raw bits to the field"]
55    #[inline(always)]
56    pub fn bit(self, value: bool) -> &'a mut W {
57        self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u8) & 0x01) << 1);
58        self.w
59    }
60}
61#[doc = "Reader of field `ONESHOT`"]
62pub type ONESHOT_R = crate::R<bool, bool>;
63#[doc = "Write proxy for field `ONESHOT`"]
64pub struct ONESHOT_W<'a> {
65    w: &'a mut W,
66}
67impl<'a> ONESHOT_W<'a> {
68    #[doc = r"Sets the field bit"]
69    #[inline(always)]
70    pub fn set_bit(self) -> &'a mut W {
71        self.bit(true)
72    }
73    #[doc = r"Clears the field bit"]
74    #[inline(always)]
75    pub fn clear_bit(self) -> &'a mut W {
76        self.bit(false)
77    }
78    #[doc = r"Writes raw bits to the field"]
79    #[inline(always)]
80    pub fn bit(self, value: bool) -> &'a mut W {
81        self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u8) & 0x01) << 2);
82        self.w
83    }
84}
85#[doc = "Possible values of the field `CMD`"]
86#[derive(Clone, Copy, Debug, PartialEq)]
87pub enum CMD_A {
88    #[doc = "No action"]
89    NONE,
90    #[doc = "Force a start, restart or retrigger"]
91    RETRIGGER,
92    #[doc = "Force a stop"]
93    STOP,
94    #[doc = "Force update of double-buffered register"]
95    UPDATE,
96    #[doc = "Force a read synchronization of COUNT"]
97    READSYNC,
98    #[doc = "One-shot DMA trigger"]
99    DMAOS,
100}
101impl crate::ToBits<u8> for CMD_A {
102    #[inline(always)]
103    fn _bits(&self) -> u8 {
104        match *self {
105            CMD_A::NONE => 0,
106            CMD_A::RETRIGGER => 1,
107            CMD_A::STOP => 2,
108            CMD_A::UPDATE => 3,
109            CMD_A::READSYNC => 4,
110            CMD_A::DMAOS => 5,
111        }
112    }
113}
114#[doc = "Reader of field `CMD`"]
115pub type CMD_R = crate::R<u8, CMD_A>;
116impl CMD_R {
117    #[doc = r"Get enumerated values variant"]
118    #[inline(always)]
119    pub fn variant(&self) -> crate::Variant<u8, CMD_A> {
120        use crate::Variant::*;
121        match self.bits {
122            0 => Val(CMD_A::NONE),
123            1 => Val(CMD_A::RETRIGGER),
124            2 => Val(CMD_A::STOP),
125            3 => Val(CMD_A::UPDATE),
126            4 => Val(CMD_A::READSYNC),
127            5 => Val(CMD_A::DMAOS),
128            i => Res(i),
129        }
130    }
131    #[doc = "Checks if the value of the field is `NONE`"]
132    #[inline(always)]
133    pub fn is_none(&self) -> bool {
134        *self == CMD_A::NONE
135    }
136    #[doc = "Checks if the value of the field is `RETRIGGER`"]
137    #[inline(always)]
138    pub fn is_retrigger(&self) -> bool {
139        *self == CMD_A::RETRIGGER
140    }
141    #[doc = "Checks if the value of the field is `STOP`"]
142    #[inline(always)]
143    pub fn is_stop(&self) -> bool {
144        *self == CMD_A::STOP
145    }
146    #[doc = "Checks if the value of the field is `UPDATE`"]
147    #[inline(always)]
148    pub fn is_update(&self) -> bool {
149        *self == CMD_A::UPDATE
150    }
151    #[doc = "Checks if the value of the field is `READSYNC`"]
152    #[inline(always)]
153    pub fn is_readsync(&self) -> bool {
154        *self == CMD_A::READSYNC
155    }
156    #[doc = "Checks if the value of the field is `DMAOS`"]
157    #[inline(always)]
158    pub fn is_dmaos(&self) -> bool {
159        *self == CMD_A::DMAOS
160    }
161}
162#[doc = "Write proxy for field `CMD`"]
163pub struct CMD_W<'a> {
164    w: &'a mut W,
165}
166impl<'a> CMD_W<'a> {
167    #[doc = r"Writes `variant` to the field"]
168    #[inline(always)]
169    pub fn variant(self, variant: CMD_A) -> &'a mut W {
170        use crate::ToBits;
171        unsafe { self.bits(variant._bits()) }
172    }
173    #[doc = "No action"]
174    #[inline(always)]
175    pub fn none(self) -> &'a mut W {
176        self.variant(CMD_A::NONE)
177    }
178    #[doc = "Force a start, restart or retrigger"]
179    #[inline(always)]
180    pub fn retrigger(self) -> &'a mut W {
181        self.variant(CMD_A::RETRIGGER)
182    }
183    #[doc = "Force a stop"]
184    #[inline(always)]
185    pub fn stop(self) -> &'a mut W {
186        self.variant(CMD_A::STOP)
187    }
188    #[doc = "Force update of double-buffered register"]
189    #[inline(always)]
190    pub fn update(self) -> &'a mut W {
191        self.variant(CMD_A::UPDATE)
192    }
193    #[doc = "Force a read synchronization of COUNT"]
194    #[inline(always)]
195    pub fn readsync(self) -> &'a mut W {
196        self.variant(CMD_A::READSYNC)
197    }
198    #[doc = "One-shot DMA trigger"]
199    #[inline(always)]
200    pub fn dmaos(self) -> &'a mut W {
201        self.variant(CMD_A::DMAOS)
202    }
203    #[doc = r"Writes raw bits to the field"]
204    #[inline(always)]
205    pub unsafe fn bits(self, value: u8) -> &'a mut W {
206        self.w.bits = (self.w.bits & !(0x07 << 5)) | (((value as u8) & 0x07) << 5);
207        self.w
208    }
209}
210impl R {
211    #[doc = "Bit 0 - Counter Direction"]
212    #[inline(always)]
213    pub fn dir(&self) -> DIR_R {
214        DIR_R::new((self.bits & 0x01) != 0)
215    }
216    #[doc = "Bit 1 - Lock Update"]
217    #[inline(always)]
218    pub fn lupd(&self) -> LUPD_R {
219        LUPD_R::new(((self.bits >> 1) & 0x01) != 0)
220    }
221    #[doc = "Bit 2 - One-Shot on Counter"]
222    #[inline(always)]
223    pub fn oneshot(&self) -> ONESHOT_R {
224        ONESHOT_R::new(((self.bits >> 2) & 0x01) != 0)
225    }
226    #[doc = "Bits 5:7 - Command"]
227    #[inline(always)]
228    pub fn cmd(&self) -> CMD_R {
229        CMD_R::new(((self.bits >> 5) & 0x07) as u8)
230    }
231}
232impl W {
233    #[doc = "Bit 0 - Counter Direction"]
234    #[inline(always)]
235    pub fn dir(&mut self) -> DIR_W {
236        DIR_W { w: self }
237    }
238    #[doc = "Bit 1 - Lock Update"]
239    #[inline(always)]
240    pub fn lupd(&mut self) -> LUPD_W {
241        LUPD_W { w: self }
242    }
243    #[doc = "Bit 2 - One-Shot on Counter"]
244    #[inline(always)]
245    pub fn oneshot(&mut self) -> ONESHOT_W {
246        ONESHOT_W { w: self }
247    }
248    #[doc = "Bits 5:7 - Command"]
249    #[inline(always)]
250    pub fn cmd(&mut self) -> CMD_W {
251        CMD_W { w: self }
252    }
253}