stm32wb_pac/sai1/
bcr2.rs

1#[doc = "Reader of register BCR2"]
2pub type R = crate::R<u32, super::BCR2>;
3#[doc = "Writer for register BCR2"]
4pub type W = crate::W<u32, super::BCR2>;
5#[doc = "Register BCR2 `reset()`'s with value 0"]
6impl crate::ResetValue for super::BCR2 {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `COMP`"]
14pub type COMP_R = crate::R<u8, u8>;
15#[doc = "Write proxy for field `COMP`"]
16pub struct COMP_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> COMP_W<'a> {
20    #[doc = r"Writes raw bits to the field"]
21    #[inline(always)]
22    pub unsafe fn bits(self, value: u8) -> &'a mut W {
23        self.w.bits = (self.w.bits & !(0x03 << 14)) | (((value as u32) & 0x03) << 14);
24        self.w
25    }
26}
27#[doc = "Reader of field `CPL`"]
28pub type CPL_R = crate::R<bool, bool>;
29#[doc = "Write proxy for field `CPL`"]
30pub struct CPL_W<'a> {
31    w: &'a mut W,
32}
33impl<'a> CPL_W<'a> {
34    #[doc = r"Sets the field bit"]
35    #[inline(always)]
36    pub fn set_bit(self) -> &'a mut W {
37        self.bit(true)
38    }
39    #[doc = r"Clears the field bit"]
40    #[inline(always)]
41    pub fn clear_bit(self) -> &'a mut W {
42        self.bit(false)
43    }
44    #[doc = r"Writes raw bits to the field"]
45    #[inline(always)]
46    pub fn bit(self, value: bool) -> &'a mut W {
47        self.w.bits = (self.w.bits & !(0x01 << 13)) | (((value as u32) & 0x01) << 13);
48        self.w
49    }
50}
51#[doc = "Reader of field `MUTECN`"]
52pub type MUTECN_R = crate::R<u8, u8>;
53#[doc = "Write proxy for field `MUTECN`"]
54pub struct MUTECN_W<'a> {
55    w: &'a mut W,
56}
57impl<'a> MUTECN_W<'a> {
58    #[doc = r"Writes raw bits to the field"]
59    #[inline(always)]
60    pub unsafe fn bits(self, value: u8) -> &'a mut W {
61        self.w.bits = (self.w.bits & !(0x3f << 7)) | (((value as u32) & 0x3f) << 7);
62        self.w
63    }
64}
65#[doc = "Reader of field `MUTEVAL`"]
66pub type MUTEVAL_R = crate::R<bool, bool>;
67#[doc = "Write proxy for field `MUTEVAL`"]
68pub struct MUTEVAL_W<'a> {
69    w: &'a mut W,
70}
71impl<'a> MUTEVAL_W<'a> {
72    #[doc = r"Sets the field bit"]
73    #[inline(always)]
74    pub fn set_bit(self) -> &'a mut W {
75        self.bit(true)
76    }
77    #[doc = r"Clears the field bit"]
78    #[inline(always)]
79    pub fn clear_bit(self) -> &'a mut W {
80        self.bit(false)
81    }
82    #[doc = r"Writes raw bits to the field"]
83    #[inline(always)]
84    pub fn bit(self, value: bool) -> &'a mut W {
85        self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6);
86        self.w
87    }
88}
89#[doc = "Reader of field `MUTE`"]
90pub type MUTE_R = crate::R<bool, bool>;
91#[doc = "Write proxy for field `MUTE`"]
92pub struct MUTE_W<'a> {
93    w: &'a mut W,
94}
95impl<'a> MUTE_W<'a> {
96    #[doc = r"Sets the field bit"]
97    #[inline(always)]
98    pub fn set_bit(self) -> &'a mut W {
99        self.bit(true)
100    }
101    #[doc = r"Clears the field bit"]
102    #[inline(always)]
103    pub fn clear_bit(self) -> &'a mut W {
104        self.bit(false)
105    }
106    #[doc = r"Writes raw bits to the field"]
107    #[inline(always)]
108    pub fn bit(self, value: bool) -> &'a mut W {
109        self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5);
110        self.w
111    }
112}
113#[doc = "Reader of field `TRIS`"]
114pub type TRIS_R = crate::R<bool, bool>;
115#[doc = "Write proxy for field `TRIS`"]
116pub struct TRIS_W<'a> {
117    w: &'a mut W,
118}
119impl<'a> TRIS_W<'a> {
120    #[doc = r"Sets the field bit"]
121    #[inline(always)]
122    pub fn set_bit(self) -> &'a mut W {
123        self.bit(true)
124    }
125    #[doc = r"Clears the field bit"]
126    #[inline(always)]
127    pub fn clear_bit(self) -> &'a mut W {
128        self.bit(false)
129    }
130    #[doc = r"Writes raw bits to the field"]
131    #[inline(always)]
132    pub fn bit(self, value: bool) -> &'a mut W {
133        self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4);
134        self.w
135    }
136}
137#[doc = "Reader of field `FFLUS`"]
138pub type FFLUS_R = crate::R<bool, bool>;
139#[doc = "Write proxy for field `FFLUS`"]
140pub struct FFLUS_W<'a> {
141    w: &'a mut W,
142}
143impl<'a> FFLUS_W<'a> {
144    #[doc = r"Sets the field bit"]
145    #[inline(always)]
146    pub fn set_bit(self) -> &'a mut W {
147        self.bit(true)
148    }
149    #[doc = r"Clears the field bit"]
150    #[inline(always)]
151    pub fn clear_bit(self) -> &'a mut W {
152        self.bit(false)
153    }
154    #[doc = r"Writes raw bits to the field"]
155    #[inline(always)]
156    pub fn bit(self, value: bool) -> &'a mut W {
157        self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3);
158        self.w
159    }
160}
161#[doc = "Reader of field `FTH`"]
162pub type FTH_R = crate::R<u8, u8>;
163#[doc = "Write proxy for field `FTH`"]
164pub struct FTH_W<'a> {
165    w: &'a mut W,
166}
167impl<'a> FTH_W<'a> {
168    #[doc = r"Writes raw bits to the field"]
169    #[inline(always)]
170    pub unsafe fn bits(self, value: u8) -> &'a mut W {
171        self.w.bits = (self.w.bits & !0x07) | ((value as u32) & 0x07);
172        self.w
173    }
174}
175impl R {
176    #[doc = "Bits 14:15 - Companding mode"]
177    #[inline(always)]
178    pub fn comp(&self) -> COMP_R {
179        COMP_R::new(((self.bits >> 14) & 0x03) as u8)
180    }
181    #[doc = "Bit 13 - Complement bit"]
182    #[inline(always)]
183    pub fn cpl(&self) -> CPL_R {
184        CPL_R::new(((self.bits >> 13) & 0x01) != 0)
185    }
186    #[doc = "Bits 7:12 - Mute counter"]
187    #[inline(always)]
188    pub fn mutecn(&self) -> MUTECN_R {
189        MUTECN_R::new(((self.bits >> 7) & 0x3f) as u8)
190    }
191    #[doc = "Bit 6 - Mute value"]
192    #[inline(always)]
193    pub fn muteval(&self) -> MUTEVAL_R {
194        MUTEVAL_R::new(((self.bits >> 6) & 0x01) != 0)
195    }
196    #[doc = "Bit 5 - Mute"]
197    #[inline(always)]
198    pub fn mute(&self) -> MUTE_R {
199        MUTE_R::new(((self.bits >> 5) & 0x01) != 0)
200    }
201    #[doc = "Bit 4 - Tristate management on data line"]
202    #[inline(always)]
203    pub fn tris(&self) -> TRIS_R {
204        TRIS_R::new(((self.bits >> 4) & 0x01) != 0)
205    }
206    #[doc = "Bit 3 - FIFO flush"]
207    #[inline(always)]
208    pub fn fflus(&self) -> FFLUS_R {
209        FFLUS_R::new(((self.bits >> 3) & 0x01) != 0)
210    }
211    #[doc = "Bits 0:2 - FIFO threshold"]
212    #[inline(always)]
213    pub fn fth(&self) -> FTH_R {
214        FTH_R::new((self.bits & 0x07) as u8)
215    }
216}
217impl W {
218    #[doc = "Bits 14:15 - Companding mode"]
219    #[inline(always)]
220    pub fn comp(&mut self) -> COMP_W {
221        COMP_W { w: self }
222    }
223    #[doc = "Bit 13 - Complement bit"]
224    #[inline(always)]
225    pub fn cpl(&mut self) -> CPL_W {
226        CPL_W { w: self }
227    }
228    #[doc = "Bits 7:12 - Mute counter"]
229    #[inline(always)]
230    pub fn mutecn(&mut self) -> MUTECN_W {
231        MUTECN_W { w: self }
232    }
233    #[doc = "Bit 6 - Mute value"]
234    #[inline(always)]
235    pub fn muteval(&mut self) -> MUTEVAL_W {
236        MUTEVAL_W { w: self }
237    }
238    #[doc = "Bit 5 - Mute"]
239    #[inline(always)]
240    pub fn mute(&mut self) -> MUTE_W {
241        MUTE_W { w: self }
242    }
243    #[doc = "Bit 4 - Tristate management on data line"]
244    #[inline(always)]
245    pub fn tris(&mut self) -> TRIS_W {
246        TRIS_W { w: self }
247    }
248    #[doc = "Bit 3 - FIFO flush"]
249    #[inline(always)]
250    pub fn fflus(&mut self) -> FFLUS_W {
251        FFLUS_W { w: self }
252    }
253    #[doc = "Bits 0:2 - FIFO threshold"]
254    #[inline(always)]
255    pub fn fth(&mut self) -> FTH_W {
256        FTH_W { w: self }
257    }
258}