swm341_pac/spi0/
ctrl.rs

1#[doc = "Register `CTRL` reader"]
2pub struct R(crate::R<CTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CTRL` writer"]
17pub struct W(crate::W<CTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CTRL_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<CTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `CLKDIV` reader - CLKDIV field"]
38pub type CLKDIV_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `CLKDIV` writer - CLKDIV field"]
40pub type CLKDIV_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, u8, 3, O>;
41#[doc = "Field `EN` reader - EN field"]
42pub type EN_R = crate::BitReader<bool>;
43#[doc = "Field `EN` writer - EN field"]
44pub type EN_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
45#[doc = "Field `SIZE` reader - SIZE field"]
46pub type SIZE_R = crate::FieldReader<u8, u8>;
47#[doc = "Field `SIZE` writer - SIZE field"]
48pub type SIZE_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, u8, 4, O>;
49#[doc = "Field `CPHA` reader - CPHA field"]
50pub type CPHA_R = crate::BitReader<bool>;
51#[doc = "Field `CPHA` writer - CPHA field"]
52pub type CPHA_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
53#[doc = "Field `CPOL` reader - CPOL field"]
54pub type CPOL_R = crate::BitReader<bool>;
55#[doc = "Field `CPOL` writer - CPOL field"]
56pub type CPOL_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
57#[doc = "Field `FFS` reader - FFS field"]
58pub type FFS_R = crate::FieldReader<u8, u8>;
59#[doc = "Field `FFS` writer - FFS field"]
60pub type FFS_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, u8, 2, O>;
61#[doc = "Field `MSTR` reader - MSTR field"]
62pub type MSTR_R = crate::BitReader<bool>;
63#[doc = "Field `MSTR` writer - MSTR field"]
64pub type MSTR_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
65#[doc = "Field `FAST` reader - FAST field"]
66pub type FAST_R = crate::BitReader<bool>;
67#[doc = "Field `FAST` writer - FAST field"]
68pub type FAST_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
69#[doc = "Field `DMATXEN` reader - DMATXEN field"]
70pub type DMATXEN_R = crate::BitReader<bool>;
71#[doc = "Field `DMATXEN` writer - DMATXEN field"]
72pub type DMATXEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
73#[doc = "Field `DMARXEN` reader - DMARXEN field"]
74pub type DMARXEN_R = crate::BitReader<bool>;
75#[doc = "Field `DMARXEN` writer - DMARXEN field"]
76pub type DMARXEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
77#[doc = "Field `FILTE` reader - FILTE field"]
78pub type FILTE_R = crate::BitReader<bool>;
79#[doc = "Field `FILTE` writer - FILTE field"]
80pub type FILTE_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
81#[doc = "Field `SSN_H` reader - SSN_H field"]
82pub type SSN_H_R = crate::BitReader<bool>;
83#[doc = "Field `SSN_H` writer - SSN_H field"]
84pub type SSN_H_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
85#[doc = "Field `RFTHR` reader - RFTHR field"]
86pub type RFTHR_R = crate::FieldReader<u8, u8>;
87#[doc = "Field `RFTHR` writer - RFTHR field"]
88pub type RFTHR_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, u8, 3, O>;
89#[doc = "Field `TFTHR` reader - TFTHR field"]
90pub type TFTHR_R = crate::FieldReader<u8, u8>;
91#[doc = "Field `TFTHR` writer - TFTHR field"]
92pub type TFTHR_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, u8, 3, O>;
93#[doc = "Field `RFCLR` reader - RFCLR field"]
94pub type RFCLR_R = crate::BitReader<bool>;
95#[doc = "Field `RFCLR` writer - RFCLR field"]
96pub type RFCLR_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
97#[doc = "Field `TFCLR` reader - TFCLR field"]
98pub type TFCLR_R = crate::BitReader<bool>;
99#[doc = "Field `TFCLR` writer - TFCLR field"]
100pub type TFCLR_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
101#[doc = "Field `LSBF` reader - LSBF field"]
102pub type LSBF_R = crate::BitReader<bool>;
103#[doc = "Field `LSBF` writer - LSBF field"]
104pub type LSBF_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
105#[doc = "Field `NSYNC` reader - NSYNC field"]
106pub type NSYNC_R = crate::BitReader<bool>;
107#[doc = "Field `NSYNC` writer - NSYNC field"]
108pub type NSYNC_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
109impl R {
110    #[doc = "Bits 0:2 - CLKDIV field"]
111    #[inline(always)]
112    pub fn clkdiv(&self) -> CLKDIV_R {
113        CLKDIV_R::new((self.bits & 7) as u8)
114    }
115    #[doc = "Bit 3 - EN field"]
116    #[inline(always)]
117    pub fn en(&self) -> EN_R {
118        EN_R::new(((self.bits >> 3) & 1) != 0)
119    }
120    #[doc = "Bits 4:7 - SIZE field"]
121    #[inline(always)]
122    pub fn size(&self) -> SIZE_R {
123        SIZE_R::new(((self.bits >> 4) & 0x0f) as u8)
124    }
125    #[doc = "Bit 8 - CPHA field"]
126    #[inline(always)]
127    pub fn cpha(&self) -> CPHA_R {
128        CPHA_R::new(((self.bits >> 8) & 1) != 0)
129    }
130    #[doc = "Bit 9 - CPOL field"]
131    #[inline(always)]
132    pub fn cpol(&self) -> CPOL_R {
133        CPOL_R::new(((self.bits >> 9) & 1) != 0)
134    }
135    #[doc = "Bits 10:11 - FFS field"]
136    #[inline(always)]
137    pub fn ffs(&self) -> FFS_R {
138        FFS_R::new(((self.bits >> 10) & 3) as u8)
139    }
140    #[doc = "Bit 12 - MSTR field"]
141    #[inline(always)]
142    pub fn mstr(&self) -> MSTR_R {
143        MSTR_R::new(((self.bits >> 12) & 1) != 0)
144    }
145    #[doc = "Bit 13 - FAST field"]
146    #[inline(always)]
147    pub fn fast(&self) -> FAST_R {
148        FAST_R::new(((self.bits >> 13) & 1) != 0)
149    }
150    #[doc = "Bit 14 - DMATXEN field"]
151    #[inline(always)]
152    pub fn dmatxen(&self) -> DMATXEN_R {
153        DMATXEN_R::new(((self.bits >> 14) & 1) != 0)
154    }
155    #[doc = "Bit 15 - DMARXEN field"]
156    #[inline(always)]
157    pub fn dmarxen(&self) -> DMARXEN_R {
158        DMARXEN_R::new(((self.bits >> 15) & 1) != 0)
159    }
160    #[doc = "Bit 16 - FILTE field"]
161    #[inline(always)]
162    pub fn filte(&self) -> FILTE_R {
163        FILTE_R::new(((self.bits >> 16) & 1) != 0)
164    }
165    #[doc = "Bit 17 - SSN_H field"]
166    #[inline(always)]
167    pub fn ssn_h(&self) -> SSN_H_R {
168        SSN_H_R::new(((self.bits >> 17) & 1) != 0)
169    }
170    #[doc = "Bits 18:20 - RFTHR field"]
171    #[inline(always)]
172    pub fn rfthr(&self) -> RFTHR_R {
173        RFTHR_R::new(((self.bits >> 18) & 7) as u8)
174    }
175    #[doc = "Bits 21:23 - TFTHR field"]
176    #[inline(always)]
177    pub fn tfthr(&self) -> TFTHR_R {
178        TFTHR_R::new(((self.bits >> 21) & 7) as u8)
179    }
180    #[doc = "Bit 24 - RFCLR field"]
181    #[inline(always)]
182    pub fn rfclr(&self) -> RFCLR_R {
183        RFCLR_R::new(((self.bits >> 24) & 1) != 0)
184    }
185    #[doc = "Bit 25 - TFCLR field"]
186    #[inline(always)]
187    pub fn tfclr(&self) -> TFCLR_R {
188        TFCLR_R::new(((self.bits >> 25) & 1) != 0)
189    }
190    #[doc = "Bit 28 - LSBF field"]
191    #[inline(always)]
192    pub fn lsbf(&self) -> LSBF_R {
193        LSBF_R::new(((self.bits >> 28) & 1) != 0)
194    }
195    #[doc = "Bit 29 - NSYNC field"]
196    #[inline(always)]
197    pub fn nsync(&self) -> NSYNC_R {
198        NSYNC_R::new(((self.bits >> 29) & 1) != 0)
199    }
200}
201impl W {
202    #[doc = "Bits 0:2 - CLKDIV field"]
203    #[inline(always)]
204    pub fn clkdiv(&mut self) -> CLKDIV_W<0> {
205        CLKDIV_W::new(self)
206    }
207    #[doc = "Bit 3 - EN field"]
208    #[inline(always)]
209    pub fn en(&mut self) -> EN_W<3> {
210        EN_W::new(self)
211    }
212    #[doc = "Bits 4:7 - SIZE field"]
213    #[inline(always)]
214    pub fn size(&mut self) -> SIZE_W<4> {
215        SIZE_W::new(self)
216    }
217    #[doc = "Bit 8 - CPHA field"]
218    #[inline(always)]
219    pub fn cpha(&mut self) -> CPHA_W<8> {
220        CPHA_W::new(self)
221    }
222    #[doc = "Bit 9 - CPOL field"]
223    #[inline(always)]
224    pub fn cpol(&mut self) -> CPOL_W<9> {
225        CPOL_W::new(self)
226    }
227    #[doc = "Bits 10:11 - FFS field"]
228    #[inline(always)]
229    pub fn ffs(&mut self) -> FFS_W<10> {
230        FFS_W::new(self)
231    }
232    #[doc = "Bit 12 - MSTR field"]
233    #[inline(always)]
234    pub fn mstr(&mut self) -> MSTR_W<12> {
235        MSTR_W::new(self)
236    }
237    #[doc = "Bit 13 - FAST field"]
238    #[inline(always)]
239    pub fn fast(&mut self) -> FAST_W<13> {
240        FAST_W::new(self)
241    }
242    #[doc = "Bit 14 - DMATXEN field"]
243    #[inline(always)]
244    pub fn dmatxen(&mut self) -> DMATXEN_W<14> {
245        DMATXEN_W::new(self)
246    }
247    #[doc = "Bit 15 - DMARXEN field"]
248    #[inline(always)]
249    pub fn dmarxen(&mut self) -> DMARXEN_W<15> {
250        DMARXEN_W::new(self)
251    }
252    #[doc = "Bit 16 - FILTE field"]
253    #[inline(always)]
254    pub fn filte(&mut self) -> FILTE_W<16> {
255        FILTE_W::new(self)
256    }
257    #[doc = "Bit 17 - SSN_H field"]
258    #[inline(always)]
259    pub fn ssn_h(&mut self) -> SSN_H_W<17> {
260        SSN_H_W::new(self)
261    }
262    #[doc = "Bits 18:20 - RFTHR field"]
263    #[inline(always)]
264    pub fn rfthr(&mut self) -> RFTHR_W<18> {
265        RFTHR_W::new(self)
266    }
267    #[doc = "Bits 21:23 - TFTHR field"]
268    #[inline(always)]
269    pub fn tfthr(&mut self) -> TFTHR_W<21> {
270        TFTHR_W::new(self)
271    }
272    #[doc = "Bit 24 - RFCLR field"]
273    #[inline(always)]
274    pub fn rfclr(&mut self) -> RFCLR_W<24> {
275        RFCLR_W::new(self)
276    }
277    #[doc = "Bit 25 - TFCLR field"]
278    #[inline(always)]
279    pub fn tfclr(&mut self) -> TFCLR_W<25> {
280        TFCLR_W::new(self)
281    }
282    #[doc = "Bit 28 - LSBF field"]
283    #[inline(always)]
284    pub fn lsbf(&mut self) -> LSBF_W<28> {
285        LSBF_W::new(self)
286    }
287    #[doc = "Bit 29 - NSYNC field"]
288    #[inline(always)]
289    pub fn nsync(&mut self) -> NSYNC_W<29> {
290        NSYNC_W::new(self)
291    }
292    #[doc = "Writes raw bits to the register."]
293    #[inline(always)]
294    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
295        self.0.bits(bits);
296        self
297    }
298}
299#[doc = "CTRL 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 [ctrl](index.html) module"]
300pub struct CTRL_SPEC;
301impl crate::RegisterSpec for CTRL_SPEC {
302    type Ux = u32;
303}
304#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
305impl crate::Readable for CTRL_SPEC {
306    type Reader = R;
307}
308#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
309impl crate::Writable for CTRL_SPEC {
310    type Writer = W;
311}
312#[doc = "`reset()` method sets CTRL to value 0"]
313impl crate::Resettable for CTRL_SPEC {
314    #[inline(always)]
315    fn reset_value() -> Self::Ux {
316        0
317    }
318}