stm32l1/stm32l151/spi1/
cr2.rs

1///Register `CR2` reader
2pub type R = crate::R<CR2rs>;
3///Register `CR2` writer
4pub type W = crate::W<CR2rs>;
5/**Rx buffer DMA enable
6
7Value on reset: 0*/
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum RXDMAEN {
11    ///0: Rx buffer DMA disabled
12    Disabled = 0,
13    ///1: Rx buffer DMA enabled
14    Enabled = 1,
15}
16impl From<RXDMAEN> for bool {
17    #[inline(always)]
18    fn from(variant: RXDMAEN) -> Self {
19        variant as u8 != 0
20    }
21}
22///Field `RXDMAEN` reader - Rx buffer DMA enable
23pub type RXDMAEN_R = crate::BitReader<RXDMAEN>;
24impl RXDMAEN_R {
25    ///Get enumerated values variant
26    #[inline(always)]
27    pub const fn variant(&self) -> RXDMAEN {
28        match self.bits {
29            false => RXDMAEN::Disabled,
30            true => RXDMAEN::Enabled,
31        }
32    }
33    ///Rx buffer DMA disabled
34    #[inline(always)]
35    pub fn is_disabled(&self) -> bool {
36        *self == RXDMAEN::Disabled
37    }
38    ///Rx buffer DMA enabled
39    #[inline(always)]
40    pub fn is_enabled(&self) -> bool {
41        *self == RXDMAEN::Enabled
42    }
43}
44///Field `RXDMAEN` writer - Rx buffer DMA enable
45pub type RXDMAEN_W<'a, REG> = crate::BitWriter<'a, REG, RXDMAEN>;
46impl<'a, REG> RXDMAEN_W<'a, REG>
47where
48    REG: crate::Writable + crate::RegisterSpec,
49{
50    ///Rx buffer DMA disabled
51    #[inline(always)]
52    pub fn disabled(self) -> &'a mut crate::W<REG> {
53        self.variant(RXDMAEN::Disabled)
54    }
55    ///Rx buffer DMA enabled
56    #[inline(always)]
57    pub fn enabled(self) -> &'a mut crate::W<REG> {
58        self.variant(RXDMAEN::Enabled)
59    }
60}
61/**Tx buffer DMA enable
62
63Value on reset: 0*/
64#[cfg_attr(feature = "defmt", derive(defmt::Format))]
65#[derive(Clone, Copy, Debug, PartialEq, Eq)]
66pub enum TXDMAEN {
67    ///0: Tx buffer DMA disabled
68    Disabled = 0,
69    ///1: Tx buffer DMA enabled
70    Enabled = 1,
71}
72impl From<TXDMAEN> for bool {
73    #[inline(always)]
74    fn from(variant: TXDMAEN) -> Self {
75        variant as u8 != 0
76    }
77}
78///Field `TXDMAEN` reader - Tx buffer DMA enable
79pub type TXDMAEN_R = crate::BitReader<TXDMAEN>;
80impl TXDMAEN_R {
81    ///Get enumerated values variant
82    #[inline(always)]
83    pub const fn variant(&self) -> TXDMAEN {
84        match self.bits {
85            false => TXDMAEN::Disabled,
86            true => TXDMAEN::Enabled,
87        }
88    }
89    ///Tx buffer DMA disabled
90    #[inline(always)]
91    pub fn is_disabled(&self) -> bool {
92        *self == TXDMAEN::Disabled
93    }
94    ///Tx buffer DMA enabled
95    #[inline(always)]
96    pub fn is_enabled(&self) -> bool {
97        *self == TXDMAEN::Enabled
98    }
99}
100///Field `TXDMAEN` writer - Tx buffer DMA enable
101pub type TXDMAEN_W<'a, REG> = crate::BitWriter<'a, REG, TXDMAEN>;
102impl<'a, REG> TXDMAEN_W<'a, REG>
103where
104    REG: crate::Writable + crate::RegisterSpec,
105{
106    ///Tx buffer DMA disabled
107    #[inline(always)]
108    pub fn disabled(self) -> &'a mut crate::W<REG> {
109        self.variant(TXDMAEN::Disabled)
110    }
111    ///Tx buffer DMA enabled
112    #[inline(always)]
113    pub fn enabled(self) -> &'a mut crate::W<REG> {
114        self.variant(TXDMAEN::Enabled)
115    }
116}
117/**SS output enable
118
119Value on reset: 0*/
120#[cfg_attr(feature = "defmt", derive(defmt::Format))]
121#[derive(Clone, Copy, Debug, PartialEq, Eq)]
122pub enum SSOE {
123    ///0: SS output is disabled in master mode
124    Disabled = 0,
125    ///1: SS output is enabled in master mode
126    Enabled = 1,
127}
128impl From<SSOE> for bool {
129    #[inline(always)]
130    fn from(variant: SSOE) -> Self {
131        variant as u8 != 0
132    }
133}
134///Field `SSOE` reader - SS output enable
135pub type SSOE_R = crate::BitReader<SSOE>;
136impl SSOE_R {
137    ///Get enumerated values variant
138    #[inline(always)]
139    pub const fn variant(&self) -> SSOE {
140        match self.bits {
141            false => SSOE::Disabled,
142            true => SSOE::Enabled,
143        }
144    }
145    ///SS output is disabled in master mode
146    #[inline(always)]
147    pub fn is_disabled(&self) -> bool {
148        *self == SSOE::Disabled
149    }
150    ///SS output is enabled in master mode
151    #[inline(always)]
152    pub fn is_enabled(&self) -> bool {
153        *self == SSOE::Enabled
154    }
155}
156///Field `SSOE` writer - SS output enable
157pub type SSOE_W<'a, REG> = crate::BitWriter<'a, REG, SSOE>;
158impl<'a, REG> SSOE_W<'a, REG>
159where
160    REG: crate::Writable + crate::RegisterSpec,
161{
162    ///SS output is disabled in master mode
163    #[inline(always)]
164    pub fn disabled(self) -> &'a mut crate::W<REG> {
165        self.variant(SSOE::Disabled)
166    }
167    ///SS output is enabled in master mode
168    #[inline(always)]
169    pub fn enabled(self) -> &'a mut crate::W<REG> {
170        self.variant(SSOE::Enabled)
171    }
172}
173/**Frame format
174
175Value on reset: 0*/
176#[cfg_attr(feature = "defmt", derive(defmt::Format))]
177#[derive(Clone, Copy, Debug, PartialEq, Eq)]
178pub enum FRF {
179    ///0: SPI Motorola mode
180    Motorola = 0,
181    ///1: SPI TI mode
182    Ti = 1,
183}
184impl From<FRF> for bool {
185    #[inline(always)]
186    fn from(variant: FRF) -> Self {
187        variant as u8 != 0
188    }
189}
190///Field `FRF` reader - Frame format
191pub type FRF_R = crate::BitReader<FRF>;
192impl FRF_R {
193    ///Get enumerated values variant
194    #[inline(always)]
195    pub const fn variant(&self) -> FRF {
196        match self.bits {
197            false => FRF::Motorola,
198            true => FRF::Ti,
199        }
200    }
201    ///SPI Motorola mode
202    #[inline(always)]
203    pub fn is_motorola(&self) -> bool {
204        *self == FRF::Motorola
205    }
206    ///SPI TI mode
207    #[inline(always)]
208    pub fn is_ti(&self) -> bool {
209        *self == FRF::Ti
210    }
211}
212///Field `FRF` writer - Frame format
213pub type FRF_W<'a, REG> = crate::BitWriter<'a, REG, FRF>;
214impl<'a, REG> FRF_W<'a, REG>
215where
216    REG: crate::Writable + crate::RegisterSpec,
217{
218    ///SPI Motorola mode
219    #[inline(always)]
220    pub fn motorola(self) -> &'a mut crate::W<REG> {
221        self.variant(FRF::Motorola)
222    }
223    ///SPI TI mode
224    #[inline(always)]
225    pub fn ti(self) -> &'a mut crate::W<REG> {
226        self.variant(FRF::Ti)
227    }
228}
229/**Error interrupt enable
230
231Value on reset: 0*/
232#[cfg_attr(feature = "defmt", derive(defmt::Format))]
233#[derive(Clone, Copy, Debug, PartialEq, Eq)]
234pub enum ERRIE {
235    ///0: Error interrupt masked
236    Masked = 0,
237    ///1: Error interrupt not masked
238    NotMasked = 1,
239}
240impl From<ERRIE> for bool {
241    #[inline(always)]
242    fn from(variant: ERRIE) -> Self {
243        variant as u8 != 0
244    }
245}
246///Field `ERRIE` reader - Error interrupt enable
247pub type ERRIE_R = crate::BitReader<ERRIE>;
248impl ERRIE_R {
249    ///Get enumerated values variant
250    #[inline(always)]
251    pub const fn variant(&self) -> ERRIE {
252        match self.bits {
253            false => ERRIE::Masked,
254            true => ERRIE::NotMasked,
255        }
256    }
257    ///Error interrupt masked
258    #[inline(always)]
259    pub fn is_masked(&self) -> bool {
260        *self == ERRIE::Masked
261    }
262    ///Error interrupt not masked
263    #[inline(always)]
264    pub fn is_not_masked(&self) -> bool {
265        *self == ERRIE::NotMasked
266    }
267}
268///Field `ERRIE` writer - Error interrupt enable
269pub type ERRIE_W<'a, REG> = crate::BitWriter<'a, REG, ERRIE>;
270impl<'a, REG> ERRIE_W<'a, REG>
271where
272    REG: crate::Writable + crate::RegisterSpec,
273{
274    ///Error interrupt masked
275    #[inline(always)]
276    pub fn masked(self) -> &'a mut crate::W<REG> {
277        self.variant(ERRIE::Masked)
278    }
279    ///Error interrupt not masked
280    #[inline(always)]
281    pub fn not_masked(self) -> &'a mut crate::W<REG> {
282        self.variant(ERRIE::NotMasked)
283    }
284}
285/**RX buffer not empty interrupt enable
286
287Value on reset: 0*/
288#[cfg_attr(feature = "defmt", derive(defmt::Format))]
289#[derive(Clone, Copy, Debug, PartialEq, Eq)]
290pub enum RXNEIE {
291    ///0: RXE interrupt masked
292    Masked = 0,
293    ///1: RXE interrupt not masked
294    NotMasked = 1,
295}
296impl From<RXNEIE> for bool {
297    #[inline(always)]
298    fn from(variant: RXNEIE) -> Self {
299        variant as u8 != 0
300    }
301}
302///Field `RXNEIE` reader - RX buffer not empty interrupt enable
303pub type RXNEIE_R = crate::BitReader<RXNEIE>;
304impl RXNEIE_R {
305    ///Get enumerated values variant
306    #[inline(always)]
307    pub const fn variant(&self) -> RXNEIE {
308        match self.bits {
309            false => RXNEIE::Masked,
310            true => RXNEIE::NotMasked,
311        }
312    }
313    ///RXE interrupt masked
314    #[inline(always)]
315    pub fn is_masked(&self) -> bool {
316        *self == RXNEIE::Masked
317    }
318    ///RXE interrupt not masked
319    #[inline(always)]
320    pub fn is_not_masked(&self) -> bool {
321        *self == RXNEIE::NotMasked
322    }
323}
324///Field `RXNEIE` writer - RX buffer not empty interrupt enable
325pub type RXNEIE_W<'a, REG> = crate::BitWriter<'a, REG, RXNEIE>;
326impl<'a, REG> RXNEIE_W<'a, REG>
327where
328    REG: crate::Writable + crate::RegisterSpec,
329{
330    ///RXE interrupt masked
331    #[inline(always)]
332    pub fn masked(self) -> &'a mut crate::W<REG> {
333        self.variant(RXNEIE::Masked)
334    }
335    ///RXE interrupt not masked
336    #[inline(always)]
337    pub fn not_masked(self) -> &'a mut crate::W<REG> {
338        self.variant(RXNEIE::NotMasked)
339    }
340}
341/**Tx buffer empty interrupt enable
342
343Value on reset: 0*/
344#[cfg_attr(feature = "defmt", derive(defmt::Format))]
345#[derive(Clone, Copy, Debug, PartialEq, Eq)]
346pub enum TXEIE {
347    ///0: TXE interrupt masked
348    Masked = 0,
349    ///1: TXE interrupt not masked
350    NotMasked = 1,
351}
352impl From<TXEIE> for bool {
353    #[inline(always)]
354    fn from(variant: TXEIE) -> Self {
355        variant as u8 != 0
356    }
357}
358///Field `TXEIE` reader - Tx buffer empty interrupt enable
359pub type TXEIE_R = crate::BitReader<TXEIE>;
360impl TXEIE_R {
361    ///Get enumerated values variant
362    #[inline(always)]
363    pub const fn variant(&self) -> TXEIE {
364        match self.bits {
365            false => TXEIE::Masked,
366            true => TXEIE::NotMasked,
367        }
368    }
369    ///TXE interrupt masked
370    #[inline(always)]
371    pub fn is_masked(&self) -> bool {
372        *self == TXEIE::Masked
373    }
374    ///TXE interrupt not masked
375    #[inline(always)]
376    pub fn is_not_masked(&self) -> bool {
377        *self == TXEIE::NotMasked
378    }
379}
380///Field `TXEIE` writer - Tx buffer empty interrupt enable
381pub type TXEIE_W<'a, REG> = crate::BitWriter<'a, REG, TXEIE>;
382impl<'a, REG> TXEIE_W<'a, REG>
383where
384    REG: crate::Writable + crate::RegisterSpec,
385{
386    ///TXE interrupt masked
387    #[inline(always)]
388    pub fn masked(self) -> &'a mut crate::W<REG> {
389        self.variant(TXEIE::Masked)
390    }
391    ///TXE interrupt not masked
392    #[inline(always)]
393    pub fn not_masked(self) -> &'a mut crate::W<REG> {
394        self.variant(TXEIE::NotMasked)
395    }
396}
397impl R {
398    ///Bit 0 - Rx buffer DMA enable
399    #[inline(always)]
400    pub fn rxdmaen(&self) -> RXDMAEN_R {
401        RXDMAEN_R::new((self.bits & 1) != 0)
402    }
403    ///Bit 1 - Tx buffer DMA enable
404    #[inline(always)]
405    pub fn txdmaen(&self) -> TXDMAEN_R {
406        TXDMAEN_R::new(((self.bits >> 1) & 1) != 0)
407    }
408    ///Bit 2 - SS output enable
409    #[inline(always)]
410    pub fn ssoe(&self) -> SSOE_R {
411        SSOE_R::new(((self.bits >> 2) & 1) != 0)
412    }
413    ///Bit 4 - Frame format
414    #[inline(always)]
415    pub fn frf(&self) -> FRF_R {
416        FRF_R::new(((self.bits >> 4) & 1) != 0)
417    }
418    ///Bit 5 - Error interrupt enable
419    #[inline(always)]
420    pub fn errie(&self) -> ERRIE_R {
421        ERRIE_R::new(((self.bits >> 5) & 1) != 0)
422    }
423    ///Bit 6 - RX buffer not empty interrupt enable
424    #[inline(always)]
425    pub fn rxneie(&self) -> RXNEIE_R {
426        RXNEIE_R::new(((self.bits >> 6) & 1) != 0)
427    }
428    ///Bit 7 - Tx buffer empty interrupt enable
429    #[inline(always)]
430    pub fn txeie(&self) -> TXEIE_R {
431        TXEIE_R::new(((self.bits >> 7) & 1) != 0)
432    }
433}
434impl core::fmt::Debug for R {
435    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
436        f.debug_struct("CR2")
437            .field("txeie", &self.txeie())
438            .field("rxneie", &self.rxneie())
439            .field("errie", &self.errie())
440            .field("frf", &self.frf())
441            .field("ssoe", &self.ssoe())
442            .field("txdmaen", &self.txdmaen())
443            .field("rxdmaen", &self.rxdmaen())
444            .finish()
445    }
446}
447impl W {
448    ///Bit 0 - Rx buffer DMA enable
449    #[inline(always)]
450    pub fn rxdmaen(&mut self) -> RXDMAEN_W<CR2rs> {
451        RXDMAEN_W::new(self, 0)
452    }
453    ///Bit 1 - Tx buffer DMA enable
454    #[inline(always)]
455    pub fn txdmaen(&mut self) -> TXDMAEN_W<CR2rs> {
456        TXDMAEN_W::new(self, 1)
457    }
458    ///Bit 2 - SS output enable
459    #[inline(always)]
460    pub fn ssoe(&mut self) -> SSOE_W<CR2rs> {
461        SSOE_W::new(self, 2)
462    }
463    ///Bit 4 - Frame format
464    #[inline(always)]
465    pub fn frf(&mut self) -> FRF_W<CR2rs> {
466        FRF_W::new(self, 4)
467    }
468    ///Bit 5 - Error interrupt enable
469    #[inline(always)]
470    pub fn errie(&mut self) -> ERRIE_W<CR2rs> {
471        ERRIE_W::new(self, 5)
472    }
473    ///Bit 6 - RX buffer not empty interrupt enable
474    #[inline(always)]
475    pub fn rxneie(&mut self) -> RXNEIE_W<CR2rs> {
476        RXNEIE_W::new(self, 6)
477    }
478    ///Bit 7 - Tx buffer empty interrupt enable
479    #[inline(always)]
480    pub fn txeie(&mut self) -> TXEIE_W<CR2rs> {
481        TXEIE_W::new(self, 7)
482    }
483}
484/**control register 2
485
486You can [`read`](crate::Reg::read) this register and get [`cr2::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`cr2::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
487
488See register [structure](https://stm32-rs.github.io/stm32-rs/STM32L151.html#SPI1:CR2)*/
489pub struct CR2rs;
490impl crate::RegisterSpec for CR2rs {
491    type Ux = u16;
492}
493///`read()` method returns [`cr2::R`](R) reader structure
494impl crate::Readable for CR2rs {}
495///`write(|w| ..)` method takes [`cr2::W`](W) writer structure
496impl crate::Writable for CR2rs {
497    type Safety = crate::Unsafe;
498}
499///`reset()` method sets CR2 to value 0
500impl crate::Resettable for CR2rs {}