corstone300_pac/ssp0/
cr0.rs

1// Copyright 2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
2//
3// SPDX-License-Identifier: MIT
4
5#[doc = "Register `CR0` reader"]
6pub struct R(crate::R<CR0_SPEC>);
7impl core::ops::Deref for R {
8    type Target = crate::R<CR0_SPEC>;
9    #[inline(always)]
10    fn deref(&self) -> &Self::Target {
11        &self.0
12    }
13}
14impl From<crate::R<CR0_SPEC>> for R {
15    #[inline(always)]
16    fn from(reader: crate::R<CR0_SPEC>) -> Self {
17        R(reader)
18    }
19}
20#[doc = "Register `CR0` writer"]
21pub struct W(crate::W<CR0_SPEC>);
22impl core::ops::Deref for W {
23    type Target = crate::W<CR0_SPEC>;
24    #[inline(always)]
25    fn deref(&self) -> &Self::Target {
26        &self.0
27    }
28}
29impl core::ops::DerefMut for W {
30    #[inline(always)]
31    fn deref_mut(&mut self) -> &mut Self::Target {
32        &mut self.0
33    }
34}
35impl From<crate::W<CR0_SPEC>> for W {
36    #[inline(always)]
37    fn from(writer: crate::W<CR0_SPEC>) -> Self {
38        W(writer)
39    }
40}
41#[doc = "Field `DSS` reader - Data Size Select"]
42pub type DSS_R = crate::FieldReader<u8, DSS_A>;
43#[doc = "Data Size Select\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum DSS_A {
47    #[doc = "3: `11`"]
48    _4BIT = 3,
49    #[doc = "4: `100`"]
50    _5BIT = 4,
51    #[doc = "5: `101`"]
52    _6BIT = 5,
53    #[doc = "6: `110`"]
54    _7BIT = 6,
55    #[doc = "7: `111`"]
56    _8BIT = 7,
57    #[doc = "8: `1000`"]
58    _9BIT = 8,
59    #[doc = "9: `1001`"]
60    _10BIT = 9,
61    #[doc = "10: `1010`"]
62    _11BIT = 10,
63    #[doc = "11: `1011`"]
64    _12BIT = 11,
65    #[doc = "12: `1100`"]
66    _13BIT = 12,
67    #[doc = "13: `1101`"]
68    _14BIT = 13,
69    #[doc = "14: `1110`"]
70    _15BIT = 14,
71    #[doc = "15: `1111`"]
72    _16BIT = 15,
73}
74impl From<DSS_A> for u8 {
75    #[inline(always)]
76    fn from(variant: DSS_A) -> Self {
77        variant as _
78    }
79}
80impl DSS_R {
81    #[doc = "Get enumerated values variant"]
82    #[inline(always)]
83    pub fn variant(&self) -> Option<DSS_A> {
84        match self.bits {
85            3 => Some(DSS_A::_4BIT),
86            4 => Some(DSS_A::_5BIT),
87            5 => Some(DSS_A::_6BIT),
88            6 => Some(DSS_A::_7BIT),
89            7 => Some(DSS_A::_8BIT),
90            8 => Some(DSS_A::_9BIT),
91            9 => Some(DSS_A::_10BIT),
92            10 => Some(DSS_A::_11BIT),
93            11 => Some(DSS_A::_12BIT),
94            12 => Some(DSS_A::_13BIT),
95            13 => Some(DSS_A::_14BIT),
96            14 => Some(DSS_A::_15BIT),
97            15 => Some(DSS_A::_16BIT),
98            _ => None,
99        }
100    }
101    #[doc = "Checks if the value of the field is `_4BIT`"]
102    #[inline(always)]
103    pub fn is_4bit(&self) -> bool {
104        *self == DSS_A::_4BIT
105    }
106    #[doc = "Checks if the value of the field is `_5BIT`"]
107    #[inline(always)]
108    pub fn is_5bit(&self) -> bool {
109        *self == DSS_A::_5BIT
110    }
111    #[doc = "Checks if the value of the field is `_6BIT`"]
112    #[inline(always)]
113    pub fn is_6bit(&self) -> bool {
114        *self == DSS_A::_6BIT
115    }
116    #[doc = "Checks if the value of the field is `_7BIT`"]
117    #[inline(always)]
118    pub fn is_7bit(&self) -> bool {
119        *self == DSS_A::_7BIT
120    }
121    #[doc = "Checks if the value of the field is `_8BIT`"]
122    #[inline(always)]
123    pub fn is_8bit(&self) -> bool {
124        *self == DSS_A::_8BIT
125    }
126    #[doc = "Checks if the value of the field is `_9BIT`"]
127    #[inline(always)]
128    pub fn is_9bit(&self) -> bool {
129        *self == DSS_A::_9BIT
130    }
131    #[doc = "Checks if the value of the field is `_10BIT`"]
132    #[inline(always)]
133    pub fn is_10bit(&self) -> bool {
134        *self == DSS_A::_10BIT
135    }
136    #[doc = "Checks if the value of the field is `_11BIT`"]
137    #[inline(always)]
138    pub fn is_11bit(&self) -> bool {
139        *self == DSS_A::_11BIT
140    }
141    #[doc = "Checks if the value of the field is `_12BIT`"]
142    #[inline(always)]
143    pub fn is_12bit(&self) -> bool {
144        *self == DSS_A::_12BIT
145    }
146    #[doc = "Checks if the value of the field is `_13BIT`"]
147    #[inline(always)]
148    pub fn is_13bit(&self) -> bool {
149        *self == DSS_A::_13BIT
150    }
151    #[doc = "Checks if the value of the field is `_14BIT`"]
152    #[inline(always)]
153    pub fn is_14bit(&self) -> bool {
154        *self == DSS_A::_14BIT
155    }
156    #[doc = "Checks if the value of the field is `_15BIT`"]
157    #[inline(always)]
158    pub fn is_15bit(&self) -> bool {
159        *self == DSS_A::_15BIT
160    }
161    #[doc = "Checks if the value of the field is `_16BIT`"]
162    #[inline(always)]
163    pub fn is_16bit(&self) -> bool {
164        *self == DSS_A::_16BIT
165    }
166}
167#[doc = "Field `DSS` writer - Data Size Select"]
168pub type DSS_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CR0_SPEC, u8, DSS_A, 4, O>;
169impl<'a, const O: u8> DSS_W<'a, O> {
170    #[doc = "`11`"]
171    #[inline(always)]
172    pub fn _4bit(self) -> &'a mut W {
173        self.variant(DSS_A::_4BIT)
174    }
175    #[doc = "`100`"]
176    #[inline(always)]
177    pub fn _5bit(self) -> &'a mut W {
178        self.variant(DSS_A::_5BIT)
179    }
180    #[doc = "`101`"]
181    #[inline(always)]
182    pub fn _6bit(self) -> &'a mut W {
183        self.variant(DSS_A::_6BIT)
184    }
185    #[doc = "`110`"]
186    #[inline(always)]
187    pub fn _7bit(self) -> &'a mut W {
188        self.variant(DSS_A::_7BIT)
189    }
190    #[doc = "`111`"]
191    #[inline(always)]
192    pub fn _8bit(self) -> &'a mut W {
193        self.variant(DSS_A::_8BIT)
194    }
195    #[doc = "`1000`"]
196    #[inline(always)]
197    pub fn _9bit(self) -> &'a mut W {
198        self.variant(DSS_A::_9BIT)
199    }
200    #[doc = "`1001`"]
201    #[inline(always)]
202    pub fn _10bit(self) -> &'a mut W {
203        self.variant(DSS_A::_10BIT)
204    }
205    #[doc = "`1010`"]
206    #[inline(always)]
207    pub fn _11bit(self) -> &'a mut W {
208        self.variant(DSS_A::_11BIT)
209    }
210    #[doc = "`1011`"]
211    #[inline(always)]
212    pub fn _12bit(self) -> &'a mut W {
213        self.variant(DSS_A::_12BIT)
214    }
215    #[doc = "`1100`"]
216    #[inline(always)]
217    pub fn _13bit(self) -> &'a mut W {
218        self.variant(DSS_A::_13BIT)
219    }
220    #[doc = "`1101`"]
221    #[inline(always)]
222    pub fn _14bit(self) -> &'a mut W {
223        self.variant(DSS_A::_14BIT)
224    }
225    #[doc = "`1110`"]
226    #[inline(always)]
227    pub fn _15bit(self) -> &'a mut W {
228        self.variant(DSS_A::_15BIT)
229    }
230    #[doc = "`1111`"]
231    #[inline(always)]
232    pub fn _16bit(self) -> &'a mut W {
233        self.variant(DSS_A::_16BIT)
234    }
235}
236#[doc = "Field `FRF` reader - Frame format"]
237pub type FRF_R = crate::FieldReader<u8, FRF_A>;
238#[doc = "Frame format\n\nValue on reset: 0"]
239#[derive(Clone, Copy, Debug, PartialEq, Eq)]
240#[repr(u8)]
241pub enum FRF_A {
242    #[doc = "0: Motorola SPI frame format"]
243    MOTOROLA = 0,
244    #[doc = "1: TI synchronous serial frame format"]
245    TI = 1,
246    #[doc = "2: National Microwire frame format"]
247    NM = 2,
248}
249impl From<FRF_A> for u8 {
250    #[inline(always)]
251    fn from(variant: FRF_A) -> Self {
252        variant as _
253    }
254}
255impl FRF_R {
256    #[doc = "Get enumerated values variant"]
257    #[inline(always)]
258    pub fn variant(&self) -> Option<FRF_A> {
259        match self.bits {
260            0 => Some(FRF_A::MOTOROLA),
261            1 => Some(FRF_A::TI),
262            2 => Some(FRF_A::NM),
263            _ => None,
264        }
265    }
266    #[doc = "Checks if the value of the field is `MOTOROLA`"]
267    #[inline(always)]
268    pub fn is_motorola(&self) -> bool {
269        *self == FRF_A::MOTOROLA
270    }
271    #[doc = "Checks if the value of the field is `TI`"]
272    #[inline(always)]
273    pub fn is_ti(&self) -> bool {
274        *self == FRF_A::TI
275    }
276    #[doc = "Checks if the value of the field is `NM`"]
277    #[inline(always)]
278    pub fn is_nm(&self) -> bool {
279        *self == FRF_A::NM
280    }
281}
282#[doc = "Field `FRF` writer - Frame format"]
283pub type FRF_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CR0_SPEC, u8, FRF_A, 2, O>;
284impl<'a, const O: u8> FRF_W<'a, O> {
285    #[doc = "Motorola SPI frame format"]
286    #[inline(always)]
287    pub fn motorola(self) -> &'a mut W {
288        self.variant(FRF_A::MOTOROLA)
289    }
290    #[doc = "TI synchronous serial frame format"]
291    #[inline(always)]
292    pub fn ti(self) -> &'a mut W {
293        self.variant(FRF_A::TI)
294    }
295    #[doc = "National Microwire frame format"]
296    #[inline(always)]
297    pub fn nm(self) -> &'a mut W {
298        self.variant(FRF_A::NM)
299    }
300}
301#[doc = "Field `SPO` reader - SSPCLKOUT polarity"]
302pub type SPO_R = crate::BitReader<bool>;
303#[doc = "Field `SPO` writer - SSPCLKOUT polarity"]
304pub type SPO_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR0_SPEC, bool, O>;
305#[doc = "Field `SPH` reader - SSPCLKOUT phase"]
306pub type SPH_R = crate::BitReader<bool>;
307#[doc = "Field `SPH` writer - SSPCLKOUT phase"]
308pub type SPH_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR0_SPEC, bool, O>;
309#[doc = "Field `SCR` reader - Serial clock rate"]
310pub type SCR_R = crate::FieldReader<u8, u8>;
311#[doc = "Field `SCR` writer - Serial clock rate"]
312pub type SCR_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CR0_SPEC, u8, u8, 8, O>;
313impl R {
314    #[doc = "Bits 0:3 - Data Size Select"]
315    #[inline(always)]
316    pub fn dss(&self) -> DSS_R {
317        DSS_R::new((self.bits & 0x0f) as u8)
318    }
319    #[doc = "Bits 4:5 - Frame format"]
320    #[inline(always)]
321    pub fn frf(&self) -> FRF_R {
322        FRF_R::new(((self.bits >> 4) & 3) as u8)
323    }
324    #[doc = "Bit 6 - SSPCLKOUT polarity"]
325    #[inline(always)]
326    pub fn spo(&self) -> SPO_R {
327        SPO_R::new(((self.bits >> 6) & 1) != 0)
328    }
329    #[doc = "Bit 7 - SSPCLKOUT phase"]
330    #[inline(always)]
331    pub fn sph(&self) -> SPH_R {
332        SPH_R::new(((self.bits >> 7) & 1) != 0)
333    }
334    #[doc = "Bits 8:15 - Serial clock rate"]
335    #[inline(always)]
336    pub fn scr(&self) -> SCR_R {
337        SCR_R::new(((self.bits >> 8) & 0xff) as u8)
338    }
339}
340impl W {
341    #[doc = "Bits 0:3 - Data Size Select"]
342    #[inline(always)]
343    pub fn dss(&mut self) -> DSS_W<0> {
344        DSS_W::new(self)
345    }
346    #[doc = "Bits 4:5 - Frame format"]
347    #[inline(always)]
348    pub fn frf(&mut self) -> FRF_W<4> {
349        FRF_W::new(self)
350    }
351    #[doc = "Bit 6 - SSPCLKOUT polarity"]
352    #[inline(always)]
353    pub fn spo(&mut self) -> SPO_W<6> {
354        SPO_W::new(self)
355    }
356    #[doc = "Bit 7 - SSPCLKOUT phase"]
357    #[inline(always)]
358    pub fn sph(&mut self) -> SPH_W<7> {
359        SPH_W::new(self)
360    }
361    #[doc = "Bits 8:15 - Serial clock rate"]
362    #[inline(always)]
363    pub fn scr(&mut self) -> SCR_W<8> {
364        SCR_W::new(self)
365    }
366    #[doc = "Writes raw bits to the register."]
367    #[inline(always)]
368    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
369        self.0.bits(bits);
370        self
371    }
372}
373#[doc = "Control register 0\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 [cr0](index.html) module"]
374pub struct CR0_SPEC;
375impl crate::RegisterSpec for CR0_SPEC {
376    type Ux = u32;
377}
378#[doc = "`read()` method returns [cr0::R](R) reader structure"]
379impl crate::Readable for CR0_SPEC {
380    type Reader = R;
381}
382#[doc = "`write(|w| ..)` method takes [cr0::W](W) writer structure"]
383impl crate::Writable for CR0_SPEC {
384    type Writer = W;
385}
386#[doc = "`reset()` method sets CR0 to value 0"]
387impl crate::Resettable for CR0_SPEC {
388    #[inline(always)]
389    fn reset_value() -> Self::Ux {
390        0
391    }
392}