atsam4ls2b_pac/pdca/
mr.rs

1#[doc = "Register `MR%s` reader"]
2pub struct R(crate::R<MR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<MR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<MR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<MR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `MR%s` writer"]
17pub struct W(crate::W<MR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<MR_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<MR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<MR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `SIZE` reader - Transfer size"]
38pub type SIZE_R = crate::FieldReader<u8, SIZESELECT_A>;
39#[doc = "Transfer size\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum SIZESELECT_A {
43    #[doc = "0: `0`"]
44    BYTE = 0,
45    #[doc = "1: `1`"]
46    HALF_WORD = 1,
47    #[doc = "2: `10`"]
48    WORD = 2,
49}
50impl From<SIZESELECT_A> for u8 {
51    #[inline(always)]
52    fn from(variant: SIZESELECT_A) -> Self {
53        variant as _
54    }
55}
56impl SIZE_R {
57    #[doc = "Get enumerated values variant"]
58    #[inline(always)]
59    pub fn variant(&self) -> Option<SIZESELECT_A> {
60        match self.bits {
61            0 => Some(SIZESELECT_A::BYTE),
62            1 => Some(SIZESELECT_A::HALF_WORD),
63            2 => Some(SIZESELECT_A::WORD),
64            _ => None,
65        }
66    }
67    #[doc = "Checks if the value of the field is `BYTE`"]
68    #[inline(always)]
69    pub fn is_byte(&self) -> bool {
70        *self == SIZESELECT_A::BYTE
71    }
72    #[doc = "Checks if the value of the field is `HALF_WORD`"]
73    #[inline(always)]
74    pub fn is_half_word(&self) -> bool {
75        *self == SIZESELECT_A::HALF_WORD
76    }
77    #[doc = "Checks if the value of the field is `WORD`"]
78    #[inline(always)]
79    pub fn is_word(&self) -> bool {
80        *self == SIZESELECT_A::WORD
81    }
82}
83#[doc = "Field `SIZE` writer - Transfer size"]
84pub type SIZE_W<'a, const O: u8> = crate::FieldWriter<'a, u32, MR_SPEC, u8, SIZESELECT_A, 2, O>;
85impl<'a, const O: u8> SIZE_W<'a, O> {
86    #[doc = "`0`"]
87    #[inline(always)]
88    pub fn byte(self) -> &'a mut W {
89        self.variant(SIZESELECT_A::BYTE)
90    }
91    #[doc = "`1`"]
92    #[inline(always)]
93    pub fn half_word(self) -> &'a mut W {
94        self.variant(SIZESELECT_A::HALF_WORD)
95    }
96    #[doc = "`10`"]
97    #[inline(always)]
98    pub fn word(self) -> &'a mut W {
99        self.variant(SIZESELECT_A::WORD)
100    }
101}
102#[doc = "Field `ETRIG` reader - Event trigger"]
103pub type ETRIG_R = crate::BitReader<bool>;
104#[doc = "Field `ETRIG` writer - Event trigger"]
105pub type ETRIG_W<'a, const O: u8> = crate::BitWriter<'a, u32, MR_SPEC, bool, O>;
106#[doc = "Field `RING` reader - Ring Buffer"]
107pub type RING_R = crate::BitReader<bool>;
108#[doc = "Field `RING` writer - Ring Buffer"]
109pub type RING_W<'a, const O: u8> = crate::BitWriter<'a, u32, MR_SPEC, bool, O>;
110impl R {
111    #[doc = "Bits 0:1 - Transfer size"]
112    #[inline(always)]
113    pub fn size(&self) -> SIZE_R {
114        SIZE_R::new((self.bits & 3) as u8)
115    }
116    #[doc = "Bit 2 - Event trigger"]
117    #[inline(always)]
118    pub fn etrig(&self) -> ETRIG_R {
119        ETRIG_R::new(((self.bits >> 2) & 1) != 0)
120    }
121    #[doc = "Bit 3 - Ring Buffer"]
122    #[inline(always)]
123    pub fn ring(&self) -> RING_R {
124        RING_R::new(((self.bits >> 3) & 1) != 0)
125    }
126}
127impl W {
128    #[doc = "Bits 0:1 - Transfer size"]
129    #[inline(always)]
130    #[must_use]
131    pub fn size(&mut self) -> SIZE_W<0> {
132        SIZE_W::new(self)
133    }
134    #[doc = "Bit 2 - Event trigger"]
135    #[inline(always)]
136    #[must_use]
137    pub fn etrig(&mut self) -> ETRIG_W<2> {
138        ETRIG_W::new(self)
139    }
140    #[doc = "Bit 3 - Ring Buffer"]
141    #[inline(always)]
142    #[must_use]
143    pub fn ring(&mut self) -> RING_W<3> {
144        RING_W::new(self)
145    }
146    #[doc = "Writes raw bits to the register."]
147    #[inline(always)]
148    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
149        self.0.bits(bits);
150        self
151    }
152}
153#[doc = "Mode Register\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 [mr](index.html) module"]
154pub struct MR_SPEC;
155impl crate::RegisterSpec for MR_SPEC {
156    type Ux = u32;
157}
158#[doc = "`read()` method returns [mr::R](R) reader structure"]
159impl crate::Readable for MR_SPEC {
160    type Reader = R;
161}
162#[doc = "`write(|w| ..)` method takes [mr::W](W) writer structure"]
163impl crate::Writable for MR_SPEC {
164    type Writer = W;
165    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
166    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
167}
168#[doc = "`reset()` method sets MR%s to value 0"]
169impl crate::Resettable for MR_SPEC {
170    const RESET_VALUE: Self::Ux = 0;
171}