stm32wb_pac/spi1/
cr1.rs

1#[doc = "Reader of register CR1"]
2pub type R = crate::R<u32, super::CR1>;
3#[doc = "Writer for register CR1"]
4pub type W = crate::W<u32, super::CR1>;
5#[doc = "Register CR1 `reset()`'s with value 0"]
6impl crate::ResetValue for super::CR1 {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `BIDIMODE`"]
14pub type BIDIMODE_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `BIDIMODE`"]
16pub struct BIDIMODE_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> BIDIMODE_W<'a> {
20    #[doc = r"Sets the field bit"]
21    #[inline(always)]
22    pub fn set_bit(self) -> &'a mut W {
23        self.bit(true)
24    }
25    #[doc = r"Clears the field bit"]
26    #[inline(always)]
27    pub fn clear_bit(self) -> &'a mut W {
28        self.bit(false)
29    }
30    #[doc = r"Writes raw bits to the field"]
31    #[inline(always)]
32    pub fn bit(self, value: bool) -> &'a mut W {
33        self.w.bits = (self.w.bits & !(0x01 << 15)) | (((value as u32) & 0x01) << 15);
34        self.w
35    }
36}
37#[doc = "Reader of field `BIDIOE`"]
38pub type BIDIOE_R = crate::R<bool, bool>;
39#[doc = "Write proxy for field `BIDIOE`"]
40pub struct BIDIOE_W<'a> {
41    w: &'a mut W,
42}
43impl<'a> BIDIOE_W<'a> {
44    #[doc = r"Sets the field bit"]
45    #[inline(always)]
46    pub fn set_bit(self) -> &'a mut W {
47        self.bit(true)
48    }
49    #[doc = r"Clears the field bit"]
50    #[inline(always)]
51    pub fn clear_bit(self) -> &'a mut W {
52        self.bit(false)
53    }
54    #[doc = r"Writes raw bits to the field"]
55    #[inline(always)]
56    pub fn bit(self, value: bool) -> &'a mut W {
57        self.w.bits = (self.w.bits & !(0x01 << 14)) | (((value as u32) & 0x01) << 14);
58        self.w
59    }
60}
61#[doc = "Reader of field `CRCEN`"]
62pub type CRCEN_R = crate::R<bool, bool>;
63#[doc = "Write proxy for field `CRCEN`"]
64pub struct CRCEN_W<'a> {
65    w: &'a mut W,
66}
67impl<'a> CRCEN_W<'a> {
68    #[doc = r"Sets the field bit"]
69    #[inline(always)]
70    pub fn set_bit(self) -> &'a mut W {
71        self.bit(true)
72    }
73    #[doc = r"Clears the field bit"]
74    #[inline(always)]
75    pub fn clear_bit(self) -> &'a mut W {
76        self.bit(false)
77    }
78    #[doc = r"Writes raw bits to the field"]
79    #[inline(always)]
80    pub fn bit(self, value: bool) -> &'a mut W {
81        self.w.bits = (self.w.bits & !(0x01 << 13)) | (((value as u32) & 0x01) << 13);
82        self.w
83    }
84}
85#[doc = "Reader of field `CRCNEXT`"]
86pub type CRCNEXT_R = crate::R<bool, bool>;
87#[doc = "Write proxy for field `CRCNEXT`"]
88pub struct CRCNEXT_W<'a> {
89    w: &'a mut W,
90}
91impl<'a> CRCNEXT_W<'a> {
92    #[doc = r"Sets the field bit"]
93    #[inline(always)]
94    pub fn set_bit(self) -> &'a mut W {
95        self.bit(true)
96    }
97    #[doc = r"Clears the field bit"]
98    #[inline(always)]
99    pub fn clear_bit(self) -> &'a mut W {
100        self.bit(false)
101    }
102    #[doc = r"Writes raw bits to the field"]
103    #[inline(always)]
104    pub fn bit(self, value: bool) -> &'a mut W {
105        self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u32) & 0x01) << 12);
106        self.w
107    }
108}
109#[doc = "Reader of field `DFF`"]
110pub type DFF_R = crate::R<bool, bool>;
111#[doc = "Write proxy for field `DFF`"]
112pub struct DFF_W<'a> {
113    w: &'a mut W,
114}
115impl<'a> DFF_W<'a> {
116    #[doc = r"Sets the field bit"]
117    #[inline(always)]
118    pub fn set_bit(self) -> &'a mut W {
119        self.bit(true)
120    }
121    #[doc = r"Clears the field bit"]
122    #[inline(always)]
123    pub fn clear_bit(self) -> &'a mut W {
124        self.bit(false)
125    }
126    #[doc = r"Writes raw bits to the field"]
127    #[inline(always)]
128    pub fn bit(self, value: bool) -> &'a mut W {
129        self.w.bits = (self.w.bits & !(0x01 << 11)) | (((value as u32) & 0x01) << 11);
130        self.w
131    }
132}
133#[doc = "Reader of field `RXONLY`"]
134pub type RXONLY_R = crate::R<bool, bool>;
135#[doc = "Write proxy for field `RXONLY`"]
136pub struct RXONLY_W<'a> {
137    w: &'a mut W,
138}
139impl<'a> RXONLY_W<'a> {
140    #[doc = r"Sets the field bit"]
141    #[inline(always)]
142    pub fn set_bit(self) -> &'a mut W {
143        self.bit(true)
144    }
145    #[doc = r"Clears the field bit"]
146    #[inline(always)]
147    pub fn clear_bit(self) -> &'a mut W {
148        self.bit(false)
149    }
150    #[doc = r"Writes raw bits to the field"]
151    #[inline(always)]
152    pub fn bit(self, value: bool) -> &'a mut W {
153        self.w.bits = (self.w.bits & !(0x01 << 10)) | (((value as u32) & 0x01) << 10);
154        self.w
155    }
156}
157#[doc = "Reader of field `SSM`"]
158pub type SSM_R = crate::R<bool, bool>;
159#[doc = "Write proxy for field `SSM`"]
160pub struct SSM_W<'a> {
161    w: &'a mut W,
162}
163impl<'a> SSM_W<'a> {
164    #[doc = r"Sets the field bit"]
165    #[inline(always)]
166    pub fn set_bit(self) -> &'a mut W {
167        self.bit(true)
168    }
169    #[doc = r"Clears the field bit"]
170    #[inline(always)]
171    pub fn clear_bit(self) -> &'a mut W {
172        self.bit(false)
173    }
174    #[doc = r"Writes raw bits to the field"]
175    #[inline(always)]
176    pub fn bit(self, value: bool) -> &'a mut W {
177        self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u32) & 0x01) << 9);
178        self.w
179    }
180}
181#[doc = "Reader of field `SSI`"]
182pub type SSI_R = crate::R<bool, bool>;
183#[doc = "Write proxy for field `SSI`"]
184pub struct SSI_W<'a> {
185    w: &'a mut W,
186}
187impl<'a> SSI_W<'a> {
188    #[doc = r"Sets the field bit"]
189    #[inline(always)]
190    pub fn set_bit(self) -> &'a mut W {
191        self.bit(true)
192    }
193    #[doc = r"Clears the field bit"]
194    #[inline(always)]
195    pub fn clear_bit(self) -> &'a mut W {
196        self.bit(false)
197    }
198    #[doc = r"Writes raw bits to the field"]
199    #[inline(always)]
200    pub fn bit(self, value: bool) -> &'a mut W {
201        self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8);
202        self.w
203    }
204}
205#[doc = "Reader of field `LSBFIRST`"]
206pub type LSBFIRST_R = crate::R<bool, bool>;
207#[doc = "Write proxy for field `LSBFIRST`"]
208pub struct LSBFIRST_W<'a> {
209    w: &'a mut W,
210}
211impl<'a> LSBFIRST_W<'a> {
212    #[doc = r"Sets the field bit"]
213    #[inline(always)]
214    pub fn set_bit(self) -> &'a mut W {
215        self.bit(true)
216    }
217    #[doc = r"Clears the field bit"]
218    #[inline(always)]
219    pub fn clear_bit(self) -> &'a mut W {
220        self.bit(false)
221    }
222    #[doc = r"Writes raw bits to the field"]
223    #[inline(always)]
224    pub fn bit(self, value: bool) -> &'a mut W {
225        self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7);
226        self.w
227    }
228}
229#[doc = "Reader of field `SPE`"]
230pub type SPE_R = crate::R<bool, bool>;
231#[doc = "Write proxy for field `SPE`"]
232pub struct SPE_W<'a> {
233    w: &'a mut W,
234}
235impl<'a> SPE_W<'a> {
236    #[doc = r"Sets the field bit"]
237    #[inline(always)]
238    pub fn set_bit(self) -> &'a mut W {
239        self.bit(true)
240    }
241    #[doc = r"Clears the field bit"]
242    #[inline(always)]
243    pub fn clear_bit(self) -> &'a mut W {
244        self.bit(false)
245    }
246    #[doc = r"Writes raw bits to the field"]
247    #[inline(always)]
248    pub fn bit(self, value: bool) -> &'a mut W {
249        self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6);
250        self.w
251    }
252}
253#[doc = "Reader of field `BR`"]
254pub type BR_R = crate::R<u8, u8>;
255#[doc = "Write proxy for field `BR`"]
256pub struct BR_W<'a> {
257    w: &'a mut W,
258}
259impl<'a> BR_W<'a> {
260    #[doc = r"Writes raw bits to the field"]
261    #[inline(always)]
262    pub unsafe fn bits(self, value: u8) -> &'a mut W {
263        self.w.bits = (self.w.bits & !(0x07 << 3)) | (((value as u32) & 0x07) << 3);
264        self.w
265    }
266}
267#[doc = "Reader of field `MSTR`"]
268pub type MSTR_R = crate::R<bool, bool>;
269#[doc = "Write proxy for field `MSTR`"]
270pub struct MSTR_W<'a> {
271    w: &'a mut W,
272}
273impl<'a> MSTR_W<'a> {
274    #[doc = r"Sets the field bit"]
275    #[inline(always)]
276    pub fn set_bit(self) -> &'a mut W {
277        self.bit(true)
278    }
279    #[doc = r"Clears the field bit"]
280    #[inline(always)]
281    pub fn clear_bit(self) -> &'a mut W {
282        self.bit(false)
283    }
284    #[doc = r"Writes raw bits to the field"]
285    #[inline(always)]
286    pub fn bit(self, value: bool) -> &'a mut W {
287        self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2);
288        self.w
289    }
290}
291#[doc = "Reader of field `CPOL`"]
292pub type CPOL_R = crate::R<bool, bool>;
293#[doc = "Write proxy for field `CPOL`"]
294pub struct CPOL_W<'a> {
295    w: &'a mut W,
296}
297impl<'a> CPOL_W<'a> {
298    #[doc = r"Sets the field bit"]
299    #[inline(always)]
300    pub fn set_bit(self) -> &'a mut W {
301        self.bit(true)
302    }
303    #[doc = r"Clears the field bit"]
304    #[inline(always)]
305    pub fn clear_bit(self) -> &'a mut W {
306        self.bit(false)
307    }
308    #[doc = r"Writes raw bits to the field"]
309    #[inline(always)]
310    pub fn bit(self, value: bool) -> &'a mut W {
311        self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1);
312        self.w
313    }
314}
315#[doc = "Reader of field `CPHA`"]
316pub type CPHA_R = crate::R<bool, bool>;
317#[doc = "Write proxy for field `CPHA`"]
318pub struct CPHA_W<'a> {
319    w: &'a mut W,
320}
321impl<'a> CPHA_W<'a> {
322    #[doc = r"Sets the field bit"]
323    #[inline(always)]
324    pub fn set_bit(self) -> &'a mut W {
325        self.bit(true)
326    }
327    #[doc = r"Clears the field bit"]
328    #[inline(always)]
329    pub fn clear_bit(self) -> &'a mut W {
330        self.bit(false)
331    }
332    #[doc = r"Writes raw bits to the field"]
333    #[inline(always)]
334    pub fn bit(self, value: bool) -> &'a mut W {
335        self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
336        self.w
337    }
338}
339impl R {
340    #[doc = "Bit 15 - Bidirectional data mode enable"]
341    #[inline(always)]
342    pub fn bidimode(&self) -> BIDIMODE_R {
343        BIDIMODE_R::new(((self.bits >> 15) & 0x01) != 0)
344    }
345    #[doc = "Bit 14 - Output enable in bidirectional mode"]
346    #[inline(always)]
347    pub fn bidioe(&self) -> BIDIOE_R {
348        BIDIOE_R::new(((self.bits >> 14) & 0x01) != 0)
349    }
350    #[doc = "Bit 13 - Hardware CRC calculation enable"]
351    #[inline(always)]
352    pub fn crcen(&self) -> CRCEN_R {
353        CRCEN_R::new(((self.bits >> 13) & 0x01) != 0)
354    }
355    #[doc = "Bit 12 - CRC transfer next"]
356    #[inline(always)]
357    pub fn crcnext(&self) -> CRCNEXT_R {
358        CRCNEXT_R::new(((self.bits >> 12) & 0x01) != 0)
359    }
360    #[doc = "Bit 11 - Data frame format"]
361    #[inline(always)]
362    pub fn dff(&self) -> DFF_R {
363        DFF_R::new(((self.bits >> 11) & 0x01) != 0)
364    }
365    #[doc = "Bit 10 - Receive only"]
366    #[inline(always)]
367    pub fn rxonly(&self) -> RXONLY_R {
368        RXONLY_R::new(((self.bits >> 10) & 0x01) != 0)
369    }
370    #[doc = "Bit 9 - Software slave management"]
371    #[inline(always)]
372    pub fn ssm(&self) -> SSM_R {
373        SSM_R::new(((self.bits >> 9) & 0x01) != 0)
374    }
375    #[doc = "Bit 8 - Internal slave select"]
376    #[inline(always)]
377    pub fn ssi(&self) -> SSI_R {
378        SSI_R::new(((self.bits >> 8) & 0x01) != 0)
379    }
380    #[doc = "Bit 7 - Frame format"]
381    #[inline(always)]
382    pub fn lsbfirst(&self) -> LSBFIRST_R {
383        LSBFIRST_R::new(((self.bits >> 7) & 0x01) != 0)
384    }
385    #[doc = "Bit 6 - SPI enable"]
386    #[inline(always)]
387    pub fn spe(&self) -> SPE_R {
388        SPE_R::new(((self.bits >> 6) & 0x01) != 0)
389    }
390    #[doc = "Bits 3:5 - Baud rate control"]
391    #[inline(always)]
392    pub fn br(&self) -> BR_R {
393        BR_R::new(((self.bits >> 3) & 0x07) as u8)
394    }
395    #[doc = "Bit 2 - Master selection"]
396    #[inline(always)]
397    pub fn mstr(&self) -> MSTR_R {
398        MSTR_R::new(((self.bits >> 2) & 0x01) != 0)
399    }
400    #[doc = "Bit 1 - Clock polarity"]
401    #[inline(always)]
402    pub fn cpol(&self) -> CPOL_R {
403        CPOL_R::new(((self.bits >> 1) & 0x01) != 0)
404    }
405    #[doc = "Bit 0 - Clock phase"]
406    #[inline(always)]
407    pub fn cpha(&self) -> CPHA_R {
408        CPHA_R::new((self.bits & 0x01) != 0)
409    }
410}
411impl W {
412    #[doc = "Bit 15 - Bidirectional data mode enable"]
413    #[inline(always)]
414    pub fn bidimode(&mut self) -> BIDIMODE_W {
415        BIDIMODE_W { w: self }
416    }
417    #[doc = "Bit 14 - Output enable in bidirectional mode"]
418    #[inline(always)]
419    pub fn bidioe(&mut self) -> BIDIOE_W {
420        BIDIOE_W { w: self }
421    }
422    #[doc = "Bit 13 - Hardware CRC calculation enable"]
423    #[inline(always)]
424    pub fn crcen(&mut self) -> CRCEN_W {
425        CRCEN_W { w: self }
426    }
427    #[doc = "Bit 12 - CRC transfer next"]
428    #[inline(always)]
429    pub fn crcnext(&mut self) -> CRCNEXT_W {
430        CRCNEXT_W { w: self }
431    }
432    #[doc = "Bit 11 - Data frame format"]
433    #[inline(always)]
434    pub fn dff(&mut self) -> DFF_W {
435        DFF_W { w: self }
436    }
437    #[doc = "Bit 10 - Receive only"]
438    #[inline(always)]
439    pub fn rxonly(&mut self) -> RXONLY_W {
440        RXONLY_W { w: self }
441    }
442    #[doc = "Bit 9 - Software slave management"]
443    #[inline(always)]
444    pub fn ssm(&mut self) -> SSM_W {
445        SSM_W { w: self }
446    }
447    #[doc = "Bit 8 - Internal slave select"]
448    #[inline(always)]
449    pub fn ssi(&mut self) -> SSI_W {
450        SSI_W { w: self }
451    }
452    #[doc = "Bit 7 - Frame format"]
453    #[inline(always)]
454    pub fn lsbfirst(&mut self) -> LSBFIRST_W {
455        LSBFIRST_W { w: self }
456    }
457    #[doc = "Bit 6 - SPI enable"]
458    #[inline(always)]
459    pub fn spe(&mut self) -> SPE_W {
460        SPE_W { w: self }
461    }
462    #[doc = "Bits 3:5 - Baud rate control"]
463    #[inline(always)]
464    pub fn br(&mut self) -> BR_W {
465        BR_W { w: self }
466    }
467    #[doc = "Bit 2 - Master selection"]
468    #[inline(always)]
469    pub fn mstr(&mut self) -> MSTR_W {
470        MSTR_W { w: self }
471    }
472    #[doc = "Bit 1 - Clock polarity"]
473    #[inline(always)]
474    pub fn cpol(&mut self) -> CPOL_W {
475        CPOL_W { w: self }
476    }
477    #[doc = "Bit 0 - Clock phase"]
478    #[inline(always)]
479    pub fn cpha(&mut self) -> CPHA_W {
480        CPHA_W { w: self }
481    }
482}