stm32f1_staging/stm32f102/spi2/
sr.rs

1///Register `SR` reader
2pub type R = crate::R<SRrs>;
3///Register `SR` writer
4pub type W = crate::W<SRrs>;
5/**Receive buffer not empty
6
7Value on reset: 0*/
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum RXNE {
11    ///0: Rx buffer empty
12    Empty = 0,
13    ///1: Rx buffer not empty
14    NotEmpty = 1,
15}
16impl From<RXNE> for bool {
17    #[inline(always)]
18    fn from(variant: RXNE) -> Self {
19        variant as u8 != 0
20    }
21}
22///Field `RXNE` reader - Receive buffer not empty
23pub type RXNE_R = crate::BitReader<RXNE>;
24impl RXNE_R {
25    ///Get enumerated values variant
26    #[inline(always)]
27    pub const fn variant(&self) -> RXNE {
28        match self.bits {
29            false => RXNE::Empty,
30            true => RXNE::NotEmpty,
31        }
32    }
33    ///Rx buffer empty
34    #[inline(always)]
35    pub fn is_empty(&self) -> bool {
36        *self == RXNE::Empty
37    }
38    ///Rx buffer not empty
39    #[inline(always)]
40    pub fn is_not_empty(&self) -> bool {
41        *self == RXNE::NotEmpty
42    }
43}
44/**Transmit buffer empty
45
46Value on reset: 1*/
47#[cfg_attr(feature = "defmt", derive(defmt::Format))]
48#[derive(Clone, Copy, Debug, PartialEq, Eq)]
49pub enum TXE {
50    ///0: Tx buffer not empty
51    NotEmpty = 0,
52    ///1: Tx buffer empty
53    Empty = 1,
54}
55impl From<TXE> for bool {
56    #[inline(always)]
57    fn from(variant: TXE) -> Self {
58        variant as u8 != 0
59    }
60}
61///Field `TXE` reader - Transmit buffer empty
62pub type TXE_R = crate::BitReader<TXE>;
63impl TXE_R {
64    ///Get enumerated values variant
65    #[inline(always)]
66    pub const fn variant(&self) -> TXE {
67        match self.bits {
68            false => TXE::NotEmpty,
69            true => TXE::Empty,
70        }
71    }
72    ///Tx buffer not empty
73    #[inline(always)]
74    pub fn is_not_empty(&self) -> bool {
75        *self == TXE::NotEmpty
76    }
77    ///Tx buffer empty
78    #[inline(always)]
79    pub fn is_empty(&self) -> bool {
80        *self == TXE::Empty
81    }
82}
83/**CRC error flag
84
85Value on reset: 0*/
86#[cfg_attr(feature = "defmt", derive(defmt::Format))]
87#[derive(Clone, Copy, Debug, PartialEq, Eq)]
88pub enum CRCERRR {
89    ///0: CRC value received matches the SPIx_RXCRCR value
90    Match = 0,
91    ///1: CRC value received does not match the SPIx_RXCRCR value
92    NoMatch = 1,
93}
94impl From<CRCERRR> for bool {
95    #[inline(always)]
96    fn from(variant: CRCERRR) -> Self {
97        variant as u8 != 0
98    }
99}
100///Field `CRCERR` reader - CRC error flag
101pub type CRCERR_R = crate::BitReader<CRCERRR>;
102impl CRCERR_R {
103    ///Get enumerated values variant
104    #[inline(always)]
105    pub const fn variant(&self) -> CRCERRR {
106        match self.bits {
107            false => CRCERRR::Match,
108            true => CRCERRR::NoMatch,
109        }
110    }
111    ///CRC value received matches the SPIx_RXCRCR value
112    #[inline(always)]
113    pub fn is_match(&self) -> bool {
114        *self == CRCERRR::Match
115    }
116    ///CRC value received does not match the SPIx_RXCRCR value
117    #[inline(always)]
118    pub fn is_no_match(&self) -> bool {
119        *self == CRCERRR::NoMatch
120    }
121}
122/**CRC error flag
123
124Value on reset: 0*/
125#[cfg_attr(feature = "defmt", derive(defmt::Format))]
126#[derive(Clone, Copy, Debug, PartialEq, Eq)]
127pub enum CRCERRW {
128    ///0: Clear flag
129    Clear = 0,
130}
131impl From<CRCERRW> for bool {
132    #[inline(always)]
133    fn from(variant: CRCERRW) -> Self {
134        variant as u8 != 0
135    }
136}
137///Field `CRCERR` writer - CRC error flag
138pub type CRCERR_W<'a, REG> = crate::BitWriter0C<'a, REG, CRCERRW>;
139impl<'a, REG> CRCERR_W<'a, REG>
140where
141    REG: crate::Writable + crate::RegisterSpec,
142{
143    ///Clear flag
144    #[inline(always)]
145    pub fn clear(self) -> &'a mut crate::W<REG> {
146        self.variant(CRCERRW::Clear)
147    }
148}
149/**Mode fault
150
151Value on reset: 0*/
152#[cfg_attr(feature = "defmt", derive(defmt::Format))]
153#[derive(Clone, Copy, Debug, PartialEq, Eq)]
154pub enum MODFR {
155    ///0: No mode fault occurred
156    NoFault = 0,
157    ///1: Mode fault occurred
158    Fault = 1,
159}
160impl From<MODFR> for bool {
161    #[inline(always)]
162    fn from(variant: MODFR) -> Self {
163        variant as u8 != 0
164    }
165}
166///Field `MODF` reader - Mode fault
167pub type MODF_R = crate::BitReader<MODFR>;
168impl MODF_R {
169    ///Get enumerated values variant
170    #[inline(always)]
171    pub const fn variant(&self) -> MODFR {
172        match self.bits {
173            false => MODFR::NoFault,
174            true => MODFR::Fault,
175        }
176    }
177    ///No mode fault occurred
178    #[inline(always)]
179    pub fn is_no_fault(&self) -> bool {
180        *self == MODFR::NoFault
181    }
182    ///Mode fault occurred
183    #[inline(always)]
184    pub fn is_fault(&self) -> bool {
185        *self == MODFR::Fault
186    }
187}
188/**Overrun flag
189
190Value on reset: 0*/
191#[cfg_attr(feature = "defmt", derive(defmt::Format))]
192#[derive(Clone, Copy, Debug, PartialEq, Eq)]
193pub enum OVRR {
194    ///0: No overrun occurred
195    NoOverrun = 0,
196    ///1: Overrun occurred
197    Overrun = 1,
198}
199impl From<OVRR> for bool {
200    #[inline(always)]
201    fn from(variant: OVRR) -> Self {
202        variant as u8 != 0
203    }
204}
205///Field `OVR` reader - Overrun flag
206pub type OVR_R = crate::BitReader<OVRR>;
207impl OVR_R {
208    ///Get enumerated values variant
209    #[inline(always)]
210    pub const fn variant(&self) -> OVRR {
211        match self.bits {
212            false => OVRR::NoOverrun,
213            true => OVRR::Overrun,
214        }
215    }
216    ///No overrun occurred
217    #[inline(always)]
218    pub fn is_no_overrun(&self) -> bool {
219        *self == OVRR::NoOverrun
220    }
221    ///Overrun occurred
222    #[inline(always)]
223    pub fn is_overrun(&self) -> bool {
224        *self == OVRR::Overrun
225    }
226}
227/**Busy flag
228
229Value on reset: 0*/
230#[cfg_attr(feature = "defmt", derive(defmt::Format))]
231#[derive(Clone, Copy, Debug, PartialEq, Eq)]
232pub enum BSYR {
233    ///0: SPI not busy
234    NotBusy = 0,
235    ///1: SPI busy
236    Busy = 1,
237}
238impl From<BSYR> for bool {
239    #[inline(always)]
240    fn from(variant: BSYR) -> Self {
241        variant as u8 != 0
242    }
243}
244///Field `BSY` reader - Busy flag
245pub type BSY_R = crate::BitReader<BSYR>;
246impl BSY_R {
247    ///Get enumerated values variant
248    #[inline(always)]
249    pub const fn variant(&self) -> BSYR {
250        match self.bits {
251            false => BSYR::NotBusy,
252            true => BSYR::Busy,
253        }
254    }
255    ///SPI not busy
256    #[inline(always)]
257    pub fn is_not_busy(&self) -> bool {
258        *self == BSYR::NotBusy
259    }
260    ///SPI busy
261    #[inline(always)]
262    pub fn is_busy(&self) -> bool {
263        *self == BSYR::Busy
264    }
265}
266impl R {
267    ///Bit 0 - Receive buffer not empty
268    #[inline(always)]
269    pub fn rxne(&self) -> RXNE_R {
270        RXNE_R::new((self.bits & 1) != 0)
271    }
272    ///Bit 1 - Transmit buffer empty
273    #[inline(always)]
274    pub fn txe(&self) -> TXE_R {
275        TXE_R::new(((self.bits >> 1) & 1) != 0)
276    }
277    ///Bit 4 - CRC error flag
278    #[inline(always)]
279    pub fn crcerr(&self) -> CRCERR_R {
280        CRCERR_R::new(((self.bits >> 4) & 1) != 0)
281    }
282    ///Bit 5 - Mode fault
283    #[inline(always)]
284    pub fn modf(&self) -> MODF_R {
285        MODF_R::new(((self.bits >> 5) & 1) != 0)
286    }
287    ///Bit 6 - Overrun flag
288    #[inline(always)]
289    pub fn ovr(&self) -> OVR_R {
290        OVR_R::new(((self.bits >> 6) & 1) != 0)
291    }
292    ///Bit 7 - Busy flag
293    #[inline(always)]
294    pub fn bsy(&self) -> BSY_R {
295        BSY_R::new(((self.bits >> 7) & 1) != 0)
296    }
297}
298impl core::fmt::Debug for R {
299    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
300        f.debug_struct("SR")
301            .field("bsy", &self.bsy())
302            .field("ovr", &self.ovr())
303            .field("modf", &self.modf())
304            .field("crcerr", &self.crcerr())
305            .field("txe", &self.txe())
306            .field("rxne", &self.rxne())
307            .finish()
308    }
309}
310impl W {
311    ///Bit 4 - CRC error flag
312    #[inline(always)]
313    pub fn crcerr(&mut self) -> CRCERR_W<SRrs> {
314        CRCERR_W::new(self, 4)
315    }
316}
317/**status register
318
319You can [`read`](crate::Reg::read) this register and get [`sr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`sr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
320
321See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F102.html#SPI2:SR)*/
322pub struct SRrs;
323impl crate::RegisterSpec for SRrs {
324    type Ux = u16;
325}
326///`read()` method returns [`sr::R`](R) reader structure
327impl crate::Readable for SRrs {}
328///`write(|w| ..)` method takes [`sr::W`](W) writer structure
329impl crate::Writable for SRrs {
330    type Safety = crate::Unsafe;
331    const ZERO_TO_MODIFY_FIELDS_BITMAP: u16 = 0x10;
332}
333///`reset()` method sets SR to value 0x02
334impl crate::Resettable for SRrs {
335    const RESET_VALUE: u16 = 0x02;
336}