atsaml21e16b/ccl/
lutctrl.rs

1#[doc = "Register `LUTCTRL%s` reader"]
2pub struct R(crate::R<LUTCTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<LUTCTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<LUTCTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<LUTCTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `LUTCTRL%s` writer"]
17pub struct W(crate::W<LUTCTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<LUTCTRL_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<LUTCTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<LUTCTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `ENABLE` reader - LUT Enable"]
38pub type ENABLE_R = crate::BitReader<bool>;
39#[doc = "Field `ENABLE` writer - LUT Enable"]
40pub type ENABLE_W<'a, const O: u8> = crate::BitWriter<'a, u32, LUTCTRL_SPEC, bool, O>;
41#[doc = "Field `FILTSEL` reader - Filter Selection"]
42pub type FILTSEL_R = crate::FieldReader<u8, FILTSELSELECT_A>;
43#[doc = "Filter Selection\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum FILTSELSELECT_A {
47    #[doc = "0: Filter disabled"]
48    DISABLE = 0,
49    #[doc = "1: Synchronizer enabled"]
50    SYNCH = 1,
51    #[doc = "2: Filter enabled"]
52    FILTER = 2,
53}
54impl From<FILTSELSELECT_A> for u8 {
55    #[inline(always)]
56    fn from(variant: FILTSELSELECT_A) -> Self {
57        variant as _
58    }
59}
60impl FILTSEL_R {
61    #[doc = "Get enumerated values variant"]
62    #[inline(always)]
63    pub fn variant(&self) -> Option<FILTSELSELECT_A> {
64        match self.bits {
65            0 => Some(FILTSELSELECT_A::DISABLE),
66            1 => Some(FILTSELSELECT_A::SYNCH),
67            2 => Some(FILTSELSELECT_A::FILTER),
68            _ => None,
69        }
70    }
71    #[doc = "Checks if the value of the field is `DISABLE`"]
72    #[inline(always)]
73    pub fn is_disable(&self) -> bool {
74        *self == FILTSELSELECT_A::DISABLE
75    }
76    #[doc = "Checks if the value of the field is `SYNCH`"]
77    #[inline(always)]
78    pub fn is_synch(&self) -> bool {
79        *self == FILTSELSELECT_A::SYNCH
80    }
81    #[doc = "Checks if the value of the field is `FILTER`"]
82    #[inline(always)]
83    pub fn is_filter(&self) -> bool {
84        *self == FILTSELSELECT_A::FILTER
85    }
86}
87#[doc = "Field `FILTSEL` writer - Filter Selection"]
88pub type FILTSEL_W<'a, const O: u8> =
89    crate::FieldWriter<'a, u32, LUTCTRL_SPEC, u8, FILTSELSELECT_A, 2, O>;
90impl<'a, const O: u8> FILTSEL_W<'a, O> {
91    #[doc = "Filter disabled"]
92    #[inline(always)]
93    pub fn disable(self) -> &'a mut W {
94        self.variant(FILTSELSELECT_A::DISABLE)
95    }
96    #[doc = "Synchronizer enabled"]
97    #[inline(always)]
98    pub fn synch(self) -> &'a mut W {
99        self.variant(FILTSELSELECT_A::SYNCH)
100    }
101    #[doc = "Filter enabled"]
102    #[inline(always)]
103    pub fn filter(self) -> &'a mut W {
104        self.variant(FILTSELSELECT_A::FILTER)
105    }
106}
107#[doc = "Field `EDGESEL` reader - Edge Selection"]
108pub type EDGESEL_R = crate::BitReader<bool>;
109#[doc = "Field `EDGESEL` writer - Edge Selection"]
110pub type EDGESEL_W<'a, const O: u8> = crate::BitWriter<'a, u32, LUTCTRL_SPEC, bool, O>;
111#[doc = "Field `INSEL0` reader - Input Selection 0"]
112pub type INSEL0_R = crate::FieldReader<u8, INSEL0SELECT_A>;
113#[doc = "Input Selection 0\n\nValue on reset: 0"]
114#[derive(Clone, Copy, Debug, PartialEq, Eq)]
115#[repr(u8)]
116pub enum INSEL0SELECT_A {
117    #[doc = "0: Masked input"]
118    MASK = 0,
119    #[doc = "1: Feedback input source"]
120    FEEDBACK = 1,
121    #[doc = "2: Linked LUT input source"]
122    LINK = 2,
123    #[doc = "3: Event in put source"]
124    EVENT = 3,
125    #[doc = "4: I/O pin input source"]
126    IO = 4,
127    #[doc = "5: AC input source"]
128    AC = 5,
129    #[doc = "6: TC input source"]
130    TC = 6,
131    #[doc = "7: Alternate TC input source"]
132    ALTTC = 7,
133    #[doc = "8: TCC input source"]
134    TCC = 8,
135    #[doc = "9: SERCOM inout source"]
136    SERCOM = 9,
137}
138impl From<INSEL0SELECT_A> for u8 {
139    #[inline(always)]
140    fn from(variant: INSEL0SELECT_A) -> Self {
141        variant as _
142    }
143}
144impl INSEL0_R {
145    #[doc = "Get enumerated values variant"]
146    #[inline(always)]
147    pub fn variant(&self) -> Option<INSEL0SELECT_A> {
148        match self.bits {
149            0 => Some(INSEL0SELECT_A::MASK),
150            1 => Some(INSEL0SELECT_A::FEEDBACK),
151            2 => Some(INSEL0SELECT_A::LINK),
152            3 => Some(INSEL0SELECT_A::EVENT),
153            4 => Some(INSEL0SELECT_A::IO),
154            5 => Some(INSEL0SELECT_A::AC),
155            6 => Some(INSEL0SELECT_A::TC),
156            7 => Some(INSEL0SELECT_A::ALTTC),
157            8 => Some(INSEL0SELECT_A::TCC),
158            9 => Some(INSEL0SELECT_A::SERCOM),
159            _ => None,
160        }
161    }
162    #[doc = "Checks if the value of the field is `MASK`"]
163    #[inline(always)]
164    pub fn is_mask(&self) -> bool {
165        *self == INSEL0SELECT_A::MASK
166    }
167    #[doc = "Checks if the value of the field is `FEEDBACK`"]
168    #[inline(always)]
169    pub fn is_feedback(&self) -> bool {
170        *self == INSEL0SELECT_A::FEEDBACK
171    }
172    #[doc = "Checks if the value of the field is `LINK`"]
173    #[inline(always)]
174    pub fn is_link(&self) -> bool {
175        *self == INSEL0SELECT_A::LINK
176    }
177    #[doc = "Checks if the value of the field is `EVENT`"]
178    #[inline(always)]
179    pub fn is_event(&self) -> bool {
180        *self == INSEL0SELECT_A::EVENT
181    }
182    #[doc = "Checks if the value of the field is `IO`"]
183    #[inline(always)]
184    pub fn is_io(&self) -> bool {
185        *self == INSEL0SELECT_A::IO
186    }
187    #[doc = "Checks if the value of the field is `AC`"]
188    #[inline(always)]
189    pub fn is_ac(&self) -> bool {
190        *self == INSEL0SELECT_A::AC
191    }
192    #[doc = "Checks if the value of the field is `TC`"]
193    #[inline(always)]
194    pub fn is_tc(&self) -> bool {
195        *self == INSEL0SELECT_A::TC
196    }
197    #[doc = "Checks if the value of the field is `ALTTC`"]
198    #[inline(always)]
199    pub fn is_alttc(&self) -> bool {
200        *self == INSEL0SELECT_A::ALTTC
201    }
202    #[doc = "Checks if the value of the field is `TCC`"]
203    #[inline(always)]
204    pub fn is_tcc(&self) -> bool {
205        *self == INSEL0SELECT_A::TCC
206    }
207    #[doc = "Checks if the value of the field is `SERCOM`"]
208    #[inline(always)]
209    pub fn is_sercom(&self) -> bool {
210        *self == INSEL0SELECT_A::SERCOM
211    }
212}
213#[doc = "Field `INSEL0` writer - Input Selection 0"]
214pub type INSEL0_W<'a, const O: u8> =
215    crate::FieldWriter<'a, u32, LUTCTRL_SPEC, u8, INSEL0SELECT_A, 4, O>;
216impl<'a, const O: u8> INSEL0_W<'a, O> {
217    #[doc = "Masked input"]
218    #[inline(always)]
219    pub fn mask(self) -> &'a mut W {
220        self.variant(INSEL0SELECT_A::MASK)
221    }
222    #[doc = "Feedback input source"]
223    #[inline(always)]
224    pub fn feedback(self) -> &'a mut W {
225        self.variant(INSEL0SELECT_A::FEEDBACK)
226    }
227    #[doc = "Linked LUT input source"]
228    #[inline(always)]
229    pub fn link(self) -> &'a mut W {
230        self.variant(INSEL0SELECT_A::LINK)
231    }
232    #[doc = "Event in put source"]
233    #[inline(always)]
234    pub fn event(self) -> &'a mut W {
235        self.variant(INSEL0SELECT_A::EVENT)
236    }
237    #[doc = "I/O pin input source"]
238    #[inline(always)]
239    pub fn io(self) -> &'a mut W {
240        self.variant(INSEL0SELECT_A::IO)
241    }
242    #[doc = "AC input source"]
243    #[inline(always)]
244    pub fn ac(self) -> &'a mut W {
245        self.variant(INSEL0SELECT_A::AC)
246    }
247    #[doc = "TC input source"]
248    #[inline(always)]
249    pub fn tc(self) -> &'a mut W {
250        self.variant(INSEL0SELECT_A::TC)
251    }
252    #[doc = "Alternate TC input source"]
253    #[inline(always)]
254    pub fn alttc(self) -> &'a mut W {
255        self.variant(INSEL0SELECT_A::ALTTC)
256    }
257    #[doc = "TCC input source"]
258    #[inline(always)]
259    pub fn tcc(self) -> &'a mut W {
260        self.variant(INSEL0SELECT_A::TCC)
261    }
262    #[doc = "SERCOM inout source"]
263    #[inline(always)]
264    pub fn sercom(self) -> &'a mut W {
265        self.variant(INSEL0SELECT_A::SERCOM)
266    }
267}
268#[doc = "Field `INSEL1` reader - Input Selection 1"]
269pub type INSEL1_R = crate::FieldReader<u8, u8>;
270#[doc = "Field `INSEL1` writer - Input Selection 1"]
271pub type INSEL1_W<'a, const O: u8> = crate::FieldWriter<'a, u32, LUTCTRL_SPEC, u8, u8, 4, O>;
272#[doc = "Field `INSEL2` reader - Input Selection 2"]
273pub type INSEL2_R = crate::FieldReader<u8, u8>;
274#[doc = "Field `INSEL2` writer - Input Selection 2"]
275pub type INSEL2_W<'a, const O: u8> = crate::FieldWriter<'a, u32, LUTCTRL_SPEC, u8, u8, 4, O>;
276#[doc = "Field `INVEI` reader - Input Event Invert"]
277pub type INVEI_R = crate::BitReader<bool>;
278#[doc = "Field `INVEI` writer - Input Event Invert"]
279pub type INVEI_W<'a, const O: u8> = crate::BitWriter<'a, u32, LUTCTRL_SPEC, bool, O>;
280#[doc = "Field `LUTEI` reader - Event Input Enable"]
281pub type LUTEI_R = crate::BitReader<bool>;
282#[doc = "Field `LUTEI` writer - Event Input Enable"]
283pub type LUTEI_W<'a, const O: u8> = crate::BitWriter<'a, u32, LUTCTRL_SPEC, bool, O>;
284#[doc = "Field `LUTEO` reader - Event Output Enable"]
285pub type LUTEO_R = crate::BitReader<bool>;
286#[doc = "Field `LUTEO` writer - Event Output Enable"]
287pub type LUTEO_W<'a, const O: u8> = crate::BitWriter<'a, u32, LUTCTRL_SPEC, bool, O>;
288#[doc = "Field `TRUTH` reader - Truth Value"]
289pub type TRUTH_R = crate::FieldReader<u8, u8>;
290#[doc = "Field `TRUTH` writer - Truth Value"]
291pub type TRUTH_W<'a, const O: u8> = crate::FieldWriter<'a, u32, LUTCTRL_SPEC, u8, u8, 8, O>;
292impl R {
293    #[doc = "Bit 1 - LUT Enable"]
294    #[inline(always)]
295    pub fn enable(&self) -> ENABLE_R {
296        ENABLE_R::new(((self.bits >> 1) & 1) != 0)
297    }
298    #[doc = "Bits 4:5 - Filter Selection"]
299    #[inline(always)]
300    pub fn filtsel(&self) -> FILTSEL_R {
301        FILTSEL_R::new(((self.bits >> 4) & 3) as u8)
302    }
303    #[doc = "Bit 7 - Edge Selection"]
304    #[inline(always)]
305    pub fn edgesel(&self) -> EDGESEL_R {
306        EDGESEL_R::new(((self.bits >> 7) & 1) != 0)
307    }
308    #[doc = "Bits 8:11 - Input Selection 0"]
309    #[inline(always)]
310    pub fn insel0(&self) -> INSEL0_R {
311        INSEL0_R::new(((self.bits >> 8) & 0x0f) as u8)
312    }
313    #[doc = "Bits 12:15 - Input Selection 1"]
314    #[inline(always)]
315    pub fn insel1(&self) -> INSEL1_R {
316        INSEL1_R::new(((self.bits >> 12) & 0x0f) as u8)
317    }
318    #[doc = "Bits 16:19 - Input Selection 2"]
319    #[inline(always)]
320    pub fn insel2(&self) -> INSEL2_R {
321        INSEL2_R::new(((self.bits >> 16) & 0x0f) as u8)
322    }
323    #[doc = "Bit 20 - Input Event Invert"]
324    #[inline(always)]
325    pub fn invei(&self) -> INVEI_R {
326        INVEI_R::new(((self.bits >> 20) & 1) != 0)
327    }
328    #[doc = "Bit 21 - Event Input Enable"]
329    #[inline(always)]
330    pub fn lutei(&self) -> LUTEI_R {
331        LUTEI_R::new(((self.bits >> 21) & 1) != 0)
332    }
333    #[doc = "Bit 22 - Event Output Enable"]
334    #[inline(always)]
335    pub fn luteo(&self) -> LUTEO_R {
336        LUTEO_R::new(((self.bits >> 22) & 1) != 0)
337    }
338    #[doc = "Bits 24:31 - Truth Value"]
339    #[inline(always)]
340    pub fn truth(&self) -> TRUTH_R {
341        TRUTH_R::new(((self.bits >> 24) & 0xff) as u8)
342    }
343}
344impl W {
345    #[doc = "Bit 1 - LUT Enable"]
346    #[inline(always)]
347    #[must_use]
348    pub fn enable(&mut self) -> ENABLE_W<1> {
349        ENABLE_W::new(self)
350    }
351    #[doc = "Bits 4:5 - Filter Selection"]
352    #[inline(always)]
353    #[must_use]
354    pub fn filtsel(&mut self) -> FILTSEL_W<4> {
355        FILTSEL_W::new(self)
356    }
357    #[doc = "Bit 7 - Edge Selection"]
358    #[inline(always)]
359    #[must_use]
360    pub fn edgesel(&mut self) -> EDGESEL_W<7> {
361        EDGESEL_W::new(self)
362    }
363    #[doc = "Bits 8:11 - Input Selection 0"]
364    #[inline(always)]
365    #[must_use]
366    pub fn insel0(&mut self) -> INSEL0_W<8> {
367        INSEL0_W::new(self)
368    }
369    #[doc = "Bits 12:15 - Input Selection 1"]
370    #[inline(always)]
371    #[must_use]
372    pub fn insel1(&mut self) -> INSEL1_W<12> {
373        INSEL1_W::new(self)
374    }
375    #[doc = "Bits 16:19 - Input Selection 2"]
376    #[inline(always)]
377    #[must_use]
378    pub fn insel2(&mut self) -> INSEL2_W<16> {
379        INSEL2_W::new(self)
380    }
381    #[doc = "Bit 20 - Input Event Invert"]
382    #[inline(always)]
383    #[must_use]
384    pub fn invei(&mut self) -> INVEI_W<20> {
385        INVEI_W::new(self)
386    }
387    #[doc = "Bit 21 - Event Input Enable"]
388    #[inline(always)]
389    #[must_use]
390    pub fn lutei(&mut self) -> LUTEI_W<21> {
391        LUTEI_W::new(self)
392    }
393    #[doc = "Bit 22 - Event Output Enable"]
394    #[inline(always)]
395    #[must_use]
396    pub fn luteo(&mut self) -> LUTEO_W<22> {
397        LUTEO_W::new(self)
398    }
399    #[doc = "Bits 24:31 - Truth Value"]
400    #[inline(always)]
401    #[must_use]
402    pub fn truth(&mut self) -> TRUTH_W<24> {
403        TRUTH_W::new(self)
404    }
405    #[doc = "Writes raw bits to the register."]
406    #[inline(always)]
407    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
408        self.0.bits(bits);
409        self
410    }
411}
412#[doc = "LUT Control x\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [lutctrl](index.html) module"]
413pub struct LUTCTRL_SPEC;
414impl crate::RegisterSpec for LUTCTRL_SPEC {
415    type Ux = u32;
416}
417#[doc = "`read()` method returns [lutctrl::R](R) reader structure"]
418impl crate::Readable for LUTCTRL_SPEC {
419    type Reader = R;
420}
421#[doc = "`write(|w| ..)` method takes [lutctrl::W](W) writer structure"]
422impl crate::Writable for LUTCTRL_SPEC {
423    type Writer = W;
424    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
425    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
426}
427#[doc = "`reset()` method sets LUTCTRL%s to value 0"]
428impl crate::Resettable for LUTCTRL_SPEC {
429    const RESET_VALUE: Self::Ux = 0;
430}