ra4e1/spi0/
spdcr.rs

1#[doc = "Register `SPDCR` reader"]
2pub struct R(crate::R<SPDCR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<SPDCR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<SPDCR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<SPDCR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `SPDCR` writer"]
17pub struct W(crate::W<SPDCR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<SPDCR_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<SPDCR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<SPDCR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `SPFC` reader - Number of Frames Specification"]
38pub type SPFC_R = crate::FieldReader<u8, SPFC_A>;
39#[doc = "Number of Frames Specification\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum SPFC_A {
43    #[doc = "0: 1 frame"]
44    _00 = 0,
45    #[doc = "1: 2 frames"]
46    _01 = 1,
47    #[doc = "2: 3 frames"]
48    _10 = 2,
49    #[doc = "3: 4 frames"]
50    _11 = 3,
51}
52impl From<SPFC_A> for u8 {
53    #[inline(always)]
54    fn from(variant: SPFC_A) -> Self {
55        variant as _
56    }
57}
58impl SPFC_R {
59    #[doc = "Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> SPFC_A {
62        match self.bits {
63            0 => SPFC_A::_00,
64            1 => SPFC_A::_01,
65            2 => SPFC_A::_10,
66            3 => SPFC_A::_11,
67            _ => unreachable!(),
68        }
69    }
70    #[doc = "Checks if the value of the field is `_00`"]
71    #[inline(always)]
72    pub fn is_00(&self) -> bool {
73        *self == SPFC_A::_00
74    }
75    #[doc = "Checks if the value of the field is `_01`"]
76    #[inline(always)]
77    pub fn is_01(&self) -> bool {
78        *self == SPFC_A::_01
79    }
80    #[doc = "Checks if the value of the field is `_10`"]
81    #[inline(always)]
82    pub fn is_10(&self) -> bool {
83        *self == SPFC_A::_10
84    }
85    #[doc = "Checks if the value of the field is `_11`"]
86    #[inline(always)]
87    pub fn is_11(&self) -> bool {
88        *self == SPFC_A::_11
89    }
90}
91#[doc = "Field `SPFC` writer - Number of Frames Specification"]
92pub type SPFC_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, SPDCR_SPEC, u8, SPFC_A, 2, O>;
93impl<'a, const O: u8> SPFC_W<'a, O> {
94    #[doc = "1 frame"]
95    #[inline(always)]
96    pub fn _00(self) -> &'a mut W {
97        self.variant(SPFC_A::_00)
98    }
99    #[doc = "2 frames"]
100    #[inline(always)]
101    pub fn _01(self) -> &'a mut W {
102        self.variant(SPFC_A::_01)
103    }
104    #[doc = "3 frames"]
105    #[inline(always)]
106    pub fn _10(self) -> &'a mut W {
107        self.variant(SPFC_A::_10)
108    }
109    #[doc = "4 frames"]
110    #[inline(always)]
111    pub fn _11(self) -> &'a mut W {
112        self.variant(SPFC_A::_11)
113    }
114}
115#[doc = "Field `SPRDTD` reader - SPI Receive/Transmit Data Select"]
116pub type SPRDTD_R = crate::BitReader<SPRDTD_A>;
117#[doc = "SPI Receive/Transmit Data Select\n\nValue on reset: 0"]
118#[derive(Clone, Copy, Debug, PartialEq, Eq)]
119pub enum SPRDTD_A {
120    #[doc = "0: Read SPDR/SPDR_HA values from receive buffer"]
121    _0 = 0,
122    #[doc = "1: Read SPDR/SPDR_HA values from transmit buffer, but only if the transmit buffer is empty"]
123    _1 = 1,
124}
125impl From<SPRDTD_A> for bool {
126    #[inline(always)]
127    fn from(variant: SPRDTD_A) -> Self {
128        variant as u8 != 0
129    }
130}
131impl SPRDTD_R {
132    #[doc = "Get enumerated values variant"]
133    #[inline(always)]
134    pub fn variant(&self) -> SPRDTD_A {
135        match self.bits {
136            false => SPRDTD_A::_0,
137            true => SPRDTD_A::_1,
138        }
139    }
140    #[doc = "Checks if the value of the field is `_0`"]
141    #[inline(always)]
142    pub fn is_0(&self) -> bool {
143        *self == SPRDTD_A::_0
144    }
145    #[doc = "Checks if the value of the field is `_1`"]
146    #[inline(always)]
147    pub fn is_1(&self) -> bool {
148        *self == SPRDTD_A::_1
149    }
150}
151#[doc = "Field `SPRDTD` writer - SPI Receive/Transmit Data Select"]
152pub type SPRDTD_W<'a, const O: u8> = crate::BitWriter<'a, u8, SPDCR_SPEC, SPRDTD_A, O>;
153impl<'a, const O: u8> SPRDTD_W<'a, O> {
154    #[doc = "Read SPDR/SPDR_HA values from receive buffer"]
155    #[inline(always)]
156    pub fn _0(self) -> &'a mut W {
157        self.variant(SPRDTD_A::_0)
158    }
159    #[doc = "Read SPDR/SPDR_HA values from transmit buffer, but only if the transmit buffer is empty"]
160    #[inline(always)]
161    pub fn _1(self) -> &'a mut W {
162        self.variant(SPRDTD_A::_1)
163    }
164}
165#[doc = "Field `SPLW` reader - SPI Word Access/Halfword Access Specification"]
166pub type SPLW_R = crate::BitReader<SPLW_A>;
167#[doc = "SPI Word Access/Halfword Access Specification\n\nValue on reset: 0"]
168#[derive(Clone, Copy, Debug, PartialEq, Eq)]
169pub enum SPLW_A {
170    #[doc = "0: Set SPDR_HA to valid for halfword access"]
171    _0 = 0,
172    #[doc = "1: Set SPDR to valid for word access"]
173    _1 = 1,
174}
175impl From<SPLW_A> for bool {
176    #[inline(always)]
177    fn from(variant: SPLW_A) -> Self {
178        variant as u8 != 0
179    }
180}
181impl SPLW_R {
182    #[doc = "Get enumerated values variant"]
183    #[inline(always)]
184    pub fn variant(&self) -> SPLW_A {
185        match self.bits {
186            false => SPLW_A::_0,
187            true => SPLW_A::_1,
188        }
189    }
190    #[doc = "Checks if the value of the field is `_0`"]
191    #[inline(always)]
192    pub fn is_0(&self) -> bool {
193        *self == SPLW_A::_0
194    }
195    #[doc = "Checks if the value of the field is `_1`"]
196    #[inline(always)]
197    pub fn is_1(&self) -> bool {
198        *self == SPLW_A::_1
199    }
200}
201#[doc = "Field `SPLW` writer - SPI Word Access/Halfword Access Specification"]
202pub type SPLW_W<'a, const O: u8> = crate::BitWriter<'a, u8, SPDCR_SPEC, SPLW_A, O>;
203impl<'a, const O: u8> SPLW_W<'a, O> {
204    #[doc = "Set SPDR_HA to valid for halfword access"]
205    #[inline(always)]
206    pub fn _0(self) -> &'a mut W {
207        self.variant(SPLW_A::_0)
208    }
209    #[doc = "Set SPDR to valid for word access"]
210    #[inline(always)]
211    pub fn _1(self) -> &'a mut W {
212        self.variant(SPLW_A::_1)
213    }
214}
215#[doc = "Field `SPBYT` reader - SPI Byte Access Specification"]
216pub type SPBYT_R = crate::BitReader<SPBYT_A>;
217#[doc = "SPI Byte Access Specification\n\nValue on reset: 0"]
218#[derive(Clone, Copy, Debug, PartialEq, Eq)]
219pub enum SPBYT_A {
220    #[doc = "0: SPDR/SPDR_HA is accessed in halfword or word (SPLW is valid)"]
221    _0 = 0,
222    #[doc = "1: SPDR_BY is accessed in byte (SPLW is invalid)"]
223    _1 = 1,
224}
225impl From<SPBYT_A> for bool {
226    #[inline(always)]
227    fn from(variant: SPBYT_A) -> Self {
228        variant as u8 != 0
229    }
230}
231impl SPBYT_R {
232    #[doc = "Get enumerated values variant"]
233    #[inline(always)]
234    pub fn variant(&self) -> SPBYT_A {
235        match self.bits {
236            false => SPBYT_A::_0,
237            true => SPBYT_A::_1,
238        }
239    }
240    #[doc = "Checks if the value of the field is `_0`"]
241    #[inline(always)]
242    pub fn is_0(&self) -> bool {
243        *self == SPBYT_A::_0
244    }
245    #[doc = "Checks if the value of the field is `_1`"]
246    #[inline(always)]
247    pub fn is_1(&self) -> bool {
248        *self == SPBYT_A::_1
249    }
250}
251#[doc = "Field `SPBYT` writer - SPI Byte Access Specification"]
252pub type SPBYT_W<'a, const O: u8> = crate::BitWriter<'a, u8, SPDCR_SPEC, SPBYT_A, O>;
253impl<'a, const O: u8> SPBYT_W<'a, O> {
254    #[doc = "SPDR/SPDR_HA is accessed in halfword or word (SPLW is valid)"]
255    #[inline(always)]
256    pub fn _0(self) -> &'a mut W {
257        self.variant(SPBYT_A::_0)
258    }
259    #[doc = "SPDR_BY is accessed in byte (SPLW is invalid)"]
260    #[inline(always)]
261    pub fn _1(self) -> &'a mut W {
262        self.variant(SPBYT_A::_1)
263    }
264}
265impl R {
266    #[doc = "Bits 0:1 - Number of Frames Specification"]
267    #[inline(always)]
268    pub fn spfc(&self) -> SPFC_R {
269        SPFC_R::new(self.bits & 3)
270    }
271    #[doc = "Bit 4 - SPI Receive/Transmit Data Select"]
272    #[inline(always)]
273    pub fn sprdtd(&self) -> SPRDTD_R {
274        SPRDTD_R::new(((self.bits >> 4) & 1) != 0)
275    }
276    #[doc = "Bit 5 - SPI Word Access/Halfword Access Specification"]
277    #[inline(always)]
278    pub fn splw(&self) -> SPLW_R {
279        SPLW_R::new(((self.bits >> 5) & 1) != 0)
280    }
281    #[doc = "Bit 6 - SPI Byte Access Specification"]
282    #[inline(always)]
283    pub fn spbyt(&self) -> SPBYT_R {
284        SPBYT_R::new(((self.bits >> 6) & 1) != 0)
285    }
286}
287impl W {
288    #[doc = "Bits 0:1 - Number of Frames Specification"]
289    #[inline(always)]
290    #[must_use]
291    pub fn spfc(&mut self) -> SPFC_W<0> {
292        SPFC_W::new(self)
293    }
294    #[doc = "Bit 4 - SPI Receive/Transmit Data Select"]
295    #[inline(always)]
296    #[must_use]
297    pub fn sprdtd(&mut self) -> SPRDTD_W<4> {
298        SPRDTD_W::new(self)
299    }
300    #[doc = "Bit 5 - SPI Word Access/Halfword Access Specification"]
301    #[inline(always)]
302    #[must_use]
303    pub fn splw(&mut self) -> SPLW_W<5> {
304        SPLW_W::new(self)
305    }
306    #[doc = "Bit 6 - SPI Byte Access Specification"]
307    #[inline(always)]
308    #[must_use]
309    pub fn spbyt(&mut self) -> SPBYT_W<6> {
310        SPBYT_W::new(self)
311    }
312    #[doc = "Writes raw bits to the register."]
313    #[inline(always)]
314    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
315        self.0.bits(bits);
316        self
317    }
318}
319#[doc = "SPI Data Control 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 [spdcr](index.html) module"]
320pub struct SPDCR_SPEC;
321impl crate::RegisterSpec for SPDCR_SPEC {
322    type Ux = u8;
323}
324#[doc = "`read()` method returns [spdcr::R](R) reader structure"]
325impl crate::Readable for SPDCR_SPEC {
326    type Reader = R;
327}
328#[doc = "`write(|w| ..)` method takes [spdcr::W](W) writer structure"]
329impl crate::Writable for SPDCR_SPEC {
330    type Writer = W;
331    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
332    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
333}
334#[doc = "`reset()` method sets SPDCR to value 0"]
335impl crate::Resettable for SPDCR_SPEC {
336    const RESET_VALUE: Self::Ux = 0;
337}