stm32f1_staging/stm32f103/bkp/
csr.rs

1///Register `CSR` reader
2pub type R = crate::R<CSRrs>;
3///Register `CSR` writer
4pub type W = crate::W<CSRrs>;
5/**Clear Tamper event
6
7Value on reset: 0*/
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum CTEW {
11    ///1: Reset the TEF Tamper event flag (and the Tamper detector)
12    Reset = 1,
13}
14impl From<CTEW> for bool {
15    #[inline(always)]
16    fn from(variant: CTEW) -> Self {
17        variant as u8 != 0
18    }
19}
20///Field `CTE` writer - Clear Tamper event
21pub type CTE_W<'a, REG> = crate::BitWriter<'a, REG, CTEW>;
22impl<'a, REG> CTE_W<'a, REG>
23where
24    REG: crate::Writable + crate::RegisterSpec,
25{
26    ///Reset the TEF Tamper event flag (and the Tamper detector)
27    #[inline(always)]
28    pub fn reset(self) -> &'a mut crate::W<REG> {
29        self.variant(CTEW::Reset)
30    }
31}
32/**Clear Tamper Interrupt
33
34Value on reset: 0*/
35#[cfg_attr(feature = "defmt", derive(defmt::Format))]
36#[derive(Clone, Copy, Debug, PartialEq, Eq)]
37pub enum CTIW {
38    ///1: Clear the Tamper interrupt and the TIF Tamper interrupt flag
39    Clear = 1,
40}
41impl From<CTIW> for bool {
42    #[inline(always)]
43    fn from(variant: CTIW) -> Self {
44        variant as u8 != 0
45    }
46}
47///Field `CTI` writer - Clear Tamper Interrupt
48pub type CTI_W<'a, REG> = crate::BitWriter<'a, REG, CTIW>;
49impl<'a, REG> CTI_W<'a, REG>
50where
51    REG: crate::Writable + crate::RegisterSpec,
52{
53    ///Clear the Tamper interrupt and the TIF Tamper interrupt flag
54    #[inline(always)]
55    pub fn clear(self) -> &'a mut crate::W<REG> {
56        self.variant(CTIW::Clear)
57    }
58}
59/**Tamper Pin interrupt enable
60
61Value on reset: 0*/
62#[cfg_attr(feature = "defmt", derive(defmt::Format))]
63#[derive(Clone, Copy, Debug, PartialEq, Eq)]
64pub enum TPIE {
65    ///0: Tamper interrupt disabled
66    Disabled = 0,
67    ///1: Tamper interrupt enabled (the TPE bit must also be set in the BKP_CR register
68    Enabled = 1,
69}
70impl From<TPIE> for bool {
71    #[inline(always)]
72    fn from(variant: TPIE) -> Self {
73        variant as u8 != 0
74    }
75}
76///Field `TPIE` reader - Tamper Pin interrupt enable
77pub type TPIE_R = crate::BitReader<TPIE>;
78impl TPIE_R {
79    ///Get enumerated values variant
80    #[inline(always)]
81    pub const fn variant(&self) -> TPIE {
82        match self.bits {
83            false => TPIE::Disabled,
84            true => TPIE::Enabled,
85        }
86    }
87    ///Tamper interrupt disabled
88    #[inline(always)]
89    pub fn is_disabled(&self) -> bool {
90        *self == TPIE::Disabled
91    }
92    ///Tamper interrupt enabled (the TPE bit must also be set in the BKP_CR register
93    #[inline(always)]
94    pub fn is_enabled(&self) -> bool {
95        *self == TPIE::Enabled
96    }
97}
98///Field `TPIE` writer - Tamper Pin interrupt enable
99pub type TPIE_W<'a, REG> = crate::BitWriter<'a, REG, TPIE>;
100impl<'a, REG> TPIE_W<'a, REG>
101where
102    REG: crate::Writable + crate::RegisterSpec,
103{
104    ///Tamper interrupt disabled
105    #[inline(always)]
106    pub fn disabled(self) -> &'a mut crate::W<REG> {
107        self.variant(TPIE::Disabled)
108    }
109    ///Tamper interrupt enabled (the TPE bit must also be set in the BKP_CR register
110    #[inline(always)]
111    pub fn enabled(self) -> &'a mut crate::W<REG> {
112        self.variant(TPIE::Enabled)
113    }
114}
115///Field `TEF` reader - Tamper Event Flag
116pub type TEF_R = crate::BitReader;
117///Field `TIF` reader - Tamper Interrupt Flag
118pub type TIF_R = crate::BitReader;
119impl R {
120    ///Bit 2 - Tamper Pin interrupt enable
121    #[inline(always)]
122    pub fn tpie(&self) -> TPIE_R {
123        TPIE_R::new(((self.bits >> 2) & 1) != 0)
124    }
125    ///Bit 8 - Tamper Event Flag
126    #[inline(always)]
127    pub fn tef(&self) -> TEF_R {
128        TEF_R::new(((self.bits >> 8) & 1) != 0)
129    }
130    ///Bit 9 - Tamper Interrupt Flag
131    #[inline(always)]
132    pub fn tif(&self) -> TIF_R {
133        TIF_R::new(((self.bits >> 9) & 1) != 0)
134    }
135}
136impl core::fmt::Debug for R {
137    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
138        f.debug_struct("CSR")
139            .field("tpie", &self.tpie())
140            .field("tef", &self.tef())
141            .field("tif", &self.tif())
142            .finish()
143    }
144}
145impl W {
146    ///Bit 0 - Clear Tamper event
147    #[inline(always)]
148    pub fn cte(&mut self) -> CTE_W<CSRrs> {
149        CTE_W::new(self, 0)
150    }
151    ///Bit 1 - Clear Tamper Interrupt
152    #[inline(always)]
153    pub fn cti(&mut self) -> CTI_W<CSRrs> {
154        CTI_W::new(self, 1)
155    }
156    ///Bit 2 - Tamper Pin interrupt enable
157    #[inline(always)]
158    pub fn tpie(&mut self) -> TPIE_W<CSRrs> {
159        TPIE_W::new(self, 2)
160    }
161}
162/**BKP_CSR control/status register (BKP_CSR)
163
164You can [`read`](crate::Reg::read) this register and get [`csr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`csr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
165
166See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F103.html#BKP:CSR)*/
167pub struct CSRrs;
168impl crate::RegisterSpec for CSRrs {
169    type Ux = u32;
170}
171///`read()` method returns [`csr::R`](R) reader structure
172impl crate::Readable for CSRrs {}
173///`write(|w| ..)` method takes [`csr::W`](W) writer structure
174impl crate::Writable for CSRrs {
175    type Safety = crate::Unsafe;
176}
177///`reset()` method sets CSR to value 0
178impl crate::Resettable for CSRrs {}