stm32f1_staging/stm32f107/usart1/
sr.rs

1///Register `SR` reader
2pub type R = crate::R<SRrs>;
3///Register `SR` writer
4pub type W = crate::W<SRrs>;
5/**Parity error
6
7Value on reset: 0*/
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum PE {
11    ///0: No parity error
12    NoError = 0,
13    ///1: Parity error
14    Error = 1,
15}
16impl From<PE> for bool {
17    #[inline(always)]
18    fn from(variant: PE) -> Self {
19        variant as u8 != 0
20    }
21}
22///Field `PE` reader - Parity error
23pub type PE_R = crate::BitReader<PE>;
24impl PE_R {
25    ///Get enumerated values variant
26    #[inline(always)]
27    pub const fn variant(&self) -> PE {
28        match self.bits {
29            false => PE::NoError,
30            true => PE::Error,
31        }
32    }
33    ///No parity error
34    #[inline(always)]
35    pub fn is_no_error(&self) -> bool {
36        *self == PE::NoError
37    }
38    ///Parity error
39    #[inline(always)]
40    pub fn is_error(&self) -> bool {
41        *self == PE::Error
42    }
43}
44/**Framing error
45
46Value on reset: 0*/
47#[cfg_attr(feature = "defmt", derive(defmt::Format))]
48#[derive(Clone, Copy, Debug, PartialEq, Eq)]
49pub enum FE {
50    ///0: No Framing error is detected
51    NoError = 0,
52    ///1: Framing error or break character is detected
53    Error = 1,
54}
55impl From<FE> for bool {
56    #[inline(always)]
57    fn from(variant: FE) -> Self {
58        variant as u8 != 0
59    }
60}
61///Field `FE` reader - Framing error
62pub type FE_R = crate::BitReader<FE>;
63impl FE_R {
64    ///Get enumerated values variant
65    #[inline(always)]
66    pub const fn variant(&self) -> FE {
67        match self.bits {
68            false => FE::NoError,
69            true => FE::Error,
70        }
71    }
72    ///No Framing error is detected
73    #[inline(always)]
74    pub fn is_no_error(&self) -> bool {
75        *self == FE::NoError
76    }
77    ///Framing error or break character is detected
78    #[inline(always)]
79    pub fn is_error(&self) -> bool {
80        *self == FE::Error
81    }
82}
83/**Noise error flag
84
85Value on reset: 0*/
86#[cfg_attr(feature = "defmt", derive(defmt::Format))]
87#[derive(Clone, Copy, Debug, PartialEq, Eq)]
88pub enum NE {
89    ///0: No noise is detected
90    NoNoise = 0,
91    ///1: Noise is detected
92    Noise = 1,
93}
94impl From<NE> for bool {
95    #[inline(always)]
96    fn from(variant: NE) -> Self {
97        variant as u8 != 0
98    }
99}
100///Field `NE` reader - Noise error flag
101pub type NE_R = crate::BitReader<NE>;
102impl NE_R {
103    ///Get enumerated values variant
104    #[inline(always)]
105    pub const fn variant(&self) -> NE {
106        match self.bits {
107            false => NE::NoNoise,
108            true => NE::Noise,
109        }
110    }
111    ///No noise is detected
112    #[inline(always)]
113    pub fn is_no_noise(&self) -> bool {
114        *self == NE::NoNoise
115    }
116    ///Noise is detected
117    #[inline(always)]
118    pub fn is_noise(&self) -> bool {
119        *self == NE::Noise
120    }
121}
122/**Overrun error
123
124Value on reset: 0*/
125#[cfg_attr(feature = "defmt", derive(defmt::Format))]
126#[derive(Clone, Copy, Debug, PartialEq, Eq)]
127pub enum ORE {
128    ///0: No Overrun error
129    NoOverrun = 0,
130    ///1: Overrun error is detected
131    Overrun = 1,
132}
133impl From<ORE> for bool {
134    #[inline(always)]
135    fn from(variant: ORE) -> Self {
136        variant as u8 != 0
137    }
138}
139///Field `ORE` reader - Overrun error
140pub type ORE_R = crate::BitReader<ORE>;
141impl ORE_R {
142    ///Get enumerated values variant
143    #[inline(always)]
144    pub const fn variant(&self) -> ORE {
145        match self.bits {
146            false => ORE::NoOverrun,
147            true => ORE::Overrun,
148        }
149    }
150    ///No Overrun error
151    #[inline(always)]
152    pub fn is_no_overrun(&self) -> bool {
153        *self == ORE::NoOverrun
154    }
155    ///Overrun error is detected
156    #[inline(always)]
157    pub fn is_overrun(&self) -> bool {
158        *self == ORE::Overrun
159    }
160}
161/**IDLE line detected
162
163Value on reset: 0*/
164#[cfg_attr(feature = "defmt", derive(defmt::Format))]
165#[derive(Clone, Copy, Debug, PartialEq, Eq)]
166pub enum IDLE {
167    ///0: No Idle Line is detected
168    NoIdle = 0,
169    ///1: Idle Line is detected
170    Idle = 1,
171}
172impl From<IDLE> for bool {
173    #[inline(always)]
174    fn from(variant: IDLE) -> Self {
175        variant as u8 != 0
176    }
177}
178///Field `IDLE` reader - IDLE line detected
179pub type IDLE_R = crate::BitReader<IDLE>;
180impl IDLE_R {
181    ///Get enumerated values variant
182    #[inline(always)]
183    pub const fn variant(&self) -> IDLE {
184        match self.bits {
185            false => IDLE::NoIdle,
186            true => IDLE::Idle,
187        }
188    }
189    ///No Idle Line is detected
190    #[inline(always)]
191    pub fn is_no_idle(&self) -> bool {
192        *self == IDLE::NoIdle
193    }
194    ///Idle Line is detected
195    #[inline(always)]
196    pub fn is_idle(&self) -> bool {
197        *self == IDLE::Idle
198    }
199}
200/**Read data register not empty
201
202Value on reset: 0*/
203#[cfg_attr(feature = "defmt", derive(defmt::Format))]
204#[derive(Clone, Copy, Debug, PartialEq, Eq)]
205pub enum RXNER {
206    ///0: Data is not received
207    NoData = 0,
208    ///1: Received data is ready to be read
209    DataReady = 1,
210}
211impl From<RXNER> for bool {
212    #[inline(always)]
213    fn from(variant: RXNER) -> Self {
214        variant as u8 != 0
215    }
216}
217///Field `RXNE` reader - Read data register not empty
218pub type RXNE_R = crate::BitReader<RXNER>;
219impl RXNE_R {
220    ///Get enumerated values variant
221    #[inline(always)]
222    pub const fn variant(&self) -> RXNER {
223        match self.bits {
224            false => RXNER::NoData,
225            true => RXNER::DataReady,
226        }
227    }
228    ///Data is not received
229    #[inline(always)]
230    pub fn is_no_data(&self) -> bool {
231        *self == RXNER::NoData
232    }
233    ///Received data is ready to be read
234    #[inline(always)]
235    pub fn is_data_ready(&self) -> bool {
236        *self == RXNER::DataReady
237    }
238}
239/**Read data register not empty
240
241Value on reset: 0*/
242#[cfg_attr(feature = "defmt", derive(defmt::Format))]
243#[derive(Clone, Copy, Debug, PartialEq, Eq)]
244pub enum RXNEW {
245    ///0: Clear received data ready flag
246    Clear = 0,
247}
248impl From<RXNEW> for bool {
249    #[inline(always)]
250    fn from(variant: RXNEW) -> Self {
251        variant as u8 != 0
252    }
253}
254///Field `RXNE` writer - Read data register not empty
255pub type RXNE_W<'a, REG> = crate::BitWriter0C<'a, REG, RXNEW>;
256impl<'a, REG> RXNE_W<'a, REG>
257where
258    REG: crate::Writable + crate::RegisterSpec,
259{
260    ///Clear received data ready flag
261    #[inline(always)]
262    pub fn clear(self) -> &'a mut crate::W<REG> {
263        self.variant(RXNEW::Clear)
264    }
265}
266/**Transmission complete
267
268Value on reset: 1*/
269#[cfg_attr(feature = "defmt", derive(defmt::Format))]
270#[derive(Clone, Copy, Debug, PartialEq, Eq)]
271pub enum TCR {
272    ///0: Transmission is not complete
273    TxNotComplete = 0,
274    ///1: Transmission is complete
275    TxComplete = 1,
276}
277impl From<TCR> for bool {
278    #[inline(always)]
279    fn from(variant: TCR) -> Self {
280        variant as u8 != 0
281    }
282}
283///Field `TC` reader - Transmission complete
284pub type TC_R = crate::BitReader<TCR>;
285impl TC_R {
286    ///Get enumerated values variant
287    #[inline(always)]
288    pub const fn variant(&self) -> TCR {
289        match self.bits {
290            false => TCR::TxNotComplete,
291            true => TCR::TxComplete,
292        }
293    }
294    ///Transmission is not complete
295    #[inline(always)]
296    pub fn is_tx_not_complete(&self) -> bool {
297        *self == TCR::TxNotComplete
298    }
299    ///Transmission is complete
300    #[inline(always)]
301    pub fn is_tx_complete(&self) -> bool {
302        *self == TCR::TxComplete
303    }
304}
305/**Transmission complete
306
307Value on reset: 1*/
308#[cfg_attr(feature = "defmt", derive(defmt::Format))]
309#[derive(Clone, Copy, Debug, PartialEq, Eq)]
310pub enum TCW {
311    ///0: Clear transmission complete flag
312    Clear = 0,
313}
314impl From<TCW> for bool {
315    #[inline(always)]
316    fn from(variant: TCW) -> Self {
317        variant as u8 != 0
318    }
319}
320///Field `TC` writer - Transmission complete
321pub type TC_W<'a, REG> = crate::BitWriter0C<'a, REG, TCW>;
322impl<'a, REG> TC_W<'a, REG>
323where
324    REG: crate::Writable + crate::RegisterSpec,
325{
326    ///Clear transmission complete flag
327    #[inline(always)]
328    pub fn clear(self) -> &'a mut crate::W<REG> {
329        self.variant(TCW::Clear)
330    }
331}
332/**Transmit data register empty
333
334Value on reset: 1*/
335#[cfg_attr(feature = "defmt", derive(defmt::Format))]
336#[derive(Clone, Copy, Debug, PartialEq, Eq)]
337pub enum TXE {
338    ///0: Data is not transferred to the shift register
339    TxNotEmpty = 0,
340    ///1: Data is transferred to the shift register
341    TxEmpty = 1,
342}
343impl From<TXE> for bool {
344    #[inline(always)]
345    fn from(variant: TXE) -> Self {
346        variant as u8 != 0
347    }
348}
349///Field `TXE` reader - Transmit data register empty
350pub type TXE_R = crate::BitReader<TXE>;
351impl TXE_R {
352    ///Get enumerated values variant
353    #[inline(always)]
354    pub const fn variant(&self) -> TXE {
355        match self.bits {
356            false => TXE::TxNotEmpty,
357            true => TXE::TxEmpty,
358        }
359    }
360    ///Data is not transferred to the shift register
361    #[inline(always)]
362    pub fn is_tx_not_empty(&self) -> bool {
363        *self == TXE::TxNotEmpty
364    }
365    ///Data is transferred to the shift register
366    #[inline(always)]
367    pub fn is_tx_empty(&self) -> bool {
368        *self == TXE::TxEmpty
369    }
370}
371/**LIN break detection flag
372
373Value on reset: 0*/
374#[cfg_attr(feature = "defmt", derive(defmt::Format))]
375#[derive(Clone, Copy, Debug, PartialEq, Eq)]
376pub enum LBDR {
377    ///0: LIN break not detected
378    NotDetected = 0,
379    ///1: LIN break detected
380    Detected = 1,
381}
382impl From<LBDR> for bool {
383    #[inline(always)]
384    fn from(variant: LBDR) -> Self {
385        variant as u8 != 0
386    }
387}
388///Field `LBD` reader - LIN break detection flag
389pub type LBD_R = crate::BitReader<LBDR>;
390impl LBD_R {
391    ///Get enumerated values variant
392    #[inline(always)]
393    pub const fn variant(&self) -> LBDR {
394        match self.bits {
395            false => LBDR::NotDetected,
396            true => LBDR::Detected,
397        }
398    }
399    ///LIN break not detected
400    #[inline(always)]
401    pub fn is_not_detected(&self) -> bool {
402        *self == LBDR::NotDetected
403    }
404    ///LIN break detected
405    #[inline(always)]
406    pub fn is_detected(&self) -> bool {
407        *self == LBDR::Detected
408    }
409}
410/**LIN break detection flag
411
412Value on reset: 0*/
413#[cfg_attr(feature = "defmt", derive(defmt::Format))]
414#[derive(Clone, Copy, Debug, PartialEq, Eq)]
415pub enum LBDW {
416    ///0: Clear LIN break detection flag
417    Clear = 0,
418}
419impl From<LBDW> for bool {
420    #[inline(always)]
421    fn from(variant: LBDW) -> Self {
422        variant as u8 != 0
423    }
424}
425///Field `LBD` writer - LIN break detection flag
426pub type LBD_W<'a, REG> = crate::BitWriter0C<'a, REG, LBDW>;
427impl<'a, REG> LBD_W<'a, REG>
428where
429    REG: crate::Writable + crate::RegisterSpec,
430{
431    ///Clear LIN break detection flag
432    #[inline(always)]
433    pub fn clear(self) -> &'a mut crate::W<REG> {
434        self.variant(LBDW::Clear)
435    }
436}
437/**CTS flag
438
439Value on reset: 0*/
440#[cfg_attr(feature = "defmt", derive(defmt::Format))]
441#[derive(Clone, Copy, Debug, PartialEq, Eq)]
442pub enum CTSR {
443    ///0: No change occurred on the CTS status line
444    NotChanged = 0,
445    ///1: A change occurred on the CTS status line
446    Changed = 1,
447}
448impl From<CTSR> for bool {
449    #[inline(always)]
450    fn from(variant: CTSR) -> Self {
451        variant as u8 != 0
452    }
453}
454///Field `CTS` reader - CTS flag
455pub type CTS_R = crate::BitReader<CTSR>;
456impl CTS_R {
457    ///Get enumerated values variant
458    #[inline(always)]
459    pub const fn variant(&self) -> CTSR {
460        match self.bits {
461            false => CTSR::NotChanged,
462            true => CTSR::Changed,
463        }
464    }
465    ///No change occurred on the CTS status line
466    #[inline(always)]
467    pub fn is_not_changed(&self) -> bool {
468        *self == CTSR::NotChanged
469    }
470    ///A change occurred on the CTS status line
471    #[inline(always)]
472    pub fn is_changed(&self) -> bool {
473        *self == CTSR::Changed
474    }
475}
476/**CTS flag
477
478Value on reset: 0*/
479#[cfg_attr(feature = "defmt", derive(defmt::Format))]
480#[derive(Clone, Copy, Debug, PartialEq, Eq)]
481pub enum CTSW {
482    ///0: Clear CTS toggle detection flag
483    Clear = 0,
484}
485impl From<CTSW> for bool {
486    #[inline(always)]
487    fn from(variant: CTSW) -> Self {
488        variant as u8 != 0
489    }
490}
491///Field `CTS` writer - CTS flag
492pub type CTS_W<'a, REG> = crate::BitWriter0C<'a, REG, CTSW>;
493impl<'a, REG> CTS_W<'a, REG>
494where
495    REG: crate::Writable + crate::RegisterSpec,
496{
497    ///Clear CTS toggle detection flag
498    #[inline(always)]
499    pub fn clear(self) -> &'a mut crate::W<REG> {
500        self.variant(CTSW::Clear)
501    }
502}
503impl R {
504    ///Bit 0 - Parity error
505    #[inline(always)]
506    pub fn pe(&self) -> PE_R {
507        PE_R::new((self.bits & 1) != 0)
508    }
509    ///Bit 1 - Framing error
510    #[inline(always)]
511    pub fn fe(&self) -> FE_R {
512        FE_R::new(((self.bits >> 1) & 1) != 0)
513    }
514    ///Bit 2 - Noise error flag
515    #[inline(always)]
516    pub fn ne(&self) -> NE_R {
517        NE_R::new(((self.bits >> 2) & 1) != 0)
518    }
519    ///Bit 3 - Overrun error
520    #[inline(always)]
521    pub fn ore(&self) -> ORE_R {
522        ORE_R::new(((self.bits >> 3) & 1) != 0)
523    }
524    ///Bit 4 - IDLE line detected
525    #[inline(always)]
526    pub fn idle(&self) -> IDLE_R {
527        IDLE_R::new(((self.bits >> 4) & 1) != 0)
528    }
529    ///Bit 5 - Read data register not empty
530    #[inline(always)]
531    pub fn rxne(&self) -> RXNE_R {
532        RXNE_R::new(((self.bits >> 5) & 1) != 0)
533    }
534    ///Bit 6 - Transmission complete
535    #[inline(always)]
536    pub fn tc(&self) -> TC_R {
537        TC_R::new(((self.bits >> 6) & 1) != 0)
538    }
539    ///Bit 7 - Transmit data register empty
540    #[inline(always)]
541    pub fn txe(&self) -> TXE_R {
542        TXE_R::new(((self.bits >> 7) & 1) != 0)
543    }
544    ///Bit 8 - LIN break detection flag
545    #[inline(always)]
546    pub fn lbd(&self) -> LBD_R {
547        LBD_R::new(((self.bits >> 8) & 1) != 0)
548    }
549    ///Bit 9 - CTS flag
550    #[inline(always)]
551    pub fn cts(&self) -> CTS_R {
552        CTS_R::new(((self.bits >> 9) & 1) != 0)
553    }
554}
555impl core::fmt::Debug for R {
556    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
557        f.debug_struct("SR")
558            .field("cts", &self.cts())
559            .field("lbd", &self.lbd())
560            .field("txe", &self.txe())
561            .field("tc", &self.tc())
562            .field("rxne", &self.rxne())
563            .field("idle", &self.idle())
564            .field("ore", &self.ore())
565            .field("ne", &self.ne())
566            .field("fe", &self.fe())
567            .field("pe", &self.pe())
568            .finish()
569    }
570}
571impl W {
572    ///Bit 5 - Read data register not empty
573    #[inline(always)]
574    pub fn rxne(&mut self) -> RXNE_W<SRrs> {
575        RXNE_W::new(self, 5)
576    }
577    ///Bit 6 - Transmission complete
578    #[inline(always)]
579    pub fn tc(&mut self) -> TC_W<SRrs> {
580        TC_W::new(self, 6)
581    }
582    ///Bit 8 - LIN break detection flag
583    #[inline(always)]
584    pub fn lbd(&mut self) -> LBD_W<SRrs> {
585        LBD_W::new(self, 8)
586    }
587    ///Bit 9 - CTS flag
588    #[inline(always)]
589    pub fn cts(&mut self) -> CTS_W<SRrs> {
590        CTS_W::new(self, 9)
591    }
592}
593/**Status register
594
595You 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).
596
597See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F107.html#USART1:SR)*/
598pub struct SRrs;
599impl crate::RegisterSpec for SRrs {
600    type Ux = u16;
601}
602///`read()` method returns [`sr::R`](R) reader structure
603impl crate::Readable for SRrs {}
604///`write(|w| ..)` method takes [`sr::W`](W) writer structure
605impl crate::Writable for SRrs {
606    type Safety = crate::Unsafe;
607    const ZERO_TO_MODIFY_FIELDS_BITMAP: u16 = 0x0360;
608}
609///`reset()` method sets SR to value 0xc0
610impl crate::Resettable for SRrs {
611    const RESET_VALUE: u16 = 0xc0;
612}